Skip to content

Commit 6e6a9f6

Browse files
committed
[DEMANDE DEVENIR AIDANT] Prépare le corps avec la signature de la charte pour l'API de création de la demande
1 parent f24f537 commit 6e6a9f6

File tree

9 files changed

+168
-57
lines changed

9 files changed

+168
-57
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,65 @@
11
import { ReponseHATEOAS } from '../../Lien.ts';
22
import { Departement } from '../departement.ts';
33
import { TypeAidant } from '../parcours-aidant/reducteurEtapes.ts';
4-
import { Entreprise } from '../parcours-aidant/choix-type-aidant/ChoixTypeAidant.tsx';
54

65
export type ReponseDemandeInitiee = ReponseHATEOAS & PreRequisDemande;
76
export type PreRequisDemande = {
87
departements: Departement[];
98
};
9+
10+
export enum TypeServiceEntite {
11+
SERVICE_PUBLIC = 'ServicePublic',
12+
SERVICE_ETAT = 'ServiceEtat',
13+
ASSOCIATION = 'Association',
14+
}
15+
export type Entite = {
16+
type: 'ServicePublic' | 'ServiceEtat' | 'Association';
17+
nom?: string;
18+
siret?: string;
19+
};
20+
1021
export type CorpsDemandeDevenirAidant = {
1122
nom: string;
1223
prenom: string;
1324
mail: string;
1425
departement: string;
1526
cguValidees: boolean;
16-
typeAidant?: TypeAidant;
17-
entreprise?: Entreprise;
27+
signatureCharte?: boolean;
28+
entite?: Entite;
1829
};
30+
31+
export const entiteEnFonctionDuTypeAidant = new Map<
32+
TypeAidant,
33+
(nom?: string, siret?: string) => Entite
34+
>([
35+
[
36+
'RepresentantEtat',
37+
(nom, siret) => ({
38+
type: TypeServiceEntite.SERVICE_ETAT,
39+
nom,
40+
siret,
41+
}),
42+
],
43+
[
44+
'AgentPublic',
45+
(nom, siret) => ({
46+
type: TypeServiceEntite.SERVICE_PUBLIC,
47+
nom,
48+
siret,
49+
}),
50+
],
51+
[
52+
'Association',
53+
(nom, siret) => ({
54+
type: TypeServiceEntite.ASSOCIATION,
55+
nom,
56+
siret,
57+
}),
58+
],
59+
[
60+
'FuturAdherent',
61+
() => ({
62+
type: TypeServiceEntite.ASSOCIATION,
63+
}),
64+
],
65+
]);

mon-aide-cyber-ui/src/domaine/gestion-demandes/devenir-aidant/formulaire-devenir-aidant/CapteurFormulaireDevenirAidant.tsx

+1-13
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,9 @@ import { constructeurParametresAPI } from '../../../../fournisseurs/api/Construc
1212
import { useMACAPI } from '../../../../fournisseurs/api/useMACAPI.ts';
1313
import { useNavigate } from 'react-router-dom';
1414
import { TypographieH4 } from '../../../../composants/communs/typographie/TypographieH4/TypographieH4.tsx';
15-
import { TypeAidant } from '../../parcours-aidant/reducteurEtapes.ts';
1615
import { TypographieH5 } from '../../../../composants/communs/typographie/TypographieH5/TypographieH5.tsx';
1716
import Button from '../../../../composants/atomes/Button/Button.tsx';
1817
import { useState } from 'react';
19-
import { Entreprise } from '../../parcours-aidant/Entreprise';
20-
21-
export type CorpsMutationDemandeDevenirAidant = {
22-
nom: string;
23-
prenom: string;
24-
mail: string;
25-
departement: string;
26-
cguValidees: boolean;
27-
typeAidant?: TypeAidant;
28-
entite?: Entreprise;
29-
};
3018

3119
export const CapteurFormulaireDevenirAidant = () => {
3220
const navigationMAC = useNavigationMAC();
@@ -61,7 +49,7 @@ export const CapteurFormulaireDevenirAidant = () => {
6149

6250
const { mutate, error, isError, isSuccess, isPending } = useMutation({
6351
mutationKey: ['demander-a-devenir-aidant'],
64-
mutationFn: (corpsMutation: CorpsMutationDemandeDevenirAidant) => {
52+
mutationFn: (corpsMutation: CorpsDemandeDevenirAidant) => {
6553
const actionSoumettre = new MoteurDeLiens(
6654
navigationMAC.etat
6755
).trouveEtRenvoie('envoyer-demande-devenir-aidant');

mon-aide-cyber-ui/src/domaine/gestion-demandes/parcours-aidant/EcranDemandeDevenirAidant.tsx

+55-26
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ import { MoteurDeLiens } from '../../MoteurDeLiens.ts';
2222
import { useMutation, useQuery } from '@tanstack/react-query';
2323
import {
2424
CorpsDemandeDevenirAidant,
25+
entiteEnFonctionDuTypeAidant,
2526
ReponseDemandeInitiee,
2627
} from '../devenir-aidant/DevenirAidant.ts';
2728
import { constructeurParametresAPI } from '../../../fournisseurs/api/ConstructeurParametresAPI.ts';
2829
import { useMACAPI } from '../../../fournisseurs/api/useMACAPI.ts';
2930
import { useNavigationMAC } from '../../../fournisseurs/hooks.ts';
3031
import { FormulaireDevenirAidant } from '../devenir-aidant/formulaire-devenir-aidant/FormulaireDevenirAidant.tsx';
31-
import { CorpsMutationDemandeDevenirAidant } from '../devenir-aidant/formulaire-devenir-aidant/CapteurFormulaireDevenirAidant.tsx';
3232
import { TypographieH5 } from '../../../composants/communs/typographie/TypographieH5/TypographieH5.tsx';
3333
import { Toast } from '../../../composants/communs/Toasts/Toast.tsx';
3434
import Button from '../../../composants/atomes/Button/Button.tsx';
@@ -74,7 +74,7 @@ export const EcranDemandeDevenirAidant = () => {
7474
isError: mutationEnErreur,
7575
} = useMutation({
7676
mutationKey: ['demander-a-devenir-aidant'],
77-
mutationFn: (corpsMutation: CorpsMutationDemandeDevenirAidant) => {
77+
mutationFn: (corpsMutation: CorpsDemandeDevenirAidant) => {
7878
const actionSoumettre = new MoteurDeLiens(
7979
navigationMAC.etat
8080
).trouveEtRenvoie('envoyer-demande-devenir-aidant');
@@ -84,6 +84,8 @@ export const EcranDemandeDevenirAidant = () => {
8484
'Une erreur est survenue lors de la demande devenir aidant'
8585
);
8686

87+
console.log({ corpsMutation });
88+
return Promise.resolve();
8789
return macAPI.execute<void, void, CorpsDemandeDevenirAidant>(
8890
constructeurParametresAPI<CorpsDemandeDevenirAidant>()
8991
.url(actionSoumettre.url)
@@ -100,6 +102,7 @@ export const EcranDemandeDevenirAidant = () => {
100102

101103
const surClickChoixUtilisation = useCallback((choix: Utilisation) => {
102104
envoie(choixUtilisationFaite(choix));
105+
window.scrollTo({ top: 0 });
103106
}, []);
104107

105108
const surClickChoixTypeAidant = useCallback(
@@ -110,10 +113,21 @@ export const EcranDemandeDevenirAidant = () => {
110113
entite,
111114
})
112115
);
116+
window.scrollTo({ top: 0 });
113117
},
114118
[]
115119
);
116120

121+
const surSignatureCharteAidant = useCallback(() => {
122+
envoie(signeCharteAidant());
123+
window.scrollTo({ top: 0 });
124+
}, []);
125+
126+
const surClickEtapePrecedente = useCallback(() => {
127+
envoie(retourEtapePrecedente());
128+
window.scrollTo({ top: 0 });
129+
}, []);
130+
117131
const etapes: Map<Etape, React.ReactElement> = new Map([
118132
[
119133
'choixUtilisation',
@@ -128,15 +142,15 @@ export const EcranDemandeDevenirAidant = () => {
128142
key="choixTypeAidant"
129143
typeAidant={etatEtapeCourante.demande?.type}
130144
surClick={surClickChoixTypeAidant}
131-
precedent={() => envoie(retourEtapePrecedente())}
145+
precedent={surClickEtapePrecedente}
132146
/>,
133147
],
134148
[
135149
'signatureCharteAidant',
136150
<SignatureCharteAidant
137151
key="signatureCharteAidant"
138-
signeCharteAidant={() => envoie(signeCharteAidant())}
139-
precedent={() => envoie(retourEtapePrecedente())}
152+
signeCharteAidant={surSignatureCharteAidant}
153+
precedent={surClickEtapePrecedente}
140154
/>,
141155
],
142156
['signatureCGUs', <SignatureCGU key="signatureCGUs" />],
@@ -169,33 +183,48 @@ export const EcranDemandeDevenirAidant = () => {
169183
</FormulaireDevenirAidant.AvantPropos>
170184
<FormulaireDevenirAidant.Formulaire
171185
referentielDepartements={referentielDepartements}
172-
surSoumission={(formulaire) =>
186+
surSoumission={(formulaire) => {
187+
const { typeAidant, entite: entiteDuFormulaire } =
188+
etatEtapeCourante.demande!.type;
189+
190+
const entiteCorrespondante =
191+
entiteEnFonctionDuTypeAidant.get(typeAidant);
192+
173193
mutate({
174194
...formulaire,
175-
typeAidant: etatEtapeCourante.demande?.type.typeAidant,
176-
entite: etatEtapeCourante.demande?.type.entite,
177-
})
178-
}
195+
signatureCharte: etatEtapeCourante.demande!.signatureCharte,
196+
...(entiteCorrespondante && {
197+
entite: entiteCorrespondante(
198+
entiteDuFormulaire?.nom,
199+
entiteDuFormulaire?.siret
200+
),
201+
}),
202+
});
203+
}}
179204
devientValide={(estFormulaireValide) => {
180205
setEstValide(estFormulaireValide);
181206
}}
182207
>
183-
<Button
184-
type="submit"
185-
key="envoyer-demande-devenir-aidant"
186-
className="fr-btn bouton-mac bouton-mac-primaire"
187-
onClick={() => envoie(retourEtapePrecedente())}
188-
>
189-
Précédent
190-
</Button>
191-
<Button
192-
type="submit"
193-
key="envoyer-demande-devenir-aidant"
194-
className="fr-btn bouton-mac bouton-mac-primaire"
195-
disabled={!estValide}
196-
>
197-
Envoyer
198-
</Button>
208+
<div className="actions">
209+
<Button
210+
type="submit"
211+
variant="secondary"
212+
key="envoyer-demande-devenir-aidant"
213+
onClick={surClickEtapePrecedente}
214+
>
215+
<i className="fr-icon-arrow-left-line"></i>
216+
<span>Précédent</span>
217+
</Button>
218+
<Button
219+
type="submit"
220+
key="envoyer-demande-devenir-aidant"
221+
className="fr-btn bouton-mac bouton-mac-primaire"
222+
disabled={!estValide}
223+
>
224+
Envoyer
225+
<span className="fr-icon-check-line" aria-hidden="true"></span>
226+
</Button>
227+
</div>
199228
</FormulaireDevenirAidant.Formulaire>
200229

201230
{mutationEnErreur ? (

mon-aide-cyber-ui/src/domaine/gestion-demandes/parcours-aidant/SignatureCharteAidant.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ export const SignatureCharteAidant = ({
7070
precedent();
7171
}}
7272
>
73-
Précédent
73+
<i className="fr-icon-arrow-left-line"></i>
74+
<span>Précédent</span>
7475
</Button>
7576
<Button
7677
disabled={!charteSignee}
@@ -80,7 +81,8 @@ export const SignatureCharteAidant = ({
8081
signeCharteAidant();
8182
}}
8283
>
83-
Suivant
84+
<span>Suivant</span>
85+
<i className="fr-icon-arrow-right-line"></i>
8486
</Button>
8587
</div>
8688
</div>

mon-aide-cyber-ui/src/domaine/gestion-demandes/parcours-aidant/choix-type-aidant/ChoixTypeAidant.tsx

+18-9
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { TypeAidant, TypeAidantEtSonEntite } from '../reducteurEtapes.ts';
55
import { Entreprise } from '../Entreprise';
66
import { SelecteurTypeAidant } from './SelecteurTypeAidant.tsx';
77
import { RechercheEntreprise } from './RechercheEntreprise.tsx';
8+
import { TypographieH5 } from '../../../../composants/communs/typographie/TypographieH5/TypographieH5.tsx';
89

910
export const ChoixTypeAidant = ({
1011
surClick,
@@ -32,13 +33,19 @@ export const ChoixTypeAidant = ({
3233
<div className="fr-container fr-grid-row fr-grid-row--center zone-choix-type-aidant">
3334
<div className="fr-col-md-8 fr-col-sm-12 section">
3435
<div>
35-
<p>Vous souhaitez œuvrer exclusivement pour l’intérêt général</p>
36-
<img
37-
className="text-center"
38-
src={illustrationInteretGeneral}
39-
alt="Illustration d’une personne oeuvrant pour l’intérêt général."
40-
/>
41-
<p>Vous êtes :</p>
36+
<TypographieH5>
37+
Vous souhaitez oeuvrer exclusivement pour l&apos;intérêt général
38+
</TypographieH5>
39+
<div className="text-center">
40+
<img
41+
style={{ width: '342px' }}
42+
src={illustrationInteretGeneral}
43+
alt="Illustration d’une personne oeuvrant pour l’intérêt général."
44+
/>
45+
</div>
46+
<p>
47+
<b>Vous êtes :</b>
48+
</p>
4249
<div className="liste-choix-type-aidants">
4350
<SelecteurTypeAidant
4451
libelle="Un représentant des services de l’État"
@@ -108,7 +115,8 @@ export const ChoixTypeAidant = ({
108115
precedent();
109116
}}
110117
>
111-
Précédent
118+
<i className="fr-icon-arrow-left-line"></i>
119+
<span>Précédent</span>
112120
</Button>
113121
<Button
114122
disabled={!peutValiderEtape}
@@ -121,7 +129,8 @@ export const ChoixTypeAidant = ({
121129
}
122130
}}
123131
>
124-
Je valide ma sélection
132+
<span>Je valide ma sélection</span>
133+
<i className="fr-icon-arrow-right-line"></i>
125134
</Button>
126135
</div>
127136
</div>

mon-aide-cyber-ui/src/domaine/gestion-demandes/parcours-aidant/choix-utilisation/ChoixUtilisation.tsx

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { TypographieH3 } from '../../../../composants/communs/typographie/TypographieH3/TypographieH3.tsx';
22
import illustrationInteretGeneral from '../../../../../public/images/illustration-interet-general.svg';
33
import illustrationCadreProfessionnel from '../../../../../public/images/illustration-cadre-professionnel.svg';
4-
import { useState } from 'react';
4+
import { useEffect, useState } from 'react';
55
import { Choix } from './choix/Choix.tsx';
6+
import useDefilementFluide from '../../../../hooks/useDefilementFluide.ts';
67

78
export type Utilisation = 'InteretGeneral' | 'ActiviteProfessionnelle';
89

@@ -11,8 +12,16 @@ export const ChoixUtilisation = ({
1112
}: {
1213
surClick: (choix: Utilisation) => void;
1314
}) => {
15+
useDefilementFluide();
1416
const [choix, setChoix] = useState<Utilisation | undefined>(undefined);
1517

18+
useEffect(() => {
19+
if (!choix) return;
20+
document
21+
.getElementById('etape-suivante-bouton')
22+
?.scrollIntoView({ behavior: 'smooth' });
23+
}, [choix]);
24+
1625
return (
1726
<>
1827
<div className="choix-utilisation text-center">
@@ -119,6 +128,7 @@ export const ChoixUtilisation = ({
119128

120129
<div className="validation">
121130
<button
131+
id="etape-suivante-bouton"
122132
disabled={!choix}
123133
type="button"
124134
className="fr-btn bouton-mac bouton-mac-primaire"

mon-aide-cyber-ui/src/domaine/gestion-demandes/parcours-aidant/ecran-demande-devenir-aidant.scss

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
grid-row-gap: 1.5rem;
88
grid-column-gap: 1.5rem;
99
justify-content: center;
10+
padding: 0 1rem 0 1rem;
1011

1112
@include a-partir-de(md) {
1213
grid-template-columns: 55% auto;
@@ -199,5 +200,10 @@
199200
padding: 0 8px;
200201
}
201202
}
203+
204+
.actions {
205+
display: flex;
206+
gap: 1rem;
207+
}
202208
}
203209

0 commit comments

Comments
 (0)