Skip to content

Commit

Permalink
feat(api): newly created certification authorities are now linked to …
Browse files Browse the repository at this point in the history
…all departments
  • Loading branch information
agarbe committed Nov 15, 2024
1 parent f67dee0 commit 389e84b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const createCertificationAuthorityMutation = graphql(`
$accountFirstname: String!
$accountLastname: String!
$certificationIds: [ID!]!
$departmentIds: [ID!]!
) {
certification_authority_createCertificationAuthority(
input: {
Expand All @@ -39,7 +38,6 @@ const createCertificationAuthorityMutation = graphql(`
accountFirstname: $accountFirstname
accountLastname: $accountLastname
certificationIds: $certificationIds
departmentIds: $departmentIds
}
) {
id
Expand Down Expand Up @@ -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) ||
[],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ input CreateCertificationAuthorityInput {
accountLastname: String!
accountEmail: String!
certificationAuthorityStructureId: ID!
departmentIds: [ID!]!
certificationIds: [ID!]!
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ const unsafeResolvers = {
contactEmail: string;
contactFullName: string;
certificationAuthorityStructureId: string;
departmentIds: string[];
certificationIds: string[];
};
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const createCertificationAuthority = async ({
accountLastname,
accountEmail,
certificationAuthorityStructureId,
departmentIds,
certificationIds,
}: {
label: string;
Expand All @@ -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: {
Expand All @@ -34,7 +36,9 @@ export const createCertificationAuthority = async ({
},
certificationAuthorityOnDepartment: {
createMany: {
data: departmentIds.map((departmentId) => ({ departmentId })),
data: allDepartements.map((d) => ({
departmentId: d.id,
})),
},
},
certificationAuthorityStructureId,
Expand Down

0 comments on commit 389e84b

Please sign in to comment.