-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[REMANIEMENT] Change la nomenclature des composants faisant le lien e…
…ntre un formulaire et son action vers un endpoint
- Loading branch information
Showing
6 changed files
with
82 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
.../mot-de-passe-oublie/formulaire-mot-de-passe-oublie/CapteurFormulaireMotDePasseOublie.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { useNavigationMAC } from '../../../../fournisseurs/hooks.ts'; | ||
import { useMACAPI } from '../../../../fournisseurs/api/useMACAPI.ts'; | ||
import { useRecupereContexteNavigation } from '../../../../hooks/useRecupereContexteNavigation.ts'; | ||
import { useMutation } from '@tanstack/react-query'; | ||
import { MoteurDeLiens } from '../../../MoteurDeLiens.ts'; | ||
import { constructeurParametresAPI } from '../../../../fournisseurs/api/ConstructeurParametresAPI.ts'; | ||
import { Toast } from '../../../../composants/communs/Toasts/Toast.tsx'; | ||
import { FormulaireMotDePasseOublie } from './FormulaireMotDePasseOublie.tsx'; | ||
|
||
export type CorpsMotDePasseOublie = { | ||
email: string; | ||
}; | ||
|
||
export const CapteurFormulaireMotDePasseOublie = () => { | ||
const navigationMAC = useNavigationMAC(); | ||
const macAPI = useMACAPI(); | ||
|
||
useRecupereContexteNavigation( | ||
'reinitialisation-mot-de-passe:reinitialisation-mot-de-passe' | ||
); | ||
|
||
const { mutate, isSuccess, error, isError, isPending, variables } = | ||
useMutation({ | ||
mutationKey: ['reinitialisation-mot-de-passe'], | ||
mutationFn: (email: string) => { | ||
if (!email) Promise.reject('Aucun email renseigné !'); | ||
|
||
const actionSoumettre = new MoteurDeLiens( | ||
navigationMAC.etat | ||
).trouveEtRenvoie('reinitialisation-mot-de-passe'); | ||
|
||
if (!actionSoumettre) | ||
throw new Error( | ||
'Une erreur est survenue lors de la demande de réinitialisation de mot de passe' | ||
); | ||
|
||
return macAPI.execute<void, void, CorpsMotDePasseOublie>( | ||
constructeurParametresAPI<CorpsMotDePasseOublie>() | ||
.url(actionSoumettre.url) | ||
.methode(actionSoumettre.methode!) | ||
.corps({ | ||
email: email, | ||
}) | ||
.construis(), | ||
(corps) => corps | ||
); | ||
}, | ||
}); | ||
|
||
if (isPending) | ||
return ( | ||
<Toast | ||
className="w-100" | ||
type="INFO" | ||
message="Traitement de votre demande en cours" | ||
/> | ||
); | ||
|
||
if (isError) | ||
return <Toast className="w-100" type="ERREUR" message={error.message} />; | ||
|
||
if (isSuccess) | ||
return ( | ||
<div className="mac-callout mac-callout-information"> | ||
<i className="mac-icone-information" /> | ||
<div> | ||
Si le compte existe, un e-mail de redéfinition de mot de passe sera | ||
envoyé à : <b>{variables}</b>. Veuillez vérifier votre boîte de | ||
réception. | ||
</div> | ||
</div> | ||
); | ||
|
||
return <FormulaireMotDePasseOublie surSoumission={mutate} />; | ||
}; |
74 changes: 0 additions & 74 deletions
74
...vitrine/mot-de-passe-oublie/formulaire-mot-de-passe-oublie/FormulaireMotDePasseOublie.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters