diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e1b58a..6166e7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Added + +- Added mail notification to `createOrganizationAndCostCenterWithAdminUser` mutation + ## [0.63.0] - 2024-12-04 ### Fixed - Remove merge marker from code diff --git a/node/resolvers/Mutations/Organizations.ts b/node/resolvers/Mutations/Organizations.ts index 6b22c3b..b2144ee 100644 --- a/node/resolvers/Mutations/Organizations.ts +++ b/node/resolvers/Mutations/Organizations.ts @@ -9,14 +9,14 @@ import { } from '../../mdSchema' import type { B2BSettingsInput, + Collection, DefaultCostCenterInput, + NormalizedOrganizationInput, Organization, OrganizationInput, - NormalizedOrganizationInput, OrganizationRequest, PaymentTerm, Price, - Collection, } from '../../typings' import { ORGANIZATION_REQUEST_STATUSES, @@ -202,7 +202,7 @@ const createOrganizationAndCostCenterWithAdminUser = async ( ctx: Context ) => { const { - clients: { storefrontPermissions }, + clients: { storefrontPermissions, mail }, vtex: { logger }, } = ctx @@ -246,6 +246,12 @@ const createOrganizationAndCostCenterWithAdminUser = async ( const { defaultCostCenter, costCenters } = organization const { email, firstName, lastName } = organization.b2bCustomerAdmin + const settings = (await B2BSettings.getB2BSettings( + undefined, + undefined, + ctx + )) as B2BSettingsInput + if (costCenters?.length) { await Promise.all( costCenters?.map(async (costCenter: DefaultCostCenterInput) => { @@ -307,6 +313,14 @@ const createOrganizationAndCostCenterWithAdminUser = async ( }) } + if (settings?.transactionEmailSettings?.organizationCreated) { + message({ + logger, + mail, + storefrontPermissions, + }).organizationCreated(organizationInput.name) + } + return { href: createOrganizationResult.Href, id: organizationId,