Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mail notification to createOrganizationAndCostCenterWithAdminUser Mutation #187

Merged
merged 4 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading