Skip to content

Commit 7d5fb48

Browse files
committed
feat(api+admin): certification authority can now have multiple structures
1 parent be88be9 commit 7d5fb48

File tree

11 files changed

+57
-24
lines changed

11 files changed

+57
-24
lines changed

packages/reva-admin-react/src/app/(admin)/certification-authority-structures/[certificationAuthorityStructureId]/certificateurs-administrateurs/[certificationAuthorityId]/certificationAuthority.hooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const getCertificationAuthority = graphql(`
3333
label
3434
}
3535
}
36-
certificationAuthorityStructure {
36+
certificationAuthorityStructures {
3737
id
3838
label
3939
}

packages/reva-admin-react/src/app/(admin)/certification-authority-structures/[certificationAuthorityStructureId]/certificateurs-administrateurs/[certificationAuthorityId]/certifications/certifications.hooks.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ const getCertificationAuthorityAndCertificationsQuery = graphql(`
1414
certification_authority_getCertificationAuthority(id: $id) {
1515
id
1616
label
17-
certificationAuthorityStructure {
17+
certificationAuthorityStructures {
18+
id
1819
label
1920
certifications {
2021
id
@@ -106,14 +107,14 @@ export const useCertificationsPage = ({
106107
) || false,
107108
}))
108109
.sort((c) =>
109-
certificationAuthority?.certificationAuthorityStructure?.certifications.some(
110-
(ca) => ca.id === c.id,
110+
certificationAuthority?.certificationAuthorityStructures?.some(
111+
(cas) => cas?.certifications.some((ca) => ca.id === c.id),
111112
)
112113
? -1
113114
: 1,
114115
),
115116
[
116-
certificationAuthority?.certificationAuthorityStructure?.certifications,
117+
certificationAuthority?.certificationAuthorityStructures,
117118
certificationAuthority?.certifications,
118119
getCertificationAuthorityAndCertificationsResponse
119120
?.searchCertificationsForAdmin?.rows,

packages/reva-admin-react/src/app/(admin)/certification-authority-structures/[certificationAuthorityStructureId]/certificateurs-administrateurs/[certificationAuthorityId]/certifications/page.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ const CertificationAuthorityCertificationsPage = () => {
4444
<CertificationAuthorityStructureBreadcrumb
4545
certificationAuthorityStructureId={certificationAuthorityStructureId}
4646
certificationAuthorityStructureLabel={
47-
certificationAuthority.certificationAuthorityStructure.label
47+
certificationAuthority.certificationAuthorityStructures.find(
48+
(s) => s.id === certificationAuthorityStructureId,
49+
)?.label || "inconnu"
4850
}
4951
certificationAuthorityId={certificationAuthorityId}
5052
certificationAuthoritylabel={certificationAuthority.label}

packages/reva-admin-react/src/app/(admin)/certification-authority-structures/[certificationAuthorityStructureId]/certificateurs-administrateurs/[certificationAuthorityId]/comptes-collaborateurs/[certificationAuthorityLocalAccountId]/comptesCollaborateurs.hooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const getCertificationAuthorityLocalAccountQuery = graphql(`
3636
certificationAuthority {
3737
id
3838
label
39-
certificationAuthorityStructure {
39+
certificationAuthorityStructures {
4040
id
4141
label
4242
}

packages/reva-admin-react/src/app/(admin)/certification-authority-structures/[certificationAuthorityStructureId]/certificateurs-administrateurs/[certificationAuthorityId]/comptes-collaborateurs/[certificationAuthorityLocalAccountId]/page.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ const CertificationAuthorityStructureComptesCollaborateursPage = () => {
5454
certificationAuthorityStructureId
5555
}
5656
certificationAuthorityStructureLabel={
57-
certificationAuthorityLocalAccount.certificationAuthority
58-
.certificationAuthorityStructure.label
57+
certificationAuthorityLocalAccount.certificationAuthority.certificationAuthorityStructures.find(
58+
(s) => s.id === certificationAuthorityStructureId,
59+
)?.label || "inconnu"
5960
}
6061
certificationAuthorityId={
6162
certificationAuthorityLocalAccount.certificationAuthority.id

packages/reva-admin-react/src/app/(admin)/certification-authority-structures/[certificationAuthorityStructureId]/certificateurs-administrateurs/[certificationAuthorityId]/page.tsx

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
useCertificationAuthority,
1515
useCertificationAuthorityForm,
1616
} from "./certificationAuthority.hooks";
17+
import { useParams } from "next/navigation";
1718

1819
type FormData = z.infer<typeof schema>;
1920

@@ -29,10 +30,12 @@ const schema = z.object({
2930

3031
const CertificationAuthorityAdminComponent = ({
3132
certificationAuthority,
33+
certificationAuthorityStructureId,
3234
}: {
3335
certificationAuthority: NonNullable<
3436
ReturnType<typeof useCertificationAuthority>["certificationAuthority"]
3537
>;
38+
certificationAuthorityStructureId: string;
3639
}) => {
3740
const { updateCertificationAuthority } = useCertificationAuthorityForm();
3841

@@ -86,11 +89,11 @@ const CertificationAuthorityAdminComponent = ({
8689
return (
8790
<div className="flex flex-col flex-1">
8891
<CertificationAuthorityStructureBreadcrumb
89-
certificationAuthorityStructureId={
90-
certificationAuthority.certificationAuthorityStructure.id
91-
}
92+
certificationAuthorityStructureId={certificationAuthorityStructureId}
9293
certificationAuthorityStructureLabel={
93-
certificationAuthority.certificationAuthorityStructure.label
94+
certificationAuthority.certificationAuthorityStructures.find(
95+
(s) => s.id === certificationAuthorityStructureId,
96+
)?.label || "inconnu"
9497
}
9598
pageLabel={certificationAuthority.label}
9699
/>
@@ -146,23 +149,23 @@ const CertificationAuthorityAdminComponent = ({
146149
</form>
147150
<InterventionAreaSummaryCard
148151
regions={regionsAndDepartments}
149-
updateButtonHref={`/certification-authority-structures/${certificationAuthority.certificationAuthorityStructure.id}/certificateurs-administrateurs/${certificationAuthority.id}/zone-intervention`}
152+
updateButtonHref={`/certification-authority-structures/${certificationAuthorityStructureId}/certificateurs-administrateurs/${certificationAuthority.id}/zone-intervention`}
150153
/>
151154
<CertificationsSummaryCard
152155
certifications={certificationAuthority.certifications}
153-
updateButtonHref={`/certification-authority-structures/${certificationAuthority.certificationAuthorityStructure.id}/certificateurs-administrateurs/${certificationAuthority.id}/certifications`}
156+
updateButtonHref={`/certification-authority-structures/${certificationAuthorityStructureId}/certificateurs-administrateurs/${certificationAuthority.id}/certifications`}
154157
/>
155158
<AccountsSummaryCard
156159
accounts={certificationAuthority.certificationAuthorityLocalAccounts}
157-
hrefPrefix={`/certification-authority-structures/${certificationAuthority.certificationAuthorityStructure.id}/certificateurs-administrateurs/${certificationAuthority.id}/comptes-collaborateurs`}
160+
hrefPrefix={`/certification-authority-structures/${certificationAuthorityStructureId}/certificateurs-administrateurs/${certificationAuthority.id}/comptes-collaborateurs`}
158161
/>
159162
</div>
160163
<div className="flex flex-row justify-end mt-4 gap-x-4">
161164
<Button
162165
className="mr-auto"
163166
priority="secondary"
164167
linkProps={{
165-
href: `/certification-authority-structures/${certificationAuthority.certificationAuthorityStructure.id}`,
168+
href: `/certification-authority-structures/${certificationAuthorityStructureId}`,
166169
}}
167170
>
168171
Retour
@@ -188,6 +191,10 @@ const CertificationAuthorityAdminPage = () => {
188191
const { certificationAuthority, getCertificationAuthorityStatus } =
189192
useCertificationAuthority();
190193

194+
const { certificationAuthorityStructureId } = useParams<{
195+
certificationAuthorityStructureId: string;
196+
}>();
197+
191198
if (
192199
!certificationAuthority ||
193200
getCertificationAuthorityStatus !== "success"
@@ -198,6 +205,7 @@ const CertificationAuthorityAdminPage = () => {
198205
return (
199206
<CertificationAuthorityAdminComponent
200207
certificationAuthority={certificationAuthority}
208+
certificationAuthorityStructureId={certificationAuthorityStructureId}
201209
/>
202210
);
203211
};

packages/reva-admin-react/src/app/(admin)/certification-authority-structures/[certificationAuthorityStructureId]/certificateurs-administrateurs/[certificationAuthorityId]/zone-intervention/page.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ const CertificationAuthorityComponent = ({
4949
<CertificationAuthorityStructureBreadcrumb
5050
certificationAuthorityStructureId={certificationAuthorityStructureId}
5151
certificationAuthorityStructureLabel={
52-
certificationAuthority.certificationAuthorityStructure.label
52+
certificationAuthority.certificationAuthorityStructures.find(
53+
(s) => s.id === certificationAuthorityStructureId,
54+
)?.label || "inconnu"
5355
}
5456
certificationAuthorityId={certificationAuthorityId}
5557
certificationAuthoritylabel={certificationAuthority.label}

packages/reva-admin-react/src/app/(admin)/certification-authority-structures/[certificationAuthorityStructureId]/certificateurs-administrateurs/[certificationAuthorityId]/zone-intervention/zone-intervention.hook.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ const getCertificationAuthorityQuery = graphql(`
1414
label
1515
contactFullName
1616
contactEmail
17-
certificationAuthorityStructure {
17+
certificationAuthorityStructures {
18+
id
1819
label
1920
}
2021
departments {

packages/reva-api/modules/certification-authority/certification-authority.graphql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ type CertificationAuthority {
88
regions: [Region!]!
99
certifications: [Certification!]!
1010
certificationAuthorityLocalAccounts: [CertificationAuthorityLocalAccount!]!
11-
certificationAuthorityStructure: CertificationAuthorityStructure!
11+
certificationAuthorityStructures: [CertificationAuthorityStructure!]!
1212
showLocalAccountsContactInfo: Boolean!
1313
}
1414

packages/reva-api/modules/certification-authority/certification-authority.resolvers.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import { updateCertificationAuthorityStructure } from "./features/updateCertific
3939
import { updateCertificationAuthorityStructureCertifications } from "./features/updateCertificationAuthorityStructureCertifications";
4040
import { getCertificationAuthorityLocalAccountByCertificationAuthorityId } from "./features/getCertificationAuthorityLocalAccountByCertificationAuthorityId";
4141
import { getAccountById } from "../account/features/getAccount";
42+
import { getCertificationAuthorityStructuresByCertificationAuthorityId } from "./features/getCertificationAuthorityStructuresByCertificationAuthorityId";
4243

4344
const unsafeResolvers = {
4445
CertificationAuthority: {
@@ -52,11 +53,11 @@ const unsafeResolvers = {
5253
getCertificationsByCertificationAuthorityId({
5354
certificationAuthorityId: parent.id,
5455
}),
55-
certificationAuthorityStructure: ({
56-
oldCertificationAuthorityStructureId,
56+
certificationAuthorityStructures: ({
57+
id: certificationAuthorityId,
5758
}: CertificationAuthority) =>
58-
getCertificationAuthorityStructureById({
59-
certificationAuthorityStructureId: oldCertificationAuthorityStructureId,
59+
getCertificationAuthorityStructuresByCertificationAuthorityId({
60+
certificationAuthorityId,
6061
}),
6162
account: (parent: CertificationAuthority) =>
6263
getAccountByCertificationAuthorityId({

0 commit comments

Comments
 (0)