Skip to content

Commit 8a0a35c

Browse files
authored
Merge branch 'feat/1079-gestion-renouvellement-agrement' into feat/1092-bo-liste-agrements
2 parents 51b378d + a3e4654 commit 8a0a35c

File tree

11 files changed

+192
-156
lines changed

11 files changed

+192
-156
lines changed

.talismanrc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ fileignoreconfig:
278278
- filename: packages/frontend-usagers/src/components/utils/TableFull.vue
279279
checksum: 05743cc5c3dfd946e8ee41cb11571b1e505bbdb5260e9c59a53e4ca16cb11f08
280280
- filename: packages/frontend-usagers/src/pages/agrement/[[agrementId]].vue
281-
checksum: 9f1b4a0e00392a84b23746ab66cad677bddc49b1f9999454b123cb7111c204c3
281+
checksum: 8ab087483ddfb8b24d68de5ba5dcc292f06ffedcf6b5f89f16184f5906ff728b
282282
- filename: packages/frontend-usagers/src/pages/connexion/enregistrement.vue
283283
checksum: dd393d7c31566dfa3864bb9a63fe98f9bf040cc8321e8cad0f74e8634e8365f8
284284
- filename: packages/frontend-usagers/src/pages/connexion/index.vue
@@ -315,6 +315,8 @@ fileignoreconfig:
315315
checksum: 7b52636c4c49bf85a592f649f8fbf653e0203b390f4f9d220fe3ae4da06422a7
316316
- filename: packages/shared-bridge/src/dto/paginationQueryDto.ts
317317
checksum: 171d7cf0f68b404e3b648fcb9d7b3e36891da049bad2ede67007d0c03661145a
318+
- filename: packages/shared-bridge/src/constantes/file.ts
319+
checksum: dded09b86eeb4c664e493ff12b023d20914b18ac5c9a98ac7e60235daec3927d
318320
- filename: packages/shared-bridge/src/utils/request.ts
319321
checksum: c29fc1527b710e177395fabd040b7e3cdd44b429b21d504ba6f192faf1cd861a
320322
- filename: packages/shared-ui/src/components/DsfrMultiselectV2.vue
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<template>
2+
<!-- TODO Filtrer ou mettre l'objet correspondant aux documents des DREETS-->
3+
<div
4+
v-if="
5+
props.initAgrement.dreetsFiles &&
6+
props.initAgrement.dreetsFiles.length > 0
7+
"
8+
>
9+
<TableFull
10+
title="Documents de la DREETS"
11+
:headers="headers"
12+
:data="props.initAgrement.dreetsFiles"
13+
/>
14+
</div>
15+
<div
16+
v-if="
17+
props.initAgrement.agrementFiles &&
18+
props.initAgrement.agrementFiles.length > 0
19+
"
20+
>
21+
<TableFull
22+
title="Documents de l'OVA"
23+
:headers="headers"
24+
:data="props.initAgrement.agrementFiles"
25+
/>
26+
</div>
27+
</template>
28+
29+
<script setup lang="ts">
30+
import { TableFull } from "@vao/shared-ui";
31+
import {
32+
type AgrementFilesDto,
33+
type DocumentDto,
34+
formatFRDateTime,
35+
getFileCategoryLabel,
36+
} from "@vao/shared-bridge";
37+
38+
const config = useRuntimeConfig();
39+
const NuxtLink = resolveComponent("NuxtLink");
40+
41+
const props = defineProps({
42+
initAgrement: { type: Object, required: true },
43+
});
44+
45+
const headers = [
46+
{
47+
column: "name",
48+
sorter: "name",
49+
text: "Nom du fichier",
50+
headerAttrs: {
51+
class: "suivi",
52+
},
53+
},
54+
{
55+
column: "category",
56+
sorter: "category",
57+
text: "Type de fichier",
58+
format: (item: AgrementFilesDto) => getFileCategoryLabel(item.category!),
59+
headerAttrs: {
60+
class: "suivi",
61+
},
62+
},
63+
{
64+
column: "createdAt",
65+
sorter: "createdAt",
66+
format: (item: DocumentDto) => formatFRDateTime(item.createdAt!),
67+
text: "Date de dépose",
68+
headerAttrs: {
69+
class: "suivi",
70+
},
71+
},
72+
{
73+
text: "téléchargement",
74+
component: (file: DocumentDto) => {
75+
return {
76+
component: NuxtLink,
77+
to: `${config.public.backendUrl}/documents/${file.uuid}`,
78+
class: "fr-icon-file-download-fill",
79+
};
80+
},
81+
},
82+
];
83+
</script>

packages/frontend-usagers/src/pages/agrement/[[agrementId]].vue

Lines changed: 14 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,8 @@
107107
</div>
108108
</template>
109109
<script setup lang="ts">
110-
import {
111-
FILE_CATEGORY,
112-
type AgrementDto,
113-
type FileKey,
114-
} from "@vao/shared-bridge";
110+
import type { FILE_CATEGORY, AgrementDto, FileKey } from "@vao/shared-bridge";
111+
import { FILE_CATEGORY_CONFIG } from "@vao/shared-bridge";
115112
import { useToaster } from "@vao/shared-ui";
116113
117114
const route = useRoute();
@@ -135,154 +132,25 @@ async function updateOrCreate(formValues: AgrementFormValues) {
135132
const updatedData: AgrementFormValues = { ...formValues };
136133
try {
137134
updatedData.agrementFiles = [];
138-
const fileMappings: {
139-
key: FileKey;
140-
multiple: boolean;
141-
category: FILE_CATEGORY;
142-
}[] = [
143-
{
144-
key: "filesMotivation",
145-
multiple: true,
146-
category: FILE_CATEGORY.MOTIVATION,
147-
},
148-
{
149-
key: "fileProcesVerbal",
150-
multiple: false,
151-
category: FILE_CATEGORY.PROCVERBAL,
152-
},
153-
{
154-
key: "fileImmatriculation",
155-
multiple: false,
156-
category: FILE_CATEGORY.IMMATRICUL,
157-
},
158-
{
159-
key: "fileAttestationsRespCivile",
160-
multiple: false,
161-
category: FILE_CATEGORY.ASSURRESP,
162-
},
163-
{
164-
key: "fileAttestationsRapatriement",
165-
multiple: false,
166-
category: FILE_CATEGORY.ASSURRAPAT,
167-
},
168-
{
169-
key: "filesChangeEvol",
170-
multiple: true,
171-
category: FILE_CATEGORY.CHANGEEVOL,
172-
},
173-
{
174-
key: "filesBilanQualit",
175-
multiple: true,
176-
category: FILE_CATEGORY.BILANQUALIT,
177-
},
178-
{
179-
key: "filesBilanFinancier",
180-
multiple: true,
181-
category: FILE_CATEGORY.BILANFINANC,
182-
},
183-
{
184-
key: "filesAgrementSejour",
185-
multiple: true,
186-
category: FILE_CATEGORY.SEJOUR,
187-
},
188-
{
189-
key: "filesAccompResp",
190-
multiple: true,
191-
category: FILE_CATEGORY.ACCOMPRESP,
192-
},
193-
{
194-
key: "filesSuiviMed",
195-
multiple: true,
196-
category: FILE_CATEGORY.SUIVIMED,
197-
},
198-
{
199-
key: "filesBilanQualitPerception",
200-
multiple: true,
201-
category: FILE_CATEGORY.BILANQUALITPERCEPTION,
202-
},
203-
{
204-
key: "filesBilanQualitPerspectives",
205-
multiple: true,
206-
category: FILE_CATEGORY.BILANQUALITPERSPECTIVE,
207-
},
208-
{
209-
key: "filesBilanQualitElementsMarquants",
210-
multiple: true,
211-
category: FILE_CATEGORY.BILANQUALITELEMARQ,
212-
},
213-
{
214-
key: "filesBilanQualitComplementaires",
215-
multiple: true,
216-
category: FILE_CATEGORY.BILANQUALITCOMPLEMENTAIRES,
217-
},
218-
{
219-
key: "filesBilanFinancierQuatreAnnees",
220-
multiple: true,
221-
category: FILE_CATEGORY.BILANFINANCIERQUATREANNEES,
222-
},
223-
{
224-
key: "filesProjetsSejoursPrevus",
225-
multiple: true,
226-
category: FILE_CATEGORY.PROJETSSEJOURSPREVUS,
227-
},
228-
{
229-
key: "filesProjetsSejoursCompetencesExperience",
230-
multiple: true,
231-
category: FILE_CATEGORY.PROJETSSEJOURSCOMPETENCESEXPERIENCE,
232-
},
233-
{
234-
key: "filesProjetsSejoursMesures",
235-
multiple: true,
236-
category: FILE_CATEGORY.PROJETSSEJOURSMESURES,
237-
},
238-
{
239-
key: "filesProjetsSejoursComplementaires",
240-
multiple: true,
241-
category: FILE_CATEGORY.PROJETSSEJOURSCOMPLEMENTAIRES,
242-
},
243-
{
244-
key: "fileProjetsSejoursCasier",
245-
multiple: false,
246-
category: FILE_CATEGORY.PROJETSSEJOURSCASIER,
247-
},
248-
{
249-
key: "filesProjetsSejoursOrgaTransports",
250-
multiple: true,
251-
category: FILE_CATEGORY.PROJETSSEJOURSORGATRANSPORT,
252-
},
253-
{
254-
key: "filesProjetsSejoursSuiviMed",
255-
multiple: true,
256-
category: FILE_CATEGORY.PROJETSSEJOURSSUIVIMED,
257-
},
258-
{
259-
key: "filesProjetsSejoursProtocoleReorientation",
260-
multiple: true,
261-
category: FILE_CATEGORY.PROJSEJPROTCOREORIENT,
262-
},
263-
{
264-
key: "filesProjetsSejoursProtocoleRapatriement",
265-
multiple: true,
266-
category: FILE_CATEGORY.PROJSSEJOURSPROTCOLERAPATR,
267-
},
268-
{
269-
key: "filesProjSejoursBudgetPersonnes",
270-
multiple: true,
271-
category: FILE_CATEGORY.PROJSEJOURSBUDGETPERSONNES,
272-
},
273-
];
274135
275-
for (const { key, multiple, category } of fileMappings) {
276-
const value = updatedData[key as FileKey];
136+
for (const category of Object.keys(
137+
FILE_CATEGORY_CONFIG,
138+
) as (keyof typeof FILE_CATEGORY_CONFIG)[]) {
139+
const { fileKey, multiple } = FILE_CATEGORY_CONFIG[category];
140+
const value = updatedData[fileKey];
277141
278142
if (!value) continue;
143+
279144
if (multiple) {
280-
const docs = await createDocuments({ documents: value, category });
145+
const docs = await createDocuments({
146+
documents: value,
147+
category: category as FILE_CATEGORY,
148+
});
281149
updatedData.agrementFiles.push(...docs);
282150
} else {
283151
const doc = await createDocument({
284152
document: value,
285-
category,
153+
category: category as FILE_CATEGORY,
286154
});
287155
if (doc) updatedData.agrementFiles.push(doc);
288156
}
@@ -351,7 +219,7 @@ async function createDocument({
351219
}) {
352220
if (document && Object.keys(document?.uuid ?? {}).length === 0) {
353221
try {
354-
const uuid = await documentStore.postDocument(document);
222+
const uuid = await documentStore.postDocument({ document, category });
355223
toaster.info({
356224
titleTag: "h2",
357225
description: `Fichier ${document.name} déposé`,

packages/frontend-usagers/src/pages/mon-agrement/index.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444
:selected="selectedTabIndex === 1"
4545
:asc="asc"
4646
>
47+
<AgrementDocuments
48+
:init-agrement="agrementStore.agrementCourant ?? {}"
49+
></AgrementDocuments>
4750
</DsfrTabContent>
4851
<DsfrTabContent
4952
panel-id="agrement-content-2"

packages/frontend-usagers/src/services/documentService.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,19 @@ const DocumentService = {
55
postDocument: async ({
66
file,
77
category,
8-
}: { file: File, category: DocumentUsagersRoutes["PostDocument"]["body"]["category"] }) => {
9-
8+
}: {
9+
file: File;
10+
category: DocumentUsagersRoutes["PostDocument"]["body"]["category"];
11+
}) => {
1012
const { uuid } = await buildRequestFile<
1113
DocumentUsagersRoutes["PostDocument"]
1214
>({
1315
path: "/documents/",
1416
method: "POST",
1517
body: {
16-
category
18+
category,
1719
},
18-
file
20+
file,
1921
})();
2022
return uuid;
2123
},

packages/frontend-usagers/src/stores/document.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ export const useDocumentStore = defineStore("document", {
1717
if (!document) {
1818
throw new Error("Un document est requis pour le chargement");
1919
}
20-
const uuid = await DocumentService.postDocument({ file: document, category });
20+
const uuid = await DocumentService.postDocument({
21+
file: document,
22+
category,
23+
});
2124
return uuid;
2225
},
2326
},

packages/frontend-usagers/src/utils/fetchBackend.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const $fetchBackend = <T = any>(
99
option: FetchBackendOptions = {},
1010
): Promise<T> => {
1111
const config = useRuntimeConfig();
12-
12+
1313
return $fetch(url, {
1414
baseURL: config.public.backendUrl,
1515
...option,
@@ -82,9 +82,9 @@ export function buildRequestFile<Route extends BasicRoute>({
8282
return async () =>
8383
$fetchBackend(url, {
8484
...OPTIONS_DEFAULT,
85-
headers: {},
8685
method: "POST",
87-
body,
86+
body: formData,
87+
headers: {},
8888
});
8989
default:
9090
throw new Error("Method not supported");

0 commit comments

Comments
 (0)