Skip to content

Commit

Permalink
Merge pull request #187 from vtex-apps/feature/add-emails-create-orga…
Browse files Browse the repository at this point in the history
…nization

Mail notification to createOrganizationAndCostCenterWithAdminUser Mutation
  • Loading branch information
ataideverton authored Dec 10, 2024
2 parents 51f625a + 260087e commit 7a3a39d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 17 additions & 3 deletions node/resolvers/Mutations/Organizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -202,7 +202,7 @@ const createOrganizationAndCostCenterWithAdminUser = async (
ctx: Context
) => {
const {
clients: { storefrontPermissions },
clients: { storefrontPermissions, mail },
vtex: { logger },
} = ctx

Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -307,6 +313,14 @@ const createOrganizationAndCostCenterWithAdminUser = async (
})
}

if (settings?.transactionEmailSettings?.organizationCreated) {
message({
logger,
mail,
storefrontPermissions,
}).organizationCreated(organizationInput.name)
}

return {
href: createOrganizationResult.Href,
id: organizationId,
Expand Down

0 comments on commit 7a3a39d

Please sign in to comment.