notification implemented
This commit is contained in:
@@ -2,7 +2,11 @@ import bcrypt from 'bcryptjs'
|
||||
import { AppError } from '../../http/errors'
|
||||
import { prisma } from '../../lib/prisma'
|
||||
import { sendNotification } from '../../services/notificationService'
|
||||
import { signupEmail, type Lang } from '../../lib/emailTranslations'
|
||||
import {
|
||||
coerceNotificationLocale,
|
||||
localizeBillingPeriod,
|
||||
localizePlanName,
|
||||
} from '../../services/notificationLocalizationService'
|
||||
import { presentCompanySignup } from './auth.presenter'
|
||||
import * as repo from './auth.company.repo'
|
||||
import { companySignupSchema } from './auth.company.schemas'
|
||||
@@ -66,24 +70,24 @@ export async function signup(body: CompanySignupInput) {
|
||||
trialEndAt,
|
||||
}))
|
||||
|
||||
const lang = body.preferredLanguage as Lang
|
||||
const lang = coerceNotificationLocale(body.preferredLanguage)
|
||||
const emailResult = await sendNotification({
|
||||
type: 'SUBSCRIPTION_TRIAL_ENDING',
|
||||
title: signupEmail.subject(lang),
|
||||
body: signupEmail.text({
|
||||
firstName: body.firstName,
|
||||
companyName: body.companyName,
|
||||
plan: body.plan,
|
||||
billingPeriod: body.billingPeriod,
|
||||
currency: body.currency,
|
||||
paymentProvider: body.paymentProvider,
|
||||
trialEnd: trialEndAt,
|
||||
}, lang),
|
||||
type: 'ACCOUNT_CREATED',
|
||||
companyId: result.company.id,
|
||||
employeeId: result.employee.id,
|
||||
email: body.email,
|
||||
channels: ['EMAIL', 'IN_APP'],
|
||||
locale: lang,
|
||||
templateKey: 'account.created',
|
||||
templateVariables: {
|
||||
firstName: body.firstName,
|
||||
companyName: body.companyName,
|
||||
planName: localizePlanName(body.plan, lang),
|
||||
billingPeriodLabel: localizeBillingPeriod(body.billingPeriod, lang),
|
||||
currency: body.currency,
|
||||
paymentProvider: body.paymentProvider,
|
||||
trialEndDate: trialEndAt,
|
||||
},
|
||||
}).catch(() => [])
|
||||
|
||||
const emailDelivery = (emailResult as Array<{ channel?: string }>).find((entry) => entry.channel === 'EMAIL')
|
||||
|
||||
Reference in New Issue
Block a user