diff --git a/api/src/identity-access-management/domain/emails/create-self-delete-user-account.email.js b/api/src/identity-access-management/domain/emails/create-self-delete-user-account.email.js new file mode 100644 index 00000000000..8a0563a1e66 --- /dev/null +++ b/api/src/identity-access-management/domain/emails/create-self-delete-user-account.email.js @@ -0,0 +1,25 @@ +import { EmailFactory } from '../../../shared/mail/domain/models/EmailFactory.js'; +import { mailer } from '../../../shared/mail/infrastructure/services/mailer.js'; + +export function createSelfDeleteUserAccountEmail({ locale, email, firstName }) { + const factory = new EmailFactory({ app: 'pix-app', locale }); + + const { i18n, defaultVariables } = factory; + + return factory.buildEmail({ + template: mailer.selfAccountDeletionTemplateId, + subject: i18n.__('self-account-deletion-email.subject'), + to: email, + variables: { + homeName: defaultVariables.homeName, + homeUrl: defaultVariables.homeUrl, + helpdeskUrl: defaultVariables.helpdeskUrl, + displayNationalLogo: defaultVariables.displayNationalLogo, + doNotAnswer: i18n.__('common.email.m doNotAnswer'), + moreOn: i18n.__('common.email.moreOn'), + pixPresentation: i18n.__('common.email.pixPresentation'), + title: i18n.__('self-account-deletion-email.params.title', { firstName }), + // "contactUs" + }, + }); +} diff --git a/api/tests/identity-access-management/unit/domain/emails/create-self-delete-user-account.email_test.js b/api/tests/identity-access-management/unit/domain/emails/create-self-delete-user-account.email_test.js new file mode 100644 index 00000000000..b8c81fd74e7 --- /dev/null +++ b/api/tests/identity-access-management/unit/domain/emails/create-self-delete-user-account.email_test.js @@ -0,0 +1,32 @@ +import { createSelfDeleteUserAccountEmail } from '../../../../../src/identity-access-management/domain/emails/create-self-delete-user-account.email.js'; +import { Email } from '../../../../../src/shared/mail/domain/models/Email.js'; +import { mailer } from '../../../../../src/shared/mail/infrastructure/services/mailer.js'; +import { expect } from '../../../../test-helper.js'; + +describe('Unit | Identity Access Management | Domain | Email | create-self-delete-user-account', function () { + it('creates self delete user account email with correct parameters', function () { + const emailParams = { + locale: 'fr', + email: 'test@example.com', + firstName: 'John', + token: '12345', + }; + + const email = createSelfDeleteUserAccountEmail(emailParams); + + expect(email).to.be.instanceof(Email); + expect(email).to.have.property('subject').that.is.a('string'); + expect(email.to).to.equal(emailParams.email); + expect(email.template).to.equal(mailer.selfAccountDeletionTemplateId); + + const variables = email.variables; + expect(variables).to.have.property('displayNationalLogo').that.is.a('boolean'); + expect(variables).to.have.property('doNotAnswer').that.is.a('string'); + expect(variables).to.have.property('helpdeskUrl').that.is.a('string'); + expect(variables).to.have.property('homeName').that.is.a('string'); + expect(variables).to.have.property('homeUrl').that.is.a('string'); + expect(variables).to.have.property('moreOn').that.is.a('string'); + expect(variables).to.have.property('pixPresentation').that.is.a('string'); + expect(variables).to.have.property('title').that.is.a('string'); + }); +}); diff --git a/api/translations/en.json b/api/translations/en.json index b31968a7f87..3e919e4cad3 100644 --- a/api/translations/en.json +++ b/api/translations/en.json @@ -386,11 +386,11 @@ "self-account-deletion-email": { "params": { "hello": "Hello {firstName},", - "requestConfirmation": "Following your request, we can confirm that your Pix account and personal data have been deleted.", - "seeYouSoon": "We hope to see you soon for new digital adventures.", - "signing": "The Pix team", + "requestConfirmation": "XXX", + "seeYouSoon": "XXX", + "signing": "XXX", "title": "Deleting your account", - "warning": "If you are not the source of this request, please contact support." + "warning": "XXX" }, "subject": "Deleting your account" },