diff --git a/packages/reva-admin-react/src/app/(admin)/certification-authority-structures/[certificationAuthorityStructureId]/certificateurs-administrateurs/create/createCertificationAuthority.hooks.ts b/packages/reva-admin-react/src/app/(admin)/certification-authority-structures/[certificationAuthorityStructureId]/certificateurs-administrateurs/create/createCertificationAuthority.hooks.ts index 4130c34c0..f3716e4cd 100644 --- a/packages/reva-admin-react/src/app/(admin)/certification-authority-structures/[certificationAuthorityStructureId]/certificateurs-administrateurs/create/createCertificationAuthority.hooks.ts +++ b/packages/reva-admin-react/src/app/(admin)/certification-authority-structures/[certificationAuthorityStructureId]/certificateurs-administrateurs/create/createCertificationAuthority.hooks.ts @@ -27,7 +27,6 @@ const createCertificationAuthorityMutation = graphql(` $accountFirstname: String! $accountLastname: String! $certificationIds: [ID!]! - $departmentIds: [ID!]! ) { certification_authority_createCertificationAuthority( input: { @@ -39,7 +38,6 @@ const createCertificationAuthorityMutation = graphql(` accountFirstname: $accountFirstname accountLastname: $accountLastname certificationIds: $certificationIds - departmentIds: $departmentIds } ) { id @@ -82,7 +80,6 @@ export const useCreateCertificationAuthorityPage = () => { certificationAuthorityStructureId: certificationAuthorityStructureId, contactEmail: params.email, contactFullName: `${params.firstname} ${params.lastname}`, - departmentIds: [], certificationIds: certificationAuthorityStructure?.certifications?.map((c) => c.id) || [], diff --git a/packages/reva-api/modules/certification-authority/certification-authority.graphql b/packages/reva-api/modules/certification-authority/certification-authority.graphql index 25e32ca9e..5b1e06e18 100644 --- a/packages/reva-api/modules/certification-authority/certification-authority.graphql +++ b/packages/reva-api/modules/certification-authority/certification-authority.graphql @@ -81,7 +81,6 @@ input CreateCertificationAuthorityInput { accountLastname: String! accountEmail: String! certificationAuthorityStructureId: ID! - departmentIds: [ID!]! certificationIds: [ID!]! } diff --git a/packages/reva-api/modules/certification-authority/certification-authority.resolvers.ts b/packages/reva-api/modules/certification-authority/certification-authority.resolvers.ts index be5850047..933c1e86d 100644 --- a/packages/reva-api/modules/certification-authority/certification-authority.resolvers.ts +++ b/packages/reva-api/modules/certification-authority/certification-authority.resolvers.ts @@ -174,7 +174,6 @@ const unsafeResolvers = { contactEmail: string; contactFullName: string; certificationAuthorityStructureId: string; - departmentIds: string[]; certificationIds: string[]; }; }, diff --git a/packages/reva-api/modules/certification-authority/features/createCertificationAuthority.ts b/packages/reva-api/modules/certification-authority/features/createCertificationAuthority.ts index 08c15ab1f..74b7973e7 100644 --- a/packages/reva-api/modules/certification-authority/features/createCertificationAuthority.ts +++ b/packages/reva-api/modules/certification-authority/features/createCertificationAuthority.ts @@ -9,7 +9,6 @@ export const createCertificationAuthority = async ({ accountLastname, accountEmail, certificationAuthorityStructureId, - departmentIds, certificationIds, }: { label: string; @@ -19,9 +18,12 @@ export const createCertificationAuthority = async ({ accountLastname: string; accountEmail: string; certificationAuthorityStructureId: string; - departmentIds: string[]; certificationIds: string[]; }) => { + const allDepartements = await prismaClient.department.findMany({ + select: { id: true }, + }); + const newCertificationAuthority = await prismaClient.certificationAuthority.create({ data: { @@ -34,7 +36,9 @@ export const createCertificationAuthority = async ({ }, certificationAuthorityOnDepartment: { createMany: { - data: departmentIds.map((departmentId) => ({ departmentId })), + data: allDepartements.map((d) => ({ + departmentId: d.id, + })), }, }, certificationAuthorityStructureId,