From fc565903578dd3ccb4ba76fad7729100709481c7 Mon Sep 17 00:00:00 2001 From: Alexandre Garbe Date: Fri, 6 Dec 2024 10:20:08 +0100 Subject: [PATCH] feat(api+admin): certification registry manager of a given certification can now delete a competence bloc --- .../updateCompetenceBloc.hook.ts | 5 ++++- .../updateCompetenceBloc.hook.ts | 5 ++++- packages/reva-api/modules/referential/referential.graphql | 3 ++- .../reva-api/modules/referential/referential.security.ts | 5 ++--- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/reva-admin-react/src/app/(admin)/certifications-v2/[certificationId]/bloc-competence/[certificationCompetenceBlocId]/updateCompetenceBloc.hook.ts b/packages/reva-admin-react/src/app/(admin)/certifications-v2/[certificationId]/bloc-competence/[certificationCompetenceBlocId]/updateCompetenceBloc.hook.ts index 074f36a9a..3e51656d6 100644 --- a/packages/reva-admin-react/src/app/(admin)/certifications-v2/[certificationId]/bloc-competence/[certificationCompetenceBlocId]/updateCompetenceBloc.hook.ts +++ b/packages/reva-admin-react/src/app/(admin)/certifications-v2/[certificationId]/bloc-competence/[certificationCompetenceBlocId]/updateCompetenceBloc.hook.ts @@ -39,9 +39,11 @@ const updateCertificationCompetenceBlocMutation = graphql(` const deleteCertificationCompetenceBlocMutation = graphql(` mutation deleteCertificationCompetenceBlocForUpdateCompetenceBlocPage( - $certificationCompetenceBlocId: String! + $certificationId: ID! + $certificationCompetenceBlocId: ID! ) { referential_deleteCertificationCompetenceBloc( + certificationId: $certificationId certificationCompetenceBlocId: $certificationCompetenceBlocId ) { id @@ -90,6 +92,7 @@ export const useUpdateCompetenceBlocPage = ({ const deleteCertificationCompetenceBloc = useMutation({ mutationFn: () => graphqlClient.request(deleteCertificationCompetenceBlocMutation, { + certificationId: competenceBloc?.certification.id || "", certificationCompetenceBlocId, }), }); diff --git a/packages/reva-admin-react/src/app/responsable-certifications/certifications/[certificationId]/bloc-competence/[certificationCompetenceBlocId]/updateCompetenceBloc.hook.ts b/packages/reva-admin-react/src/app/responsable-certifications/certifications/[certificationId]/bloc-competence/[certificationCompetenceBlocId]/updateCompetenceBloc.hook.ts index e22214301..5c4d9cd56 100644 --- a/packages/reva-admin-react/src/app/responsable-certifications/certifications/[certificationId]/bloc-competence/[certificationCompetenceBlocId]/updateCompetenceBloc.hook.ts +++ b/packages/reva-admin-react/src/app/responsable-certifications/certifications/[certificationId]/bloc-competence/[certificationCompetenceBlocId]/updateCompetenceBloc.hook.ts @@ -39,9 +39,11 @@ const updateCertificationCompetenceBlocMutation = graphql(` const deleteCertificationCompetenceBlocMutation = graphql(` mutation deleteCertificationCompetenceBlocForCertificationRegistryManagerUpdateCompetenceBlocPage( - $certificationCompetenceBlocId: String! + $certificationId: ID! + $certificationCompetenceBlocId: ID! ) { referential_deleteCertificationCompetenceBloc( + certificationId: $certificationId certificationCompetenceBlocId: $certificationCompetenceBlocId ) { id @@ -90,6 +92,7 @@ export const useUpdateCompetenceBlocPage = ({ const deleteCertificationCompetenceBloc = useMutation({ mutationFn: () => graphqlClient.request(deleteCertificationCompetenceBlocMutation, { + certificationId: competenceBloc?.certification.id || "", certificationCompetenceBlocId, }), }); diff --git a/packages/reva-api/modules/referential/referential.graphql b/packages/reva-api/modules/referential/referential.graphql index 1c66be866..2fc8a7126 100644 --- a/packages/reva-api/modules/referential/referential.graphql +++ b/packages/reva-api/modules/referential/referential.graphql @@ -376,7 +376,8 @@ type Mutation { input: UpdateCompetenceBlocInput! ): CertificationCompetenceBloc referential_deleteCertificationCompetenceBloc( - certificationCompetenceBlocId: String! + certificationId: ID! + certificationCompetenceBlocId: ID! ): CertificationCompetenceBloc! referential_addCertification(input: AddCertificationInput!): Certification! referential_updateCertificationStructureAndCertificationAuthorities( diff --git a/packages/reva-api/modules/referential/referential.security.ts b/packages/reva-api/modules/referential/referential.security.ts index 6627a403c..a6d699110 100644 --- a/packages/reva-api/modules/referential/referential.security.ts +++ b/packages/reva-api/modules/referential/referential.security.ts @@ -25,9 +25,8 @@ export const referentialResolversSecurityMap = { "Mutation.referential_updateCertificationCompetenceBloc": isAdminOrCertificationRegistryManagerOfCertification, "Mutation.referential_addCertification": [hasRole(["admin"])], - "Mutation.referential_deleteCertificationCompetenceBloc": [ - hasRole(["admin"]), - ], + "Mutation.referential_deleteCertificationCompetenceBloc": + isAdminOrCertificationRegistryManagerOfCertification, "Mutation.referential_updateCertificationStructureAndCertificationAuthorities": [hasRole(["admin"])], "Mutation.referential_sendCertificationToRegistryManager": [