Skip to content

Commit aeeb606

Browse files
committed
feat(admin): added a structures vae collectives page for admins
1 parent 2eaf68f commit aeeb606

File tree

3 files changed

+123
-6
lines changed

3 files changed

+123
-6
lines changed
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
"use client";
2+
import { Button } from "@codegouvfr/react-dsfr/Button";
3+
import { useQuery } from "@tanstack/react-query";
4+
import { useSearchParams } from "next/navigation";
5+
6+
import { WhiteCard } from "@/components/card/white-card/WhiteCard";
7+
import { useGraphQlClient } from "@/components/graphql/graphql-client/GraphqlClient";
8+
import { SearchList } from "@/components/search/search-list/SearchList";
9+
10+
import { graphql } from "@/graphql/generated";
11+
12+
const getVaeCollectives = graphql(`
13+
query getVaeCollectivesForStructuresVaeCollectivesPage(
14+
$offset: Int
15+
$searchFilter: String
16+
) {
17+
vaeCollective_commanditaireVaeCollectives(
18+
limit: 10
19+
offset: $offset
20+
searchFilter: $searchFilter
21+
) {
22+
rows {
23+
id
24+
raisonSociale
25+
createdAt
26+
}
27+
info {
28+
totalRows
29+
totalPages
30+
currentPage
31+
}
32+
}
33+
}
34+
`);
35+
36+
const RECORDS_PER_PAGE = 10;
37+
const MaisonMereAapListPage = () => {
38+
const { graphqlClient } = useGraphQlClient();
39+
40+
const searchParams = useSearchParams();
41+
const page = searchParams.get("page");
42+
const currentPage = page ? Number.parseInt(page) : 1;
43+
const searchFilter = searchParams.get("search") || "";
44+
45+
const { data, status } = useQuery({
46+
queryKey: ["getVaeCollectives", searchFilter, currentPage],
47+
queryFn: () =>
48+
graphqlClient.request(getVaeCollectives, {
49+
offset: (currentPage - 1) * RECORDS_PER_PAGE,
50+
searchFilter,
51+
}),
52+
});
53+
54+
if (status === "error") {
55+
return (
56+
<div>
57+
Une erreur est survenue lors du chargement des structures de vae
58+
collectives.
59+
</div>
60+
);
61+
}
62+
63+
if (status === "pending") {
64+
return <div className="min-h-[720px]"></div>;
65+
}
66+
67+
return (
68+
<div className="flex flex-col">
69+
<h1>Structures de VAE collectives</h1>
70+
<p className="text-xl leading-8 mb-12">
71+
En tant qu'administrateur, vous avez la possibilité de visualiser
72+
l’intégralité des structures de VAE collectives.
73+
</p>
74+
{status === "success" && (
75+
<SearchList
76+
searchBarProps={{
77+
lifted: true,
78+
title: "Recherchez par raison sociale",
79+
}}
80+
searchFilter={searchFilter}
81+
searchResultsPage={data.vaeCollective_commanditaireVaeCollectives}
82+
>
83+
{(commanditaire) =>
84+
commanditaire ? (
85+
<WhiteCard key={commanditaire.id}>
86+
<h6 className="mb-3">{commanditaire.raisonSociale}</h6>
87+
<Button
88+
className="place-self-end"
89+
linkProps={{
90+
href: `/vae-collective/commanditaires/${commanditaire.id}/cohortes`,
91+
}}
92+
>
93+
Voir plus
94+
</Button>
95+
</WhiteCard>
96+
) : null
97+
}
98+
</SearchList>
99+
)}
100+
</div>
101+
);
102+
};
103+
104+
export default MaisonMereAapListPage;

packages/reva-admin-react/src/components/header/Header.tsx

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const PATHS = {
4343
FEASIBILITIES: "/candidacies/feasibilities",
4444
STATISTIQUES: "/dashboard",
4545
VAE_COLLECTIVES: "/vae-collectives",
46+
STRUCTURES_VAE_COLLECTIVES: "/structures-vae-collectives",
4647
} as const;
4748

4849
const LABELS = {
@@ -55,6 +56,7 @@ const LABELS = {
5556
GESTION_CERTIFICATIONS: "Gestion des certifications",
5657
STRUCTURES_ACCOMPAGNATRICES: "Structures accompagnatrices",
5758
STRUCTURES_CERTIFICATRICES: "Structures certificatrices",
59+
STRUCTURES_VAE_COLLECTIVES: "Structures VAE collectives",
5860
STATISTIQUES: "Statistiques",
5961
VAE_COLLECTIVES: "VAE collectives",
6062
} as const;
@@ -105,7 +107,7 @@ const getNavigationTabs = ({
105107
isCertificationRegistryManager,
106108
isAdminCertificationAuthority,
107109
metabaseDashboardIframeUrl,
108-
showAAPVaeCollectivesTab,
110+
showAAPVaeCollectivesTabsAndMenus,
109111
}: {
110112
currentPathname: string;
111113
isAdmin: boolean;
@@ -115,7 +117,7 @@ const getNavigationTabs = ({
115117
isCertificationRegistryManager: boolean;
116118
isAdminCertificationAuthority: boolean;
117119
metabaseDashboardIframeUrl?: string | null;
118-
showAAPVaeCollectivesTab: boolean;
120+
showAAPVaeCollectivesTabsAndMenus: boolean;
119121
}) => {
120122
const adminTabs = [
121123
createTab({
@@ -153,6 +155,17 @@ const getNavigationTabs = ({
153155
PATHS.CERTIFICATION_AUTHORITY_STRUCTURES,
154156
),
155157
}),
158+
...(showAAPVaeCollectivesTabsAndMenus
159+
? [
160+
createTab({
161+
text: LABELS.STRUCTURES_VAE_COLLECTIVES,
162+
href: PATHS.STRUCTURES_VAE_COLLECTIVES,
163+
isActive: currentPathname.startsWith(
164+
PATHS.STRUCTURES_VAE_COLLECTIVES,
165+
),
166+
}),
167+
]
168+
: []),
156169
],
157170
},
158171
createTab({
@@ -168,7 +181,7 @@ const getNavigationTabs = ({
168181
href: PATHS.CANDIDACIES,
169182
isActive: isAAPCandidaciesPath(currentPathname),
170183
}),
171-
...(showAAPVaeCollectivesTab
184+
...(showAAPVaeCollectivesTabsAndMenus
172185
? [
173186
createTab({
174187
text: LABELS.VAE_COLLECTIVES,
@@ -284,7 +297,7 @@ export const Header = () => {
284297
enabled: isVaeCollectiveFeatureActive && isOrganism && !isAdmin,
285298
});
286299

287-
const showAAPVaeCollectivesTab =
300+
const showAAPVaeCollectivesTabsAndMenus =
288301
isVaeCollectiveFeatureActive &&
289302
isOrganism &&
290303
!isAdmin &&
@@ -300,7 +313,7 @@ export const Header = () => {
300313
isCertificationRegistryManager,
301314
isAdminCertificationAuthority,
302315
metabaseDashboardIframeUrl,
303-
showAAPVaeCollectivesTab,
316+
showAAPVaeCollectivesTabsAndMenus,
304317
});
305318

306319
return (

packages/reva-api/modules/vae-collective/vae-collective.resolvers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ const unsafeResolvers = {
126126
offset,
127127
limit,
128128
searchFilter,
129-
}: { offset: number; limit: number; searchFilter: string },
129+
}: { offset?: number; limit?: number; searchFilter?: string },
130130
) => getCommanditaireVaeCollectives({ offset, limit, searchFilter }),
131131
},
132132
Mutation: {

0 commit comments

Comments
 (0)