From 10871ebbeced12ec7eb9b8c186f2d7f5e8733243 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artur=20Magalh=C3=A3es?= Date: Wed, 20 Nov 2024 16:44:05 -0500 Subject: [PATCH 1/3] feat: added mail notification to `createOrganizationAndCostCenterWithAdminUser` mutation --- CHANGELOG.md | 4 ++++ node/resolvers/Mutations/Organizations.ts | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64b869c9..ea0cc334 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.61.1] - 2024-10-29 ### Fixed diff --git a/node/resolvers/Mutations/Organizations.ts b/node/resolvers/Mutations/Organizations.ts index 6b22c3b1..3649845b 100644 --- a/node/resolvers/Mutations/Organizations.ts +++ b/node/resolvers/Mutations/Organizations.ts @@ -202,7 +202,7 @@ const createOrganizationAndCostCenterWithAdminUser = async ( ctx: Context ) => { const { - clients: { storefrontPermissions }, + clients: { storefrontPermissions, mail }, vtex: { logger }, } = ctx @@ -307,6 +307,12 @@ const createOrganizationAndCostCenterWithAdminUser = async ( }) } + message({ + logger, + mail, + storefrontPermissions, + }).organizationCreated(organizationInput.name) + return { href: createOrganizationResult.Href, id: organizationId, From 903d2af5fb03a8bf391951875d07451466a6da3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artur=20Magalh=C3=A3es?= Date: Tue, 10 Dec 2024 09:23:45 -0300 Subject: [PATCH 2/3] Update node/resolvers/Mutations/Organizations.ts Sure thing! It makes totally sense. Co-authored-by: ataideverton <56592231+ataideverton@users.noreply.github.com> --- node/resolvers/Mutations/Organizations.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/node/resolvers/Mutations/Organizations.ts b/node/resolvers/Mutations/Organizations.ts index 3649845b..0cea8c60 100644 --- a/node/resolvers/Mutations/Organizations.ts +++ b/node/resolvers/Mutations/Organizations.ts @@ -307,7 +307,13 @@ const createOrganizationAndCostCenterWithAdminUser = async ( }) } +if(settings?.transactionEmailSettings?.organizationCreated) { message({ + logger, + mail, + storefrontPermissions, + }).organizationCreated(organizationInput.name) +} logger, mail, storefrontPermissions, From 260087e8197111460b3d7a1222e46487b5e7dd63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artur=20Magalh=C3=A3es?= Date: Tue, 10 Dec 2024 09:29:46 -0300 Subject: [PATCH 3/3] fix: merge fixing --- node/resolvers/Mutations/Organizations.ts | 28 ++++++++++++----------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/node/resolvers/Mutations/Organizations.ts b/node/resolvers/Mutations/Organizations.ts index 0cea8c60..b2144eee 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, @@ -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,17 +313,13 @@ const createOrganizationAndCostCenterWithAdminUser = async ( }) } -if(settings?.transactionEmailSettings?.organizationCreated) { - message({ - logger, - mail, - storefrontPermissions, - }).organizationCreated(organizationInput.name) -} - logger, - mail, - storefrontPermissions, - }).organizationCreated(organizationInput.name) + if (settings?.transactionEmailSettings?.organizationCreated) { + message({ + logger, + mail, + storefrontPermissions, + }).organizationCreated(organizationInput.name) + } return { href: createOrganizationResult.Href,