diff --git a/admin/app/components/certification-centers/invitations.gjs b/admin/app/components/certification-centers/invitations.gjs
index 743195c8bb3..6d5073fc393 100644
--- a/admin/app/components/certification-centers/invitations.gjs
+++ b/admin/app/components/certification-centers/invitations.gjs
@@ -42,6 +42,16 @@ export default class CertificationCenterInvitations extends Component {
>
Annuler l’invitation
+
+ Renvoyer l’invitation
+
{{/each}}
diff --git a/admin/app/controllers/authenticated/certification-centers/get/invitations.js b/admin/app/controllers/authenticated/certification-centers/get/invitations.js
index 01d7fa5d5b2..0d07286da68 100644
--- a/admin/app/controllers/authenticated/certification-centers/get/invitations.js
+++ b/admin/app/controllers/authenticated/certification-centers/get/invitations.js
@@ -49,6 +49,24 @@ export default class AuthenticatedCertificationCentersGetInvitationsController e
this.isLoading = false;
}
+ @action
+ async sendNewCertificationCenterInvitation(certificationCenterInvitation) {
+ this.isLoading = true;
+ const { email, language, role } = certificationCenterInvitation;
+ try {
+ await this.store.queryRecord('certification-center-invitation', {
+ email,
+ language,
+ role,
+ certificationCenterId: this.model.certificationCenterId,
+ });
+
+ this.pixToast.sendSuccessNotification({ message: `Un email a bien a été envoyé à l'adresse ${email}.` });
+ } catch (err) {
+ this.errorResponseHandler.notify(err, this.CUSTOM_ERROR_MESSAGES);
+ }
+ }
+
_isEmailToInviteValid(email) {
if (!email) {
this.userEmailToInviteError = 'Ce champ est requis.';
diff --git a/admin/app/templates/authenticated/certification-centers/get/invitations.hbs b/admin/app/templates/authenticated/certification-centers/get/invitations.hbs
index 2ab30c7548c..f207c41c344 100644
--- a/admin/app/templates/authenticated/certification-centers/get/invitations.hbs
+++ b/admin/app/templates/authenticated/certification-centers/get/invitations.hbs
@@ -9,5 +9,6 @@
\ No newline at end of file
diff --git a/admin/tests/unit/controllers/authenticated/certification-centers/get/invitations-test.js b/admin/tests/unit/controllers/authenticated/certification-centers/get/invitations-test.js
index 396765b32d4..8c53eede607 100644
--- a/admin/tests/unit/controllers/authenticated/certification-centers/get/invitations-test.js
+++ b/admin/tests/unit/controllers/authenticated/certification-centers/get/invitations-test.js
@@ -85,5 +85,58 @@ module('Unit | Controller | authenticated/certification-centers/get/invitations'
sinon.assert.calledWith(notificationErrorStub, { message: 'Une erreur s’est produite, veuillez réessayer.' });
assert.ok(true);
});
+
+ module('#sendNewInvitation', function () {
+ test('It sends a new invitation', async function (assert) {
+ // given
+ const controller = this.owner.lookup('controller:authenticated/certification-centers/get/invitations');
+
+ const store = this.owner.lookup('service:store');
+ const queryRecordStub = sinon.stub();
+ store.queryRecord = queryRecordStub;
+ const certificationCenterInvitation = {
+ email: 'test@example.net',
+ language: 'en',
+ role: 'member',
+ certificationCenterId: 1,
+ };
+ // when
+ await controller.sendNewCertificationCenterInvitation(certificationCenterInvitation);
+
+ // then
+ assert.ok(
+ queryRecordStub.calledWith('certification-center-invitation', {
+ ...certificationCenterInvitation,
+ }),
+ );
+ });
+
+ test('When an error occurs, it should send a notification error', async function (assert) {
+ // given
+ const controller = this.owner.lookup('controller:authenticated/certification-centers/get/invitations');
+ const store = this.owner.lookup('service:store');
+ const anError = Symbol('an error');
+ store.queryRecord = sinon.stub().rejects(anError);
+ const notifyStub = sinon.stub();
+ class ErrorResponseHandler extends Service {
+ notify = notifyStub;
+ }
+ this.owner.register('service:error-response-handler', ErrorResponseHandler);
+ const customErrors = Symbol('custom errors');
+ controller.CUSTOM_ERROR_MESSAGES = customErrors;
+ const certificationCenterInvitation = {
+ email: 'test@example.net',
+ language: 'en',
+ role: 'member',
+ certificationCenterId: 1,
+ };
+
+ // when
+ await controller.sendNewCertificationCenterInvitation(certificationCenterInvitation);
+
+ // then
+ assert.ok(notifyStub.calledWithExactly(anError, customErrors));
+ });
+ });
});
});