From 191722e8aeffc0c83a703f6adf448dce83dcf63c Mon Sep 17 00:00:00 2001 From: clement Date: Thu, 19 Sep 2024 12:45:41 +0200 Subject: [PATCH] rename roles using kebab case : back-office to-review agency-admin --- .../routers/admin/adminRouter.e2e.test.ts | 20 ++++++------- .../inclusionConnectedAllowed.e2e.test.ts | 2 +- .../RegisterAgencyToInclusionConnectUser.ts | 2 +- ...rAgencyToInclusionConnectUser.unit.test.ts | 6 ++-- .../convention/use-cases/GetConvention.ts | 2 +- .../use-cases/GetConvention.unit.test.ts | 2 +- .../convention/use-cases/RenewConvention.ts | 4 +-- .../use-cases/RenewConvention.unit.test.ts | 4 +-- .../RenewConventionMagicLink.unit.test.ts | 4 +-- .../UpdateConventionStatus.testHelpers.ts | 18 +++++------ .../use-cases/UpdateConventionStatus.ts | 2 +- .../UpdateConventionStatus.unit.test.ts | 14 ++++----- ...fyActorThatConventionNeedsModifications.ts | 8 ++--- ...tConventionNeedsModifications.unit.test.ts | 2 +- ...ifyAllActorsOfFinalConventionValidation.ts | 2 +- .../NotifyIcUserAgencyRightChanged.ts | 2 +- ...otifyIcUserAgencyRightChanged.unit.test.ts | 4 +-- .../PgUserRepository.integration.test.ts | 30 +++++++++---------- .../GetInclusionConnectedUser.unit.test.ts | 16 ++++++---- .../GetInclusionConnectedUsers.unit.test.ts | 8 ++--- ...ceTravailUsersToTheirAgencies.unit.test.ts | 10 +++---- .../RejectIcUserForAgency.unit.test.ts | 12 ++++---- .../UpdateUserForAgency.unit.test.ts | 6 ++-- back/src/utils/convention.ts | 12 +++++--- .../conventions/ConventionManageActions.tsx | 6 ++-- .../conventions/ConventionManageContent.tsx | 2 +- .../agency/AgencyUserModificationForm.tsx | 4 +-- .../src/app/components/agency/AgencyUsers.tsx | 4 +-- .../agency/IcUserAgenciesToReview.tsx | 2 +- .../agency/RegisterUsersToAgencies.tsx | 2 +- .../convention/RemindSignatoriesButton.tsx | 2 +- front/src/app/components/nps/NpsSection.tsx | 2 +- .../agency-dashboard/AgencyDashboardPage.tsx | 2 +- .../AdminGateway/SimulatedAdminGateway.ts | 6 ++-- .../icUsersAdmin/icUsersAdmin.selectors.ts | 4 +-- .../admin/icUsersAdmin/icUsersAdmin.test.ts | 12 ++++---- .../inclusionConnected.test.ts | 6 ++-- .../convention/conventionStatusTransitions.ts | 8 ++--- .../inclusionConnect/inclusionConnect.dto.ts | 14 ++++----- .../inclusionConnectedAllowed.dto.ts | 4 +-- shared/src/role/role.dto.ts | 8 ++--- 41 files changed, 144 insertions(+), 136 deletions(-) diff --git a/back/src/adapters/primary/routers/admin/adminRouter.e2e.test.ts b/back/src/adapters/primary/routers/admin/adminRouter.e2e.test.ts index 4cdb92ba82..8d9e06bee1 100644 --- a/back/src/adapters/primary/routers/admin/adminRouter.e2e.test.ts +++ b/back/src/adapters/primary/routers/admin/adminRouter.e2e.test.ts @@ -354,9 +354,9 @@ describe("Admin router", () => { describe(`${displayRouteName( adminRoutes.getInclusionConnectedUsers, )} List inclusion connected user`, () => { - it("200 - Gets the list of connected users with role 'toReview'", async () => { + it("200 - Gets the list of connected users with role 'to-review'", async () => { const response = await sharedRequest.getInclusionConnectedUsers({ - queryParams: { agencyRole: "toReview" }, + queryParams: { agencyRole: "to-review" }, headers: { authorization: token }, }); expectHttpResponseToEqual(response, { @@ -367,7 +367,7 @@ describe("Admin router", () => { it("401 - missing token", async () => { const response = await sharedRequest.getInclusionConnectedUsers({ - queryParams: { agencyRole: "toReview" }, + queryParams: { agencyRole: "to-review" }, headers: { authorization: "" }, }); expectHttpResponseToEqual(response, { @@ -380,7 +380,7 @@ describe("Admin router", () => { describe(`${displayRouteName( adminRoutes.updateUserRoleForAgency, )} Update user role for agency`, () => { - it("201 - Updates role of user from 'toReview' to 'counsellor' for given agency", async () => { + it("201 - Updates role of user from 'to-review' to 'counsellor' for given agency", async () => { const agency = new AgencyDtoBuilder() .withId("two-steps-validation-agency") .withCounsellorEmails(["fake-email@gmail.com"]) @@ -391,7 +391,7 @@ describe("Admin router", () => { firstName: "John", lastName: "Doe", agencyRights: [ - { agency, roles: ["toReview"], isNotifiedByEmail: false }, + { agency, roles: ["to-review"], isNotifiedByEmail: false }, ], dashboards: { agencies: {}, establishments: {} }, externalId: "john-external-id", @@ -435,7 +435,7 @@ describe("Admin router", () => { }); }); - it("400 - when trying to Update role of user from 'toReview' to 'counsellor' for agency that have only one step validation", async () => { + it("400 - when trying to Update role of user from 'to-review' to 'counsellor' for agency that have only one step validation", async () => { const agency = new AgencyDtoBuilder().build(); const inclusionConnectedUser: InclusionConnectedUser = { id: "my-user-id", @@ -443,7 +443,7 @@ describe("Admin router", () => { firstName: "John", lastName: "Doe", agencyRights: [ - { agency, roles: ["toReview"], isNotifiedByEmail: false }, + { agency, roles: ["to-review"], isNotifiedByEmail: false }, ], dashboards: { agencies: {}, establishments: {} }, externalId: "john-external-id", @@ -489,7 +489,7 @@ describe("Admin router", () => { expectObjectsToMatch(inMemoryUow.userRepository.agencyRightsByUserId, { [inclusionConnectedUser.id]: [ - { agency, roles: ["toReview"], isNotifiedByEmail: false }, + { agency, roles: ["to-review"], isNotifiedByEmail: false }, ], }); }); @@ -520,7 +520,7 @@ describe("Admin router", () => { firstName: "John", lastName: "Doe", agencyRights: [ - { agency, roles: ["toReview"], isNotifiedByEmail: false }, + { agency, roles: ["to-review"], isNotifiedByEmail: false }, ], dashboards: { agencies: {}, establishments: {} }, externalId: "john-external-id", @@ -563,7 +563,7 @@ describe("Admin router", () => { firstName: "John", lastName: "Doe", agencyRights: [ - { agency, roles: ["toReview"], isNotifiedByEmail: false }, + { agency, roles: ["to-review"], isNotifiedByEmail: false }, ], dashboards: { agencies: {}, establishments: {} }, externalId: "john-external-id", diff --git a/back/src/adapters/primary/routers/inclusionConnect/inclusionConnectedAllowed.e2e.test.ts b/back/src/adapters/primary/routers/inclusionConnect/inclusionConnectedAllowed.e2e.test.ts index 94b1eaee6b..ce04f32d6d 100644 --- a/back/src/adapters/primary/routers/inclusionConnect/inclusionConnectedAllowed.e2e.test.ts +++ b/back/src/adapters/primary/routers/inclusionConnect/inclusionConnectedAllowed.e2e.test.ts @@ -191,7 +191,7 @@ describe("InclusionConnectedAllowedRoutes", () => { expectToEqual(await inMemoryUow.userRepository.getById(userId), { ...inclusionConnectedUserWithRights, agencyRights: [ - { agency, roles: ["toReview"], isNotifiedByEmail: false }, + { agency, roles: ["to-review"], isNotifiedByEmail: false }, ], }); }); diff --git a/back/src/domains/agency/use-cases/RegisterAgencyToInclusionConnectUser.ts b/back/src/domains/agency/use-cases/RegisterAgencyToInclusionConnectUser.ts index a9c2f0cc56..7b3e1ee3f2 100644 --- a/back/src/domains/agency/use-cases/RegisterAgencyToInclusionConnectUser.ts +++ b/back/src/domains/agency/use-cases/RegisterAgencyToInclusionConnectUser.ts @@ -70,7 +70,7 @@ export class RegisterAgencyToInclusionConnectUser extends TransactionalUseCase< userId: user.id, agencyRights: agencies.map((agency) => ({ agency, - roles: ["toReview"], + roles: ["to-review"], isNotifiedByEmail: false, })), }), diff --git a/back/src/domains/agency/use-cases/RegisterAgencyToInclusionConnectUser.unit.test.ts b/back/src/domains/agency/use-cases/RegisterAgencyToInclusionConnectUser.unit.test.ts index f1afbb99ce..59746e4e46 100644 --- a/back/src/domains/agency/use-cases/RegisterAgencyToInclusionConnectUser.unit.test.ts +++ b/back/src/domains/agency/use-cases/RegisterAgencyToInclusionConnectUser.unit.test.ts @@ -109,7 +109,7 @@ describe("RegisterAgencyToInclusionConnectUser use case", () => { expectToEqual(inclusionConnectedUser, { ...user, agencyRights: [ - { agency: agency1, roles: ["toReview"], isNotifiedByEmail: false }, + { agency: agency1, roles: ["to-review"], isNotifiedByEmail: false }, ], dashboards: { agencies: {}, establishments: {} }, }); @@ -137,8 +137,8 @@ describe("RegisterAgencyToInclusionConnectUser use case", () => { expectToEqual(inclusionConnectedUser, { ...user, agencyRights: [ - { agency: agency1, roles: ["toReview"], isNotifiedByEmail: false }, - { agency: agency2, roles: ["toReview"], isNotifiedByEmail: false }, + { agency: agency1, roles: ["to-review"], isNotifiedByEmail: false }, + { agency: agency2, roles: ["to-review"], isNotifiedByEmail: false }, ], dashboards: { agencies: {}, establishments: {} }, }); diff --git a/back/src/domains/convention/use-cases/GetConvention.ts b/back/src/domains/convention/use-cases/GetConvention.ts index 84bc189542..d3f6e9a343 100644 --- a/back/src/domains/convention/use-cases/GetConvention.ts +++ b/back/src/domains/convention/use-cases/GetConvention.ts @@ -111,7 +111,7 @@ export class GetConvention extends TransactionalUseCase< conventionId: ConventionId, ): authPayload is InclusionConnectJwtPayload { if (!("role" in authPayload)) return true; - if (authPayload.role === "backOffice") return false; + if (authPayload.role === "back-office") return false; if (authPayload.applicationId === conventionId) return false; throw new ForbiddenError( `This token is not allowed to access convention with id ${conventionId}. Role was '${authPayload.role}'`, diff --git a/back/src/domains/convention/use-cases/GetConvention.unit.test.ts b/back/src/domains/convention/use-cases/GetConvention.unit.test.ts index ccbd530394..fcf2e63c26 100644 --- a/back/src/domains/convention/use-cases/GetConvention.unit.test.ts +++ b/back/src/domains/convention/use-cases/GetConvention.unit.test.ts @@ -59,7 +59,7 @@ describe("Get Convention", () => { firstName: "John", lastName: "Doe", agencyRights: [ - { roles: ["toReview"], agency, isNotifiedByEmail: false }, + { roles: ["to-review"], agency, isNotifiedByEmail: false }, ], dashboards: { agencies: {}, establishments: {} }, externalId: "john-external-id", diff --git a/back/src/domains/convention/use-cases/RenewConvention.ts b/back/src/domains/convention/use-cases/RenewConvention.ts index 8ed4bb18a2..8d2609bd46 100644 --- a/back/src/domains/convention/use-cases/RenewConvention.ts +++ b/back/src/domains/convention/use-cases/RenewConvention.ts @@ -34,7 +34,7 @@ export class RenewConvention extends TransactionalUseCase< uow: UnitOfWork, jwtPayload?: ConventionRelatedJwtPayload, ): Promise { - const allowedRoles: Role[] = ["validator", "counsellor", "backOffice"]; + const allowedRoles: Role[] = ["validator", "counsellor", "back-office"]; if (!jwtPayload) throw errors.user.unauthorized(); @@ -100,7 +100,7 @@ export class RenewConvention extends TransactionalUseCase< `Inclusion connected user '${jwtPayload.userId}' not found.`, ); - if (inclusionConnectedUser.isBackofficeAdmin) return ["backOffice"]; + if (inclusionConnectedUser.isBackofficeAdmin) return ["back-office"]; const agencyRight = inclusionConnectedUser.agencyRights.find( (agencyRight) => agencyRight.agency.id === convention.agencyId, diff --git a/back/src/domains/convention/use-cases/RenewConvention.unit.test.ts b/back/src/domains/convention/use-cases/RenewConvention.unit.test.ts index 5598074aa7..28847f5ce9 100644 --- a/back/src/domains/convention/use-cases/RenewConvention.unit.test.ts +++ b/back/src/domains/convention/use-cases/RenewConvention.unit.test.ts @@ -273,14 +273,14 @@ describe("RenewConvention", () => { { ...inclusionConnectedUser, agencyRights: [ - { agency, roles: ["agencyAdmin"], isNotifiedByEmail: false }, + { agency, roles: ["agency-admin"], isNotifiedByEmail: false }, ], }, ]); await expectPromiseToFailWithError( renewConvention.execute(renewConventionParams, inclusionConnectPayload), new ForbiddenError( - "The role 'agencyAdmin' is not allowed to renew convention", + "The role 'agency-admin' is not allowed to renew convention", ), ); }); diff --git a/back/src/domains/convention/use-cases/RenewConventionMagicLink.unit.test.ts b/back/src/domains/convention/use-cases/RenewConventionMagicLink.unit.test.ts index 365b0b671f..3adb4c66ac 100644 --- a/back/src/domains/convention/use-cases/RenewConventionMagicLink.unit.test.ts +++ b/back/src/domains/convention/use-cases/RenewConventionMagicLink.unit.test.ts @@ -238,7 +238,7 @@ describe("RenewConventionMagicLink use case", () => { it("Refuses to generate backoffice magic links", async () => { const payload = createConventionMagicLinkPayload({ id: validConvention.id, - role: "backOffice", + role: "back-office", email, now: timeGateway.now(), }); @@ -250,7 +250,7 @@ describe("RenewConventionMagicLink use case", () => { await expectPromiseToFailWithError( useCase.execute(request), - errors.convention.roleHasNoMagicLink({ role: "backOffice" }), + errors.convention.roleHasNoMagicLink({ role: "back-office" }), ); }); diff --git a/back/src/domains/convention/use-cases/UpdateConventionStatus.testHelpers.ts b/back/src/domains/convention/use-cases/UpdateConventionStatus.testHelpers.ts index b42774bbe8..38569784b5 100644 --- a/back/src/domains/convention/use-cases/UpdateConventionStatus.testHelpers.ts +++ b/back/src/domains/convention/use-cases/UpdateConventionStatus.testHelpers.ts @@ -80,12 +80,12 @@ const makeUserIdMapInclusionConnectedUser: Record< agencyRights: [ { agency: agencyWithoutCounsellorEmail, - roles: ["toReview"], + roles: ["to-review"], isNotifiedByEmail: false, }, { agency: agencyWithCounsellorEmails, - roles: ["toReview"], + roles: ["to-review"], isNotifiedByEmail: false, }, ], @@ -165,12 +165,12 @@ const makeUserIdMapInclusionConnectedUser: Record< agencyRights: [ { agency: agencyWithoutCounsellorEmail, - roles: ["agencyAdmin"], + roles: ["agency-admin"], isNotifiedByEmail: false, }, { agency: agencyWithCounsellorEmails, - roles: ["agencyAdmin"], + roles: ["agency-admin"], isNotifiedByEmail: false, }, ], @@ -607,7 +607,7 @@ export const rejectStatusTransitionTests = ({ if (user.email === establishmentRepEmail) return ["establishment-representative"]; - if (user.isBackofficeAdmin) return ["backOffice"]; + if (user.isBackofficeAdmin) return ["back-office"]; return ( user.agencyRights.find( @@ -730,7 +730,7 @@ const defineRolesForTest = ( return ["establishment-representative"]; if (testAcceptNewStatusParams.userId === "icUserWithRoleBackofficeAdmin") - return ["backOffice"]; + return ["back-office"]; const roles = makeUserIdMapInclusionConnectedUser[ @@ -754,8 +754,8 @@ export const agencyRolesEmptyOrContainsToReviewOrAgencyAdmin = ( roles: (AgencyRole | Role)[], ): roles is ExcludeFromExisting< AgencyRole | Role, - "toReview" | "agencyAdmin" + "to-review" | "agency-admin" >[] => roles.length === 0 || - roles.includes("toReview") || - roles.includes("agencyAdmin"); + roles.includes("to-review") || + roles.includes("agency-admin"); diff --git a/back/src/domains/convention/use-cases/UpdateConventionStatus.ts b/back/src/domains/convention/use-cases/UpdateConventionStatus.ts index 2a642fcc90..30040beb79 100644 --- a/back/src/domains/convention/use-cases/UpdateConventionStatus.ts +++ b/back/src/domains/convention/use-cases/UpdateConventionStatus.ts @@ -226,7 +226,7 @@ export class UpdateConventionStatus extends TransactionalUseCase< convention: ConventionDto, ): Promise { const roles: Role[] = []; - if (user.isBackofficeAdmin) roles.push("backOffice"); + if (user.isBackofficeAdmin) roles.push("back-office"); if (user.email === convention.signatories.establishmentRepresentative.email) roles.push("establishment-representative"); diff --git a/back/src/domains/convention/use-cases/UpdateConventionStatus.unit.test.ts b/back/src/domains/convention/use-cases/UpdateConventionStatus.unit.test.ts index 5b7a9d8e43..e57c1d0a7b 100644 --- a/back/src/domains/convention/use-cases/UpdateConventionStatus.unit.test.ts +++ b/back/src/domains/convention/use-cases/UpdateConventionStatus.unit.test.ts @@ -45,7 +45,7 @@ describe("UpdateConventionStatus", () => { "beneficiary-current-employer", "counsellor", "validator", - "backOffice", + "back-office", ], allowedInclusionConnectedUsers: [ "icUserWithRoleCounsellor", @@ -75,7 +75,7 @@ describe("UpdateConventionStatus", () => { "beneficiary-current-employer", "counsellor", "validator", - "backOffice", + "back-office", ], allowedInclusionConnectedUsers: [ "icUserWithRoleCounsellor", @@ -452,7 +452,7 @@ describe("UpdateConventionStatus", () => { }, expectedDomainTopic: "ConventionRejected", updatedFields: { statusJustification: "my rejection justification" }, - allowedMagicLinkRoles: ["backOffice", "validator", "counsellor"], + allowedMagicLinkRoles: ["back-office", "validator", "counsellor"], allowedInclusionConnectedUsers: [ "icUserWithRoleValidator", "icUserWithRoleCounsellor", @@ -472,7 +472,7 @@ describe("UpdateConventionStatus", () => { statusJustification: "my rejection justification", conventionId: originalConventionId, }, - allowedMagicLinkRoles: ["backOffice", "validator", "counsellor"], + allowedMagicLinkRoles: ["back-office", "validator", "counsellor"], allowedInclusionConnectedUsers: [ "icUserWithRoleValidator", "icUserWithRoleCounsellor", @@ -497,7 +497,7 @@ describe("UpdateConventionStatus", () => { }, expectedDomainTopic: "ConventionCancelled", updatedFields: { statusJustification: "Cancelled justification" }, - allowedMagicLinkRoles: ["validator", "backOffice"], + allowedMagicLinkRoles: ["validator", "back-office"], allowedInclusionConnectedUsers: [ "icUserWithRoleValidator", "icUserWithRoleBackofficeAdmin", @@ -511,7 +511,7 @@ describe("UpdateConventionStatus", () => { statusJustification: "Cancelled justification", conventionId: originalConventionId, }, - allowedMagicLinkRoles: ["validator", "backOffice"], + allowedMagicLinkRoles: ["validator", "back-office"], allowedInclusionConnectedUsers: [ "icUserWithRoleValidator", "icUserWithRoleBackofficeAdmin", @@ -530,7 +530,7 @@ describe("UpdateConventionStatus", () => { }, expectedDomainTopic: "ConventionDeprecated", updatedFields: { statusJustification: "my deprecation justification" }, - allowedMagicLinkRoles: ["backOffice", "validator", "counsellor"], + allowedMagicLinkRoles: ["back-office", "validator", "counsellor"], allowedInclusionConnectedUsers: [ "icUserWithRoleCounsellor", "icUserWithRoleValidator", diff --git a/back/src/domains/convention/use-cases/notifications/NotifyActorThatConventionNeedsModifications.ts b/back/src/domains/convention/use-cases/notifications/NotifyActorThatConventionNeedsModifications.ts index f292c69c7f..4469f92ae9 100644 --- a/back/src/domains/convention/use-cases/notifications/NotifyActorThatConventionNeedsModifications.ts +++ b/back/src/domains/convention/use-cases/notifications/NotifyActorThatConventionNeedsModifications.ts @@ -91,7 +91,7 @@ export class NotifyActorThatConventionNeedsModifications extends TransactionalUs email: recipient, now: this.timeGateway.now(), // UGLY : need to rework, handling of JWT payloads - ...(recipientRole === "backOffice" + ...(recipientRole === "back-office" ? { sub: this.config.backofficeUsername } : {}), }; @@ -187,11 +187,11 @@ const requesterNameByRole = ( "establishment-representative": `${convention.signatories.establishmentRepresentative.firstName} ${convention.signatories.establishmentRepresentative.lastName} (le représentant légal de l'entreprise)`, counsellor: agency.name, validator: agency.name, - backOffice: "L'équipe Immersion Facilitée", - agencyAdmin: "Le responsable d'agence", + "back-office": "L'équipe Immersion Facilitée", + "agency-admin": "Le responsable d'agence", "establishment-tutor": new Error(wrongRequesterUser), "agency-viewer": new Error(wrongRequesterUser), - toReview: new Error(wrongRequesterUser), + "to-review": new Error(wrongRequesterUser), }; return strategy[requesterRole]; }; diff --git a/back/src/domains/convention/use-cases/notifications/NotifyActorThatConventionNeedsModifications.unit.test.ts b/back/src/domains/convention/use-cases/notifications/NotifyActorThatConventionNeedsModifications.unit.test.ts index 0e99bc027a..675badfecc 100644 --- a/back/src/domains/convention/use-cases/notifications/NotifyActorThatConventionNeedsModifications.unit.test.ts +++ b/back/src/domains/convention/use-cases/notifications/NotifyActorThatConventionNeedsModifications.unit.test.ts @@ -149,7 +149,7 @@ describe("NotifyActorThatConventionNeedsModifications", () => { requesterName: agency.name, }, { - requesterRole: "backOffice", + requesterRole: "back-office", modifierRole: "beneficiary", email: [convention.signatories.beneficiary.email], requesterName: "L'équipe Immersion Facilitée", diff --git a/back/src/domains/convention/use-cases/notifications/NotifyAllActorsOfFinalConventionValidation.ts b/back/src/domains/convention/use-cases/notifications/NotifyAllActorsOfFinalConventionValidation.ts index fdf0720f66..054dbdcf71 100644 --- a/back/src/domains/convention/use-cases/notifications/NotifyAllActorsOfFinalConventionValidation.ts +++ b/back/src/domains/convention/use-cases/notifications/NotifyAllActorsOfFinalConventionValidation.ts @@ -132,7 +132,7 @@ export class NotifyAllActorsOfFinalConventionValidation extends TransactionalUse now: this.#timeGateway.now(), exp: this.#timeGateway.now().getTime() + 1000 * 60 * 60 * 24 * 365, // 1 year // UGLY : need to rework, handling of JWT payloads - ...(role === "backOffice" + ...(role === "back-office" ? { sub: this.#config.backofficeUsername } : {}), }; diff --git a/back/src/domains/convention/use-cases/notifications/NotifyIcUserAgencyRightChanged.ts b/back/src/domains/convention/use-cases/notifications/NotifyIcUserAgencyRightChanged.ts index 398d715747..6f251159b7 100644 --- a/back/src/domains/convention/use-cases/notifications/NotifyIcUserAgencyRightChanged.ts +++ b/back/src/domains/convention/use-cases/notifications/NotifyIcUserAgencyRightChanged.ts @@ -30,7 +30,7 @@ export class NotifyIcUserAgencyRightChanged extends TransactionalUseCase< const user = await uow.userRepository.getById(params.userId); if (!user) throw errors.user.notFound({ userId: params.userId }); - if (!params.roles.includes("toReview")) + if (!params.roles.includes("to-review")) await this.#saveNotificationAndRelatedEvent(uow, { kind: "email", templatedContent: { diff --git a/back/src/domains/convention/use-cases/notifications/NotifyIcUserAgencyRightChanged.unit.test.ts b/back/src/domains/convention/use-cases/notifications/NotifyIcUserAgencyRightChanged.unit.test.ts index ae1f0a3c33..13be4d260c 100644 --- a/back/src/domains/convention/use-cases/notifications/NotifyIcUserAgencyRightChanged.unit.test.ts +++ b/back/src/domains/convention/use-cases/notifications/NotifyIcUserAgencyRightChanged.unit.test.ts @@ -99,7 +99,7 @@ describe("SendEmailWhenAgencyIsActivated", () => { }, agencyRights: [ { - roles: ["toReview"], + roles: ["to-review"], agency, isNotifiedByEmail: false, }, @@ -151,7 +151,7 @@ describe("SendEmailWhenAgencyIsActivated", () => { uow.userRepository.setInclusionConnectedUsers([icUser]); await notifyIcUserAgencyRightChanged.execute({ - roles: ["toReview"], + roles: ["to-review"], agencyId: "agency-1", userId: icUser.id, isNotifiedByEmail: false, diff --git a/back/src/domains/core/authentication/inclusion-connect/adapters/PgUserRepository.integration.test.ts b/back/src/domains/core/authentication/inclusion-connect/adapters/PgUserRepository.integration.test.ts index 456721045d..c51d0aa2d3 100644 --- a/back/src/domains/core/authentication/inclusion-connect/adapters/PgUserRepository.integration.test.ts +++ b/back/src/domains/core/authentication/inclusion-connect/adapters/PgUserRepository.integration.test.ts @@ -173,7 +173,7 @@ describe("PgAuthenticatedUserRepository", () => { await insertAgencyRegistrationToUser(db, { agencyId: agency1.id, userId: user1.id, - roles: ["toReview"], + roles: ["to-review"], isNotifiedByEmail: false, }); await insertAgencyRegistrationToUser(db, { @@ -188,7 +188,7 @@ describe("PgAuthenticatedUserRepository", () => { ...user1, establishments: [], agencyRights: [ - { agency: agency1, roles: ["toReview"], isNotifiedByEmail: false }, + { agency: agency1, roles: ["to-review"], isNotifiedByEmail: false }, { agency: agency2, roles: ["validator"], isNotifiedByEmail: false }, ], ...withEmptyDashboards, @@ -283,7 +283,7 @@ describe("PgAuthenticatedUserRepository", () => { await insertAgencyRegistrationToUser(db, { agencyId: agency1.id, userId: user1.id, - roles: ["toReview"], + roles: ["to-review"], isNotifiedByEmail: false, }); await insertAgencyRegistrationToUser(db, { @@ -295,7 +295,7 @@ describe("PgAuthenticatedUserRepository", () => { await insertAgencyRegistrationToUser(db, { agencyId: closedAgency.id, userId: user1.id, - roles: ["toReview"], + roles: ["to-review"], isNotifiedByEmail: false, }); await insertAgencyRegistrationToUser(db, { @@ -310,7 +310,7 @@ describe("PgAuthenticatedUserRepository", () => { ...user1, establishments: [], agencyRights: [ - { agency: agency1, roles: ["toReview"], isNotifiedByEmail: false }, + { agency: agency1, roles: ["to-review"], isNotifiedByEmail: false }, { agency: agency2, roles: ["validator"], isNotifiedByEmail: false }, ], ...withEmptyDashboards, @@ -423,7 +423,7 @@ describe("PgAuthenticatedUserRepository", () => { establishments: [], agencyRights: [ { agency: agency1, roles: ["validator"], isNotifiedByEmail: false }, - { agency: agency2, roles: ["toReview"], isNotifiedByEmail: false }, + { agency: agency2, roles: ["to-review"], isNotifiedByEmail: false }, ], ...withEmptyDashboards, }; @@ -497,7 +497,7 @@ describe("PgAuthenticatedUserRepository", () => { await insertAgencyRegistrationToUser(db, { agencyId: agency1.id, userId: user1.id, - roles: ["toReview"], + roles: ["to-review"], isNotifiedByEmail: false, }); @@ -505,7 +505,7 @@ describe("PgAuthenticatedUserRepository", () => { expect(icUsers).toEqual([]); }); - it("fetches Inclusion Connected Users with status 'toReview'", async () => { + it("fetches Inclusion Connected Users with status 'to-review'", async () => { await agencyRepository.insert(agency1); await agencyRepository.insert(agency2); await insertUser(db, user1); @@ -513,7 +513,7 @@ describe("PgAuthenticatedUserRepository", () => { await insertAgencyRegistrationToUser(db, { agencyId: agency1.id, userId: user1.id, - roles: ["toReview"], + roles: ["to-review"], isNotifiedByEmail: false, }); await insertAgencyRegistrationToUser(db, { @@ -525,12 +525,12 @@ describe("PgAuthenticatedUserRepository", () => { await insertAgencyRegistrationToUser(db, { agencyId: agency2.id, userId: user2.id, - roles: ["toReview"], + roles: ["to-review"], isNotifiedByEmail: false, }); const icUsers = await userRepository.getWithFilter({ - agencyRole: "toReview", + agencyRole: "to-review", }); expectArraysToEqualIgnoringOrder(icUsers, [ @@ -538,7 +538,7 @@ describe("PgAuthenticatedUserRepository", () => { ...user1, establishments: [], agencyRights: [ - { agency: agency1, roles: ["toReview"], isNotifiedByEmail: false }, + { agency: agency1, roles: ["to-review"], isNotifiedByEmail: false }, { agency: agency2, roles: ["validator"], isNotifiedByEmail: false }, ], ...withEmptyDashboards, @@ -547,7 +547,7 @@ describe("PgAuthenticatedUserRepository", () => { ...user2, establishments: [], agencyRights: [ - { agency: agency2, roles: ["toReview"], isNotifiedByEmail: false }, + { agency: agency2, roles: ["to-review"], isNotifiedByEmail: false }, ], ...withEmptyDashboards, }, @@ -568,7 +568,7 @@ describe("PgAuthenticatedUserRepository", () => { await insertAgencyRegistrationToUser(db, { agencyId: agency1.id, userId: user2.id, - roles: ["toReview"], + roles: ["to-review"], isNotifiedByEmail: false, }); await insertAgencyRegistrationToUser(db, { @@ -625,7 +625,7 @@ describe("PgAuthenticatedUserRepository", () => { await insertAgencyRegistrationToUser(db, { agencyId: agency1.id, userId: user2.id, - roles: ["toReview"], + roles: ["to-review"], isNotifiedByEmail: true, }); diff --git a/back/src/domains/inclusion-connected-users/use-cases/GetInclusionConnectedUser.unit.test.ts b/back/src/domains/inclusion-connected-users/use-cases/GetInclusionConnectedUser.unit.test.ts index d20d8076ef..f5cf5748d8 100644 --- a/back/src/domains/inclusion-connected-users/use-cases/GetInclusionConnectedUser.unit.test.ts +++ b/back/src/domains/inclusion-connected-users/use-cases/GetInclusionConnectedUser.unit.test.ts @@ -90,7 +90,7 @@ describe("GetUserAgencyDashboardUrl", () => { const [agencyRolesAllowedToGetDashboard, agencyRolesForbiddenToGetDashboard] = splitCasesBetweenPassingAndFailing(allAgencyRoles, [ - "agencyAdmin", + "agency-admin", "validator", "counsellor", "agency-viewer", @@ -163,7 +163,7 @@ describe("GetUserAgencyDashboardUrl", () => { }, ); - it("the dashboard url should not include the agency ids where role is 'toReview'", async () => { + it("the dashboard url should not include the agency ids where role is 'to-review'", async () => { const agencyBuilder = new AgencyDtoBuilder(); const agency1 = agencyBuilder .withId("1111") @@ -179,8 +179,12 @@ describe("GetUserAgencyDashboardUrl", () => { agencyRights: [ { agency: agency1, roles: ["counsellor"], isNotifiedByEmail: false }, { agency: agency2, roles: ["validator"], isNotifiedByEmail: false }, - { agency: agency3, roles: ["toReview"], isNotifiedByEmail: false }, - { agency: agency4, roles: ["agencyAdmin"], isNotifiedByEmail: false }, + { agency: agency3, roles: ["to-review"], isNotifiedByEmail: false }, + { + agency: agency4, + roles: ["agency-admin"], + isNotifiedByEmail: false, + }, ], dashboards: { agencies: {}, establishments: {} }, }, @@ -195,8 +199,8 @@ describe("GetUserAgencyDashboardUrl", () => { agencyRights: [ { agency: agency1, roles: ["counsellor"], isNotifiedByEmail: false }, { agency: agency2, roles: ["validator"], isNotifiedByEmail: false }, - { agency: agency3, roles: ["toReview"], isNotifiedByEmail: false }, - { agency: agency4, roles: ["agencyAdmin"], isNotifiedByEmail: false }, + { agency: agency3, roles: ["to-review"], isNotifiedByEmail: false }, + { agency: agency4, roles: ["agency-admin"], isNotifiedByEmail: false }, ], dashboards: { agencies: { diff --git a/back/src/domains/inclusion-connected-users/use-cases/GetInclusionConnectedUsers.unit.test.ts b/back/src/domains/inclusion-connected-users/use-cases/GetInclusionConnectedUsers.unit.test.ts index a57824cbe9..96b9147026 100644 --- a/back/src/domains/inclusion-connected-users/use-cases/GetInclusionConnectedUsers.unit.test.ts +++ b/back/src/domains/inclusion-connected-users/use-cases/GetInclusionConnectedUsers.unit.test.ts @@ -20,7 +20,7 @@ const johnWithAgenciesToReview: InclusionConnectedUser = { lastName: "Lennon", createdAt: new Date().toISOString(), agencyRights: [ - { agency: agency1, roles: ["toReview"], isNotifiedByEmail: false }, + { agency: agency1, roles: ["to-review"], isNotifiedByEmail: false }, { agency: agency2, roles: ["validator"], isNotifiedByEmail: false }, ], dashboards: { @@ -80,7 +80,7 @@ describe("GetInclusionConnectedUsers", () => { it("throws Unauthorized if no jwt token provided", async () => { await expectPromiseToFailWithError( - getInclusionConnectedUsers.execute({ agencyRole: "toReview" }), + getInclusionConnectedUsers.execute({ agencyRole: "to-review" }), errors.user.unauthorized(), ); }); @@ -90,7 +90,7 @@ describe("GetInclusionConnectedUsers", () => { await expectPromiseToFailWithError( getInclusionConnectedUsers.execute( - { agencyRole: "toReview" }, + { agencyRole: "to-review" }, notBackofficeAdminUser, ), errors.user.forbidden({ userId: notBackofficeAdminUser.id }), @@ -104,7 +104,7 @@ describe("GetInclusionConnectedUsers", () => { backofficeAdminUser, ]); const users = await getInclusionConnectedUsers.execute( - { agencyRole: "toReview" }, + { agencyRole: "to-review" }, backofficeAdminUser, ); diff --git a/back/src/domains/inclusion-connected-users/use-cases/LinkFranceTravailUsersToTheirAgencies.unit.test.ts b/back/src/domains/inclusion-connected-users/use-cases/LinkFranceTravailUsersToTheirAgencies.unit.test.ts index 732e8002a1..23e260d607 100644 --- a/back/src/domains/inclusion-connected-users/use-cases/LinkFranceTravailUsersToTheirAgencies.unit.test.ts +++ b/back/src/domains/inclusion-connected-users/use-cases/LinkFranceTravailUsersToTheirAgencies.unit.test.ts @@ -85,7 +85,7 @@ describe("LinkFranceTravailUsersToTheirAgencies", () => { const icUser: InclusionConnectedUser = { ...defaultUser, agencyRights: [ - { agency, roles: ["agencyAdmin"], isNotifiedByEmail: false }, + { agency, roles: ["agency-admin"], isNotifiedByEmail: false }, ], dashboards: { agencies: {}, @@ -103,16 +103,16 @@ describe("LinkFranceTravailUsersToTheirAgencies", () => { expectToEqual(uow.userRepository.agencyRightsByUserId, { [icUser.id]: [ - { agency, roles: ["agencyAdmin"], isNotifiedByEmail: false }, + { agency, roles: ["agency-admin"], isNotifiedByEmail: false }, ], }); }); - it("replace agency right to IC user if user already has rights on agency and current right is toReview", async () => { + it("replace agency right to IC user if user already has rights on agency and current right is to-review", async () => { const icUser: InclusionConnectedUser = { ...defaultUser, agencyRights: [ - { agency, roles: ["toReview"], isNotifiedByEmail: false }, + { agency, roles: ["to-review"], isNotifiedByEmail: false }, ], dashboards: { agencies: {}, @@ -243,7 +243,7 @@ describe("LinkFranceTravailUsersToTheirAgencies", () => { }, { agency: agency2InGroup, - roles: ["toReview"], + roles: ["to-review"], isNotifiedByEmail: false, }, ], diff --git a/back/src/domains/inclusion-connected-users/use-cases/RejectIcUserForAgency.unit.test.ts b/back/src/domains/inclusion-connected-users/use-cases/RejectIcUserForAgency.unit.test.ts index cbb3606043..821cdcfb74 100644 --- a/back/src/domains/inclusion-connected-users/use-cases/RejectIcUserForAgency.unit.test.ts +++ b/back/src/domains/inclusion-connected-users/use-cases/RejectIcUserForAgency.unit.test.ts @@ -56,7 +56,7 @@ describe("reject IcUser for agency", () => { const icUser: InclusionConnectedUser = { ...user, agencyRights: [ - { agency: agency1, roles: ["toReview"], isNotifiedByEmail: false }, + { agency: agency1, roles: ["to-review"], isNotifiedByEmail: false }, ], dashboards: { agencies: {}, @@ -102,7 +102,7 @@ describe("reject IcUser for agency", () => { const icUser: InclusionConnectedUser = { ...user, agencyRights: [ - { agency: agency1, roles: ["toReview"], isNotifiedByEmail: false }, + { agency: agency1, roles: ["to-review"], isNotifiedByEmail: false }, ], dashboards: { agencies: {}, @@ -129,7 +129,7 @@ describe("reject IcUser for agency", () => { const icUser: InclusionConnectedUser = { ...user, agencyRights: [ - { agency: agency1, roles: ["toReview"], isNotifiedByEmail: false }, + { agency: agency1, roles: ["to-review"], isNotifiedByEmail: false }, ], dashboards: { agencies: {}, @@ -164,8 +164,8 @@ describe("reject IcUser for agency", () => { const icUser: InclusionConnectedUser = { ...user, agencyRights: [ - { agency: agency1, roles: ["toReview"], isNotifiedByEmail: false }, - { agency: agency2, roles: ["toReview"], isNotifiedByEmail: false }, + { agency: agency1, roles: ["to-review"], isNotifiedByEmail: false }, + { agency: agency2, roles: ["to-review"], isNotifiedByEmail: false }, ], dashboards: { agencies: {}, @@ -191,7 +191,7 @@ describe("reject IcUser for agency", () => { expectToEqual(uow.userRepository.agencyRightsByUserId, { [icUser.id]: [ - { agency: agency2, roles: ["toReview"], isNotifiedByEmail: false }, + { agency: agency2, roles: ["to-review"], isNotifiedByEmail: false }, ], [backofficeAdminUser.id]: [], }); diff --git a/back/src/domains/inclusion-connected-users/use-cases/UpdateUserForAgency.unit.test.ts b/back/src/domains/inclusion-connected-users/use-cases/UpdateUserForAgency.unit.test.ts index 05dc3d1bc7..1f0baf42f5 100644 --- a/back/src/domains/inclusion-connected-users/use-cases/UpdateUserForAgency.unit.test.ts +++ b/back/src/domains/inclusion-connected-users/use-cases/UpdateUserForAgency.unit.test.ts @@ -269,7 +269,7 @@ describe("UpdateUserForAgency", () => { const icUser: InclusionConnectedUser = { ...notAdminUser, agencyRights: [ - { agency, roles: ["toReview"], isNotifiedByEmail: false }, + { agency, roles: ["to-review"], isNotifiedByEmail: false }, ], dashboards: { agencies: {}, @@ -296,7 +296,7 @@ describe("UpdateUserForAgency", () => { ]); const icUserRoleForAgency: UserParamsForAgency = { - roles: ["counsellor", "validator", "agencyAdmin"], + roles: ["counsellor", "validator", "agency-admin"], agencyId: agency.id, userId: notAdminUser.id, isNotifiedByEmail: false, @@ -346,7 +346,7 @@ describe("UpdateUserForAgency", () => { const icUser: InclusionConnectedUser = { ...notAdminUser, agencyRights: [ - { agency, roles: ["toReview"], isNotifiedByEmail: false }, + { agency, roles: ["to-review"], isNotifiedByEmail: false }, ], dashboards: { agencies: {}, diff --git a/back/src/utils/convention.ts b/back/src/utils/convention.ts index de2cc3b303..191943f4a9 100644 --- a/back/src/utils/convention.ts +++ b/back/src/utils/convention.ts @@ -4,8 +4,8 @@ export const conventionEmailsByRole = ( convention: ConventionDto, agency: AgencyDto, ): Record => ({ - backOffice: errors.convention.roleHasNoMagicLink({ role: "backOffice" }), - toReview: errors.convention.roleHasNoMagicLink({ role: "toReview" }), + "back-office": errors.convention.roleHasNoMagicLink({ role: "back-office" }), + "to-review": errors.convention.roleHasNoMagicLink({ role: "to-review" }), "agency-viewer": errors.convention.roleHasNoMagicLink({ role: "agency-viewer", }), @@ -25,7 +25,9 @@ export const conventionEmailsByRole = ( }), counsellor: agency.counsellorEmails, validator: agency.validatorEmails, - agencyAdmin: errors.convention.roleHasNoMagicLink({ role: "agencyAdmin" }), + "agency-admin": errors.convention.roleHasNoMagicLink({ + role: "agency-admin", + }), "establishment-representative": [ convention.signatories.establishmentRepresentative.email, ], @@ -39,7 +41,9 @@ export const conventionEmailsByRoleForMagicLinkRenewal = ( ): Record => { return { ...conventionEmailsByRole(convention, agency), - backOffice: errors.convention.roleHasNoMagicLink({ role: "backOffice" }), + "back-office": errors.convention.roleHasNoMagicLink({ + role: "back-office", + }), "establishment-tutor": errors.convention.unsupportedRoleRenewMagicLink({ role, }), diff --git a/front/src/app/components/admin/conventions/ConventionManageActions.tsx b/front/src/app/components/admin/conventions/ConventionManageActions.tsx index 9549d731ce..2105f73bad 100644 --- a/front/src/app/components/admin/conventions/ConventionManageActions.tsx +++ b/front/src/app/components/admin/conventions/ConventionManageActions.tsx @@ -123,8 +123,8 @@ export const ConventionManageActions = ({ allowedToSignStatuses.includes(convention.status); const requesterRoles = roles.filter( - (role): role is ExcludeFromExisting => - role !== "agencyAdmin", + (role): role is ExcludeFromExisting => + role !== "agency-admin", ); return ( @@ -292,7 +292,7 @@ export const ConventionManageActions = ({ jwtParams.jwt, ); const isConventionMagicLinkJwt = - "role" in payload && payload.role !== "backOffice"; + "role" in payload && payload.role !== "back-office"; return routes .conventionDocument({ jwt: isConventionMagicLinkJwt ? jwtParams.jwt : undefined, diff --git a/front/src/app/components/admin/conventions/ConventionManageContent.tsx b/front/src/app/components/admin/conventions/ConventionManageContent.tsx index f7a569b3ae..f61d05592f 100644 --- a/front/src/app/components/admin/conventions/ConventionManageContent.tsx +++ b/front/src/app/components/admin/conventions/ConventionManageContent.tsx @@ -41,7 +41,7 @@ export const ConventionManageContent = ({ .with( { name: "manageConventionAdmin" }, ({ inclusionConnectedRoles }): Role[] => [ - "backOffice", + "back-office", ...inclusionConnectedRoles, ], ) diff --git a/front/src/app/components/agency/AgencyUserModificationForm.tsx b/front/src/app/components/agency/AgencyUserModificationForm.tsx index b02f9c3381..b9d4343052 100644 --- a/front/src/app/components/agency/AgencyUserModificationForm.tsx +++ b/front/src/app/components/agency/AgencyUserModificationForm.tsx @@ -49,7 +49,7 @@ export const AgencyUserModificationForm = ({ const onValidSubmit = () => { const validatedUserRoles = values.roles.filter( - (role) => role !== "toReview", + (role) => role !== "to-review", ); match(mode) .with("add", () => { @@ -88,7 +88,7 @@ export const AgencyUserModificationForm = ({ }, [agencyUser, reset]); const availableRoles = keys(agencyRoleToDisplay).filter( - (role) => role !== "toReview", + (role) => role !== "to-review", ); const checkboxOptions = availableRoles.map((availableRole) => { return { diff --git a/front/src/app/components/agency/AgencyUsers.tsx b/front/src/app/components/agency/AgencyUsers.tsx index ba30a88efa..6337cb2a7e 100644 --- a/front/src/app/components/agency/AgencyUsers.tsx +++ b/front/src/app/components/agency/AgencyUsers.tsx @@ -35,7 +35,7 @@ export const agencyRoleToDisplay: Record< AgencyRole, AgencyDisplayedRoleAndClass > = { - toReview: { + "to-review": { label: "À valider", className: "fr-badge--yellow-tournesol", description: "", @@ -52,7 +52,7 @@ export const agencyRoleToDisplay: Record< description: "Peut pré-valider les conventions de l'agence et modifier leur statut.", }, - agencyAdmin: { + "agency-admin": { label: "Administrateur", className: "fr-badge--green-emeraude", description: diff --git a/front/src/app/components/agency/IcUserAgenciesToReview.tsx b/front/src/app/components/agency/IcUserAgenciesToReview.tsx index e1e3e42494..980a29fe9f 100644 --- a/front/src/app/components/agency/IcUserAgenciesToReview.tsx +++ b/front/src/app/components/agency/IcUserAgenciesToReview.tsx @@ -140,7 +140,7 @@ export const IcUserAgenciesToReview = ({ agencyId: selectedAgency.id, userId: selectedUser.id, email: selectedUser.email, - roles: ["toReview"], + roles: ["to-review"], isIcUser: true, isNotifiedByEmail: true, }} diff --git a/front/src/app/components/agency/RegisterUsersToAgencies.tsx b/front/src/app/components/agency/RegisterUsersToAgencies.tsx index ba4d3fcb71..6694eb12fc 100644 --- a/front/src/app/components/agency/RegisterUsersToAgencies.tsx +++ b/front/src/app/components/agency/RegisterUsersToAgencies.tsx @@ -24,7 +24,7 @@ export const RegisterUsersToAgencies = () => { useEffect(() => { dispatch( icUsersAdminSlice.actions.fetchInclusionConnectedUsersToReviewRequested({ - agencyRole: "toReview", + agencyRole: "to-review", }), ); }, [dispatch]); diff --git a/front/src/app/components/forms/convention/RemindSignatoriesButton.tsx b/front/src/app/components/forms/convention/RemindSignatoriesButton.tsx index f48fe3eee5..7500a6b4cd 100644 --- a/front/src/app/components/forms/convention/RemindSignatoriesButton.tsx +++ b/front/src/app/components/forms/convention/RemindSignatoriesButton.tsx @@ -57,7 +57,7 @@ export const isRemindingAllowed = ( const validRemindingRoles = [ "counsellor", "validator", - "backOffice", + "back-office", ...validSignatoryRoles, ]; diff --git a/front/src/app/components/nps/NpsSection.tsx b/front/src/app/components/nps/NpsSection.tsx index 52f6b2b704..2246cf5a18 100644 --- a/front/src/app/components/nps/NpsSection.tsx +++ b/front/src/app/components/nps/NpsSection.tsx @@ -17,7 +17,7 @@ export const NpsSection = ({ ]; return ( <> - {!roles.includes("backOffice") && + {!roles.includes("back-office") && npsShowStatuses.includes(convention.status) && ( - agencyRight.roles.includes("toReview"), + agencyRight.roles.includes("to-review"), ), ), }, diff --git a/front/src/core-logic/adapters/AdminGateway/SimulatedAdminGateway.ts b/front/src/core-logic/adapters/AdminGateway/SimulatedAdminGateway.ts index 7324b10435..b6f7fcf6a0 100644 --- a/front/src/core-logic/adapters/AdminGateway/SimulatedAdminGateway.ts +++ b/front/src/core-logic/adapters/AdminGateway/SimulatedAdminGateway.ts @@ -18,7 +18,7 @@ import { AdminGateway } from "src/core-logic/ports/AdminGateway"; const simulatedAgencyDtos: AgencyRight[] = [ { - roles: ["toReview"], + roles: ["to-review"], agency: new AgencyDtoBuilder() .withName("Agence de Bourg en Bresse") .withId("fake-agency-id-1") @@ -34,7 +34,7 @@ const simulatedAgencyDtos: AgencyRight[] = [ isNotifiedByEmail: true, }, { - roles: ["toReview"], + roles: ["to-review"], agency: new AgencyDtoBuilder() .withName("CCI de Quimper") .withId("fake-agency-id-3") @@ -131,7 +131,7 @@ export class SimulatedAdminGateway implements AdminGateway { lastName: "Jeplante", agencyRights: [ { - roles: ["toReview"], + roles: ["to-review"], agency: new AgencyDtoBuilder() .withName("Mission locale qui plante") .withId("non-existing-agency-id") diff --git a/front/src/core-logic/domain/admin/icUsersAdmin/icUsersAdmin.selectors.ts b/front/src/core-logic/domain/admin/icUsersAdmin/icUsersAdmin.selectors.ts index 7028b1a94a..b7fb1c5e72 100644 --- a/front/src/core-logic/domain/admin/icUsersAdmin/icUsersAdmin.selectors.ts +++ b/front/src/core-logic/domain/admin/icUsersAdmin/icUsersAdmin.selectors.ts @@ -34,7 +34,7 @@ const agenciesNeedingReviewForSelectedUser = createSelector( const inclusionConnectedUser = usersNeedingReview[selectedUser.id]; if (!inclusionConnectedUser) return []; return values(inclusionConnectedUser.agencyRights).filter(({ roles }) => - roles.includes("toReview"), + roles.includes("to-review"), ); }, ); @@ -45,7 +45,7 @@ const icUsersNeedingReview = createSelector( values(normalizedUsers) .filter((user) => values(user.agencyRights).some((right) => - right.roles.includes("toReview"), + right.roles.includes("to-review"), ), ) .map( diff --git a/front/src/core-logic/domain/admin/icUsersAdmin/icUsersAdmin.test.ts b/front/src/core-logic/domain/admin/icUsersAdmin/icUsersAdmin.test.ts index 16d636f793..9fb621f5b2 100644 --- a/front/src/core-logic/domain/admin/icUsersAdmin/icUsersAdmin.test.ts +++ b/front/src/core-logic/domain/admin/icUsersAdmin/icUsersAdmin.test.ts @@ -37,7 +37,7 @@ const agency4 = new AgencyDtoBuilder().withId("agency-4").build(); const agency1Right: AgencyRight = { agency: agency1, - roles: ["toReview"], + roles: ["to-review"], isNotifiedByEmail: true, }; const agency2Right: AgencyRight = { @@ -52,12 +52,12 @@ const user1AgencyRights: Record = { const agency3Right: AgencyRight = { agency: agency3, - roles: ["toReview"], + roles: ["to-review"], isNotifiedByEmail: true, }; const agency4Right: AgencyRight = { agency: agency4, - roles: ["toReview"], + roles: ["to-review"], isNotifiedByEmail: true, }; const user2AgencyRights: Record = { @@ -192,7 +192,7 @@ describe("Agency registration for authenticated users", () => { store.dispatch( icUsersAdminSlice.actions.fetchInclusionConnectedUsersToReviewRequested( { - agencyRole: "toReview", + agencyRole: "to-review", }, ), ); @@ -222,7 +222,7 @@ describe("Agency registration for authenticated users", () => { store.dispatch( icUsersAdminSlice.actions.fetchInclusionConnectedUsersToReviewRequested( { - agencyRole: "toReview", + agencyRole: "to-review", }, ), ); @@ -425,7 +425,7 @@ describe("Agency registration for authenticated users", () => { ...originalUser.agencyRights, [agency2.id]: { ...originalUser.agencyRights[agency2.id], - roles: ["agencyAdmin", "validator"], + roles: ["agency-admin", "validator"], isNotifiedByEmail: false, }, }, diff --git a/front/src/core-logic/domain/inclusionConnected/inclusionConnected.test.ts b/front/src/core-logic/domain/inclusionConnected/inclusionConnected.test.ts index 13afeafec2..a9ebaba1a2 100644 --- a/front/src/core-logic/domain/inclusionConnected/inclusionConnected.test.ts +++ b/front/src/core-logic/domain/inclusionConnected/inclusionConnected.test.ts @@ -38,7 +38,7 @@ describe("InclusionConnected", () => { }, agencyRights: [ { - roles: ["agencyAdmin"], + roles: ["agency-admin"], agency: new AgencyDtoBuilder().build(), isNotifiedByEmail: true, }, @@ -261,7 +261,7 @@ describe("InclusionConnected", () => { ...inclusionConnectedUser, agencyRights: [ { - roles: ["agencyAdmin", "validator"], + roles: ["agency-admin", "validator"], agency: new AgencyDtoBuilder().build(), isNotifiedByEmail: true, }, @@ -283,7 +283,7 @@ describe("InclusionConnected", () => { inclusionConnectedSelectors.userRolesForFetchedConvention( store.getState(), ), - ["backOffice", "agencyAdmin", "validator"], + ["back-office", "agency-admin", "validator"], ); }); }); diff --git a/shared/src/convention/conventionStatusTransitions.ts b/shared/src/convention/conventionStatusTransitions.ts index e40cf56fba..c8ac176290 100644 --- a/shared/src/convention/conventionStatusTransitions.ts +++ b/shared/src/convention/conventionStatusTransitions.ts @@ -61,11 +61,11 @@ export const statusTransitionConfigs: Record< "IN_REVIEW", "ACCEPTED_BY_COUNSELLOR", ], - validRoles: ["counsellor", "validator", "backOffice"], + validRoles: ["counsellor", "validator", "back-office"], }, CANCELLED: { validInitialStatuses: ["ACCEPTED_BY_VALIDATOR"], - validRoles: ["validator", "backOffice"], + validRoles: ["validator", "back-office"], }, // This enables the "require modifications" flow. The agents can put the request // back in the draft state for the beneficiary to modify the request and reapply. @@ -80,7 +80,7 @@ export const statusTransitionConfigs: Record< validRoles: [ "counsellor", "validator", - "backOffice", + "back-office", ...validSignatoryRoles, ], refine: (conventionRead) => { @@ -99,6 +99,6 @@ export const statusTransitionConfigs: Record< "READY_TO_SIGN", "DRAFT", ], - validRoles: ["counsellor", "validator", "backOffice"], + validRoles: ["counsellor", "validator", "back-office"], }, }; diff --git a/shared/src/inclusionConnect/inclusionConnect.dto.ts b/shared/src/inclusionConnect/inclusionConnect.dto.ts index 5cb0b41a96..2d561d0efb 100644 --- a/shared/src/inclusionConnect/inclusionConnect.dto.ts +++ b/shared/src/inclusionConnect/inclusionConnect.dto.ts @@ -4,9 +4,9 @@ import { InclusionConnectedUser, User, } from "../inclusionConnectedAllowed/inclusionConnectedAllowed.dto"; -import { EstablishmentRole } from "../role/role.dto"; +import { EstablishmentRole, Role } from "../role/role.dto"; import { allowedStartInclusionConnectLoginPages } from "../routes/routes"; -import { ExcludeFromExisting } from "../utils"; +import { ExcludeFromExisting, ExtractFromExisting } from "../utils"; export type AuthenticateWithInclusionCodeConnectParams = WithSourcePage & { code: string; @@ -25,16 +25,16 @@ export type AuthenticatedUserQueryParams = { } & Pick; type InclusionConnectConventionManageAllowedRole = - | ExcludeFromExisting | EstablishmentRole - | "backOffice"; + | ExtractFromExisting + | ExcludeFromExisting; export const getIcUserRoleForAccessingConvention = ( convention: ConventionDto, user: InclusionConnectedUser, ): InclusionConnectConventionManageAllowedRole[] => { const roles: InclusionConnectConventionManageAllowedRole[] = []; - if (user.isBackofficeAdmin) roles.push("backOffice"); + if (user.isBackofficeAdmin) roles.push("back-office"); if (convention.signatories.establishmentRepresentative.email === user.email) roles.push("establishment-representative"); if (convention.establishmentTutor.email === user.email) @@ -51,7 +51,7 @@ export const getIcUserRoleForAccessingConvention = ( export const agencyRoleIsNotToReview = ( agencyRoles: AgencyRole[], -): agencyRoles is ExcludeFromExisting[] => - !agencyRoles.includes("toReview"); +): agencyRoles is ExcludeFromExisting[] => + !agencyRoles.includes("to-review"); export const inclusionConnectTokenExpiredMessage = "Token is expired"; diff --git a/shared/src/inclusionConnectedAllowed/inclusionConnectedAllowed.dto.ts b/shared/src/inclusionConnectedAllowed/inclusionConnectedAllowed.dto.ts index 866bbe182b..f0cb566ae5 100644 --- a/shared/src/inclusionConnectedAllowed/inclusionConnectedAllowed.dto.ts +++ b/shared/src/inclusionConnectedAllowed/inclusionConnectedAllowed.dto.ts @@ -12,8 +12,8 @@ export type AgencyRole = (typeof allAgencyRoles)[number]; export const allAgencyRoles = [ "counsellor", "validator", - "agencyAdmin", - "toReview", + "agency-admin", + "to-review", "agency-viewer", ] as const; diff --git a/shared/src/role/role.dto.ts b/shared/src/role/role.dto.ts index 18e3e8e514..10e59092f1 100644 --- a/shared/src/role/role.dto.ts +++ b/shared/src/role/role.dto.ts @@ -13,9 +13,9 @@ export const allRoles = [ "establishment-tutor", "counsellor", "validator", - "backOffice", - "agencyAdmin", - "toReview", + "back-office", + "agency-admin", + "to-review", "agency-viewer", ] as const; @@ -41,7 +41,7 @@ export const allModifierRoles = [ ] as const; export const getRequesterRole = (roles: Role[]): Role => { - if (roles.includes("backOffice")) return "backOffice"; + if (roles.includes("back-office")) return "back-office"; if (roles.includes("validator")) return "validator"; if (roles.includes("counsellor")) return "counsellor"; return roles[0];