From 6eeb0e4c4c219e2cdaffa49709a84083f99a5377 Mon Sep 17 00:00:00 2001 From: Hubert Moncenis Date: Thu, 22 Feb 2024 07:07:56 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Accorder=20/=20Rejeter=20/=20Annule?= =?UTF-8?q?r=20un=20d=C3=A9pot=20de=20Gfs=20-=20Storybook=20(#1605)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ✨ Accorder / Rejeter Gfs * 🚚 Accorder -> valider gfs * ♻️ Reorganize gf page architecture + add annuler action * 🔥 Delete details GF (will be remarke in other PR) * 🎨 Utiliser le terme "dépôt" --- .../applications/ssr/.storybook/preview.tsx | 4 +- ...TypeGarantiesFinanci\303\250resSelect.tsx" | 18 +- ...\264tGarantiesFinanci\303\250res.page.tsx" | 187 +++++++++++++ ...4tGarantiesFinanci\303\250res.stories.tsx" | 61 +++++ ...p\303\264tGarantiesFinanci\303\250res.tsx" | 41 +++ ...264tGarantiesFinanci\303\250res.action.ts" | 23 ++ ...264tGarantiesFinanci\303\250res.action.ts" | 0 ...p\303\264tGarantiesFinanci\303\250res.tsx" | 41 +++ ...264tGarantiesFinanci\303\250res.action.ts" | 23 ++ ...p\303\264tGarantiesFinanci\303\250res.tsx" | 41 +++ ...264tGarantiesFinanci\303\250res.action.ts" | 23 ++ ...ettreGarantiesFinanci\303\250res.page.tsx" | 6 +- ...reGarantiesFinanci\303\250res.stories.tsx" | 2 +- ...ttreGarantiesFinanci\303\250res.action.ts" | 0 ...tailsGarantiesFinanci\303\250res.page.tsx" | 248 ------------------ ...lsGarantiesFinanci\303\250res.stories.tsx" | 62 ----- 16 files changed, 463 insertions(+), 317 deletions(-) create mode 100644 "packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/modifier/ModifierD\303\251p\303\264tGarantiesFinanci\303\250res.page.tsx" create mode 100644 "packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/modifier/ModifierD\303\251p\303\264tGarantiesFinanci\303\250res.stories.tsx" create mode 100644 "packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/modifier/annuler/AnnulerD\303\251p\303\264tGarantiesFinanci\303\250res.tsx" create mode 100644 "packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/modifier/annuler/annulerD\303\251p\303\264tGarantiesFinanci\303\250res.action.ts" rename "packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251tails/modifierGarantiesFinanci\303\250res.action.ts" => "packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/modifier/modifierD\303\251p\303\264tGarantiesFinanci\303\250res.action.ts" (100%) create mode 100644 "packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/modifier/rejeter/RejeterD\303\251p\303\264tGarantiesFinanci\303\250res.tsx" create mode 100644 "packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/modifier/rejeter/rejeterD\303\251p\303\264tGarantiesFinanci\303\250res.action.ts" create mode 100644 "packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/modifier/valider/ValiderD\303\251p\303\264tGarantiesFinanci\303\250res.tsx" create mode 100644 "packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/modifier/valider/validerD\303\251p\303\264tGarantiesFinanci\303\250res.action.ts" rename "packages/applications/ssr/src/components/pages/garanties-financi\303\250res/soumettre/SoumettreGarantiesFinanci\303\250res.page.tsx" => "packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/soumettre/SoumettreGarantiesFinanci\303\250res.page.tsx" (94%) rename "packages/applications/ssr/src/components/pages/garanties-financi\303\250res/soumettre/SoumettreGarantiesFinanci\303\250res.stories.tsx" => "packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/soumettre/SoumettreGarantiesFinanci\303\250res.stories.tsx" (91%) rename "packages/applications/ssr/src/components/pages/garanties-financi\303\250res/soumettre/soumettreGarantiesFinanci\303\250res.action.ts" => "packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/soumettre/soumettreGarantiesFinanci\303\250res.action.ts" (100%) delete mode 100644 "packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251tails/D\303\251tailsGarantiesFinanci\303\250res.page.tsx" delete mode 100644 "packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251tails/D\303\251tailsGarantiesFinanci\303\250res.stories.tsx" diff --git a/packages/applications/ssr/.storybook/preview.tsx b/packages/applications/ssr/.storybook/preview.tsx index b5b7680ac7..5b52dd0c2e 100644 --- a/packages/applications/ssr/.storybook/preview.tsx +++ b/packages/applications/ssr/.storybook/preview.tsx @@ -7,8 +7,8 @@ import { createMuiDsfrThemeProvider } from '@codegouvfr/react-dsfr/mui'; import { StartDsfr } from '../src/app/StartDsfr'; -import '../public/dsfr/dsfr.min.css'; -import '../public/dsfr/utility/icons/icons.min.css'; +import './static/dsfr/dsfr.min.css'; +import './static/dsfr/utility/icons/icons.min.css'; import '../src/app/global.css'; export const decorators = [ diff --git "a/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/TypeGarantiesFinanci\303\250resSelect.tsx" "b/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/TypeGarantiesFinanci\303\250resSelect.tsx" index 276418b5ba..0e610c2258 100644 --- "a/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/TypeGarantiesFinanci\303\250resSelect.tsx" +++ "b/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/TypeGarantiesFinanci\303\250resSelect.tsx" @@ -4,7 +4,23 @@ import Input from '@codegouvfr/react-dsfr/Input'; import { formatDateForInput } from '@/utils/formatDateForInput'; -type TypeGarantiesFinancières = '6 mois après achèvement' | 'consignation' | 'avec date d’échéance'; +export type TypeGarantiesFinancières = + | '6 mois après achèvement' + | 'consignation' + | 'avec date d’échéance'; + +export type GarantiesFinancières = { + dateConsitution: string; + attestationConstitution: string; +} & ( + | { + type: Exclude; + } + | { + type: Extract; + dateÉchéance: string; + } +); export type TypeGarantiesFinancièresSelectProps = { id: string; diff --git "a/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/modifier/ModifierD\303\251p\303\264tGarantiesFinanci\303\250res.page.tsx" "b/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/modifier/ModifierD\303\251p\303\264tGarantiesFinanci\303\250res.page.tsx" new file mode 100644 index 0000000000..63b5895679 --- /dev/null +++ "b/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/modifier/ModifierD\303\251p\303\264tGarantiesFinanci\303\250res.page.tsx" @@ -0,0 +1,187 @@ +import { FC, useState } from 'react'; +import { useRouter } from 'next/navigation'; +import Input from '@codegouvfr/react-dsfr/Input'; +import Button from '@codegouvfr/react-dsfr/Button'; +import { Upload } from '@codegouvfr/react-dsfr/Upload'; +import Link from 'next/link'; +import Alert from '@codegouvfr/react-dsfr/Alert'; + +import { Routes } from '@potentiel-libraries/routes'; + +import { ColumnPageTemplate } from '@/components/templates/ColumnPage.template'; +import { ProjetBanner, ProjetBannerProps } from '@/components/molecules/projet/ProjetBanner'; +import { Form } from '@/components/atoms/form/Form'; +import { formatDateForInput } from '@/utils/formatDateForInput'; +import { SubmitButton } from '@/components/atoms/form/SubmitButton'; + +import { TitrePageGarantiesFinancières } from '../../TitrePageGarantiesFinancieres'; +import { + GarantiesFinancières, + TypeGarantiesFinancièresSelect, + TypeGarantiesFinancièresSelectProps, +} from '../../TypeGarantiesFinancièresSelect'; + +import { ValiderDépôtGarantiesFinancières } from './valider/ValiderDépôtGarantiesFinancières'; +import { RejeterDépôtGarantiesFinancières } from './rejeter/RejeterDépôtGarantiesFinancières'; +import { modifierGarantiesFinancièresAction } from './modifierDépôtGarantiesFinancières.action'; +import { AnnulerDépôtGarantiesFinancières } from './annuler/AnnulerDépôtGarantiesFinancières'; + +type AvailableActions = Array<'valider' | 'rejeter' | 'annuler'>; + +export type ModifierDépôtGarantiesFinancièresProps = { + projet: ProjetBannerProps; + garantiesFinancieres: GarantiesFinancières; + showWarning?: true; + actions: AvailableActions; +}; + +export const ModifierDépôtGarantiesFinancières: FC = ({ + projet, + garantiesFinancieres, + showWarning, + actions, +}) => { + const router = useRouter(); + const [validationErrors, setValidationErrors] = useState>([]); + + return ( + } + heading={} + leftColumn={{ + children: ( + <> +
+ router.push(Routes.GarantiesFinancières.détail(projet.identifiantProjet)) + } + onValidationError={(validationErrors) => setValidationErrors(validationErrors)} + heading="Modifier des garanties financières" + > + {showWarning && ( + + Vous pouvez modifier cette soumission de garanties financières jusqu'à sa + validation par la DREAL concernée. + + } + /> + )} + + + + + + + Attestation de constitution{' '} + {garantiesFinancieres.attestationConstitution && ( + <> +
+ + Pour que la modification puisse fonctionner, merci de joindre un nouveau + fichier ou{' '} + + celui préalablement transmis + + + + )} + + } + hint="Format accepté : pdf" + nativeInputProps={{ + name: 'attestationConstitution', + required: true, + 'aria-required': true, + accept: '.pdf', + }} + state={validationErrors.includes('attestationConstitution') ? 'error' : 'default'} + stateRelatedMessage="Attestation de consitution des garantières financières obligatoire" + /> + +
+ + Soumettre +
+ + + ), + }} + rightColumn={{ + className: 'flex flex-col w-full md:w-1/4 gap-4', + children: mapToActionComponents({ + actions, + identifiantProjet: projet.identifiantProjet, + }), + }} + /> + ); +}; + +type MapToActionsComponentsProps = { + actions: AvailableActions; + identifiantProjet: string; +}; +const mapToActionComponents = ({ actions, identifiantProjet }: MapToActionsComponentsProps) => { + return actions.length ? ( + <> + {actions.includes('valider') && ( + + )} + {actions.includes('rejeter') && ( + + )} + {actions.includes('annuler') && ( + + )} + + ) : null; +}; diff --git "a/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/modifier/ModifierD\303\251p\303\264tGarantiesFinanci\303\250res.stories.tsx" "b/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/modifier/ModifierD\303\251p\303\264tGarantiesFinanci\303\250res.stories.tsx" new file mode 100644 index 0000000000..75465ebb81 --- /dev/null +++ "b/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/modifier/ModifierD\303\251p\303\264tGarantiesFinanci\303\250res.stories.tsx" @@ -0,0 +1,61 @@ +import type { Meta, StoryObj } from '@storybook/react'; + +import { ProjetBannerProps } from '@/components/molecules/projet/ProjetBanner'; + +import { + ModifierDépôtGarantiesFinancières, + ModifierDépôtGarantiesFinancièresProps, +} from './ModifierDépôtGarantiesFinancières.page'; + +const meta = { + title: 'Pages/Garanties-financières/Dépôt/Modifier', + component: ModifierDépôtGarantiesFinancières, + parameters: {}, + tags: ['autodocs'], + argTypes: {}, +} satisfies Meta; + +export default meta; +type Story = StoryObj; + +const projet: ProjetBannerProps = { + identifiantProjet: 'identifiantProjet#1', + appelOffre: 'Appel offre', + période: 'Période', + famille: 'Famille', + nom: 'Nom du projet', + dateDésignation: '2021-10-23', + localité: { + codePostal: 'XXXXX', + commune: 'Commune', + département: 'Département', + région: 'Région', + }, + statut: 'classé', +}; + +export const EnTantQueDreal: Story = { + args: { + projet, + garantiesFinancieres: { + type: 'consignation', + dateConsitution: '2021-10-23', + attestationConstitution: 'path/to/attestationConstitution', + }, + actions: ['valider', 'rejeter'], + }, +}; + +export const EnTantQuePorteur: Story = { + args: { + projet, + garantiesFinancieres: { + type: 'avec date d’échéance', + dateÉchéance: '2021-10-23', + dateConsitution: '2021-10-23', + attestationConstitution: 'path/to/attestationConstitution', + }, + actions: ['annuler'], + showWarning: true, + }, +}; diff --git "a/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/modifier/annuler/AnnulerD\303\251p\303\264tGarantiesFinanci\303\250res.tsx" "b/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/modifier/annuler/AnnulerD\303\251p\303\264tGarantiesFinanci\303\250res.tsx" new file mode 100644 index 0000000000..1461374dc1 --- /dev/null +++ "b/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/modifier/annuler/AnnulerD\303\251p\303\264tGarantiesFinanci\303\250res.tsx" @@ -0,0 +1,41 @@ +'use client'; + +import { useRouter } from 'next/navigation'; + +import { Routes } from '@potentiel-libraries/routes'; + +import { ButtonWithFormInModal } from '@/components/molecules/ButtonWithFormInModal'; + +import { annulerDépôtGarantiesFinancièresAction } from './annulerDépôtGarantiesFinancières.action'; + +type AnnulerDépôtGarantiesFinancièresFormProps = { + identifiantProjet: string; +}; + +export const AnnulerDépôtGarantiesFinancières = ({ + identifiantProjet, +}: AnnulerDépôtGarantiesFinancièresFormProps) => { + const router = useRouter(); + + return ( + router.push(Routes.GarantiesFinancières.soumettre(identifiantProjet)), + children: ( + <> +

Êtes-vous sûr de vouloir annuler ce dépôt ?

+ + + ), + }} + /> + ); +}; diff --git "a/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/modifier/annuler/annulerD\303\251p\303\264tGarantiesFinanci\303\250res.action.ts" "b/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/modifier/annuler/annulerD\303\251p\303\264tGarantiesFinanci\303\250res.action.ts" new file mode 100644 index 0000000000..2be6d2c306 --- /dev/null +++ "b/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/modifier/annuler/annulerD\303\251p\303\264tGarantiesFinanci\303\250res.action.ts" @@ -0,0 +1,23 @@ +'use server'; + +import * as zod from 'zod'; + +import { FormAction, formAction, FormState } from '@/utils/formAction'; +import { withUtilisateur } from '@/utils/withUtilisateur'; + +const schema = zod.object({ + identifiantProjet: zod.string().min(1), +}); + +const action: FormAction = async (_, { identifiantProjet }) => { + return withUtilisateur(async (utilisateur) => { + /** + * @todo appel au use-case à faire + */ + return { + status: 'success', + }; + }); +}; + +export const annulerDépôtGarantiesFinancièresAction = formAction(action, schema); diff --git "a/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251tails/modifierGarantiesFinanci\303\250res.action.ts" "b/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/modifier/modifierD\303\251p\303\264tGarantiesFinanci\303\250res.action.ts" similarity index 100% rename from "packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251tails/modifierGarantiesFinanci\303\250res.action.ts" rename to "packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/modifier/modifierD\303\251p\303\264tGarantiesFinanci\303\250res.action.ts" diff --git "a/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/modifier/rejeter/RejeterD\303\251p\303\264tGarantiesFinanci\303\250res.tsx" "b/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/modifier/rejeter/RejeterD\303\251p\303\264tGarantiesFinanci\303\250res.tsx" new file mode 100644 index 0000000000..85f11f4cba --- /dev/null +++ "b/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/modifier/rejeter/RejeterD\303\251p\303\264tGarantiesFinanci\303\250res.tsx" @@ -0,0 +1,41 @@ +'use client'; + +import { useRouter } from 'next/navigation'; + +import { Routes } from '@potentiel-libraries/routes'; + +import { ButtonWithFormInModal } from '@/components/molecules/ButtonWithFormInModal'; + +import { rejeterDépôtGarantiesFinancièresAction } from './rejeterDépôtGarantiesFinancières.action'; + +type RejeterDépôtGarantiesFinancièresFormProps = { + identifiantProjet: string; +}; + +export const RejeterDépôtGarantiesFinancières = ({ + identifiantProjet, +}: RejeterDépôtGarantiesFinancièresFormProps) => { + const router = useRouter(); + + return ( + router.push(Routes.GarantiesFinancières.détail(identifiantProjet)), + children: ( + <> +

Êtes-vous sûr de vouloir rejeter ce dépôt ?

+ + + ), + }} + /> + ); +}; diff --git "a/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/modifier/rejeter/rejeterD\303\251p\303\264tGarantiesFinanci\303\250res.action.ts" "b/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/modifier/rejeter/rejeterD\303\251p\303\264tGarantiesFinanci\303\250res.action.ts" new file mode 100644 index 0000000000..ec4845bfe0 --- /dev/null +++ "b/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/modifier/rejeter/rejeterD\303\251p\303\264tGarantiesFinanci\303\250res.action.ts" @@ -0,0 +1,23 @@ +'use server'; + +import * as zod from 'zod'; + +import { FormAction, formAction, FormState } from '@/utils/formAction'; +import { withUtilisateur } from '@/utils/withUtilisateur'; + +const schema = zod.object({ + identifiantProjet: zod.string().min(1), +}); + +const action: FormAction = async (_, { identifiantProjet }) => { + return withUtilisateur(async (utilisateur) => { + /** + * @todo appel au use-case à faire + */ + return { + status: 'success', + }; + }); +}; + +export const rejeterDépôtGarantiesFinancièresAction = formAction(action, schema); diff --git "a/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/modifier/valider/ValiderD\303\251p\303\264tGarantiesFinanci\303\250res.tsx" "b/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/modifier/valider/ValiderD\303\251p\303\264tGarantiesFinanci\303\250res.tsx" new file mode 100644 index 0000000000..080a1b1459 --- /dev/null +++ "b/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/modifier/valider/ValiderD\303\251p\303\264tGarantiesFinanci\303\250res.tsx" @@ -0,0 +1,41 @@ +'use client'; + +import { useRouter } from 'next/navigation'; + +import { Routes } from '@potentiel-libraries/routes'; + +import { ButtonWithFormInModal } from '@/components/molecules/ButtonWithFormInModal'; + +import { validerDépôtGarantiesFinancièresAction } from './validerDépôtGarantiesFinancières.action'; + +type ValiderDépôtGarantiesFinancièresFormProps = { + identifiantProjet: string; +}; + +export const ValiderDépôtGarantiesFinancières = ({ + identifiantProjet, +}: ValiderDépôtGarantiesFinancièresFormProps) => { + const router = useRouter(); + + return ( + router.push(Routes.GarantiesFinancières.détail(identifiantProjet)), + children: ( + <> +

Êtes-vous sûr de vouloir valider ce dépôt ?

+ + + ), + }} + /> + ); +}; diff --git "a/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/modifier/valider/validerD\303\251p\303\264tGarantiesFinanci\303\250res.action.ts" "b/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/modifier/valider/validerD\303\251p\303\264tGarantiesFinanci\303\250res.action.ts" new file mode 100644 index 0000000000..cc24e1e991 --- /dev/null +++ "b/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/modifier/valider/validerD\303\251p\303\264tGarantiesFinanci\303\250res.action.ts" @@ -0,0 +1,23 @@ +'use server'; + +import * as zod from 'zod'; + +import { FormAction, formAction, FormState } from '@/utils/formAction'; +import { withUtilisateur } from '@/utils/withUtilisateur'; + +const schema = zod.object({ + identifiantProjet: zod.string().min(1), +}); + +const action: FormAction = async (_, { identifiantProjet }) => { + return withUtilisateur(async (utilisateur) => { + /** + * @todo appel au use-case à faire + */ + return { + status: 'success', + }; + }); +}; + +export const validerDépôtGarantiesFinancièresAction = formAction(action, schema); diff --git "a/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/soumettre/SoumettreGarantiesFinanci\303\250res.page.tsx" "b/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/soumettre/SoumettreGarantiesFinanci\303\250res.page.tsx" similarity index 94% rename from "packages/applications/ssr/src/components/pages/garanties-financi\303\250res/soumettre/SoumettreGarantiesFinanci\303\250res.page.tsx" rename to "packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/soumettre/SoumettreGarantiesFinanci\303\250res.page.tsx" index 71842e43a2..95763ca3bb 100644 --- "a/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/soumettre/SoumettreGarantiesFinanci\303\250res.page.tsx" +++ "b/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/soumettre/SoumettreGarantiesFinanci\303\250res.page.tsx" @@ -15,8 +15,8 @@ import { ColumnPageTemplate } from '@/components/templates/ColumnPage.template'; import { ProjetBanner, ProjetBannerProps } from '@/components/molecules/projet/ProjetBanner'; import { formatDateForInput } from '@/utils/formatDateForInput'; -import { TitrePageGarantiesFinancières } from '../TitrePageGarantiesFinancieres'; -import { TypeGarantiesFinancièresSelect } from '../TypeGarantiesFinancièresSelect'; +import { TitrePageGarantiesFinancières } from '../../TitrePageGarantiesFinancieres'; +import { TypeGarantiesFinancièresSelect } from '../../TypeGarantiesFinancièresSelect'; import { soumettreGarantiesFinancièresAction } from './soumettreGarantiesFinancières.action'; @@ -43,7 +43,7 @@ export const SoumettreGarantiesFinancièresPage: FC router.push(Routes.Projet.details(projet.identifiantProjet))} onValidationError={(validationErrors) => setValidationErrors(validationErrors)} > diff --git "a/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/soumettre/SoumettreGarantiesFinanci\303\250res.stories.tsx" "b/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/soumettre/SoumettreGarantiesFinanci\303\250res.stories.tsx" similarity index 91% rename from "packages/applications/ssr/src/components/pages/garanties-financi\303\250res/soumettre/SoumettreGarantiesFinanci\303\250res.stories.tsx" rename to "packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/soumettre/SoumettreGarantiesFinanci\303\250res.stories.tsx" index cad3ddedb3..579f287dc8 100644 --- "a/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/soumettre/SoumettreGarantiesFinanci\303\250res.stories.tsx" +++ "b/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/soumettre/SoumettreGarantiesFinanci\303\250res.stories.tsx" @@ -6,7 +6,7 @@ import { } from './SoumettreGarantiesFinancières.page'; const meta = { - title: 'Pages/Garanties-financières/Soumettre/SoumettreGarantiesFinancières', + title: 'Pages/Garanties-financières/Dépôt/Soumettre', component: SoumettreGarantiesFinancièresPage, parameters: {}, tags: ['autodocs'], diff --git "a/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/soumettre/soumettreGarantiesFinanci\303\250res.action.ts" "b/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/soumettre/soumettreGarantiesFinanci\303\250res.action.ts" similarity index 100% rename from "packages/applications/ssr/src/components/pages/garanties-financi\303\250res/soumettre/soumettreGarantiesFinanci\303\250res.action.ts" rename to "packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251p\303\264t/soumettre/soumettreGarantiesFinanci\303\250res.action.ts" diff --git "a/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251tails/D\303\251tailsGarantiesFinanci\303\250res.page.tsx" "b/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251tails/D\303\251tailsGarantiesFinanci\303\250res.page.tsx" deleted file mode 100644 index 1a586cd90f..0000000000 --- "a/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251tails/D\303\251tailsGarantiesFinanci\303\250res.page.tsx" +++ /dev/null @@ -1,248 +0,0 @@ -'use client'; - -import React, { FC, useState } from 'react'; -import { notFound, useRouter } from 'next/navigation'; -import Download from '@codegouvfr/react-dsfr/Download'; -import Input from '@codegouvfr/react-dsfr/Input'; -import { Upload } from '@codegouvfr/react-dsfr/Upload'; -import Link from 'next/link'; -import Button from '@codegouvfr/react-dsfr/Button'; -import Alert from '@codegouvfr/react-dsfr/Alert'; - -import { Routes } from '@potentiel-libraries/routes'; - -import { ProjetBanner, ProjetBannerProps } from '@/components/molecules/projet/ProjetBanner'; -import { PageTemplate } from '@/components/templates/Page.template'; -import { ColumnPageTemplate } from '@/components/templates/ColumnPage.template'; -import { Form } from '@/components/atoms/form/Form'; -import { formatDateForInput } from '@/utils/formatDateForInput'; -import { SubmitButton } from '@/components/atoms/form/SubmitButton'; - -import { TitrePageGarantiesFinancières } from '../TitrePageGarantiesFinancieres'; -import { - TypeGarantiesFinancièresSelect, - TypeGarantiesFinancièresSelectProps, -} from '../TypeGarantiesFinancièresSelect'; - -import { modifierGarantiesFinancièresAction } from './modifierGarantiesFinancières.action'; - -type GarantiesFinancières = { - type: string; - dateÉchéance?: string; - dateConsitution: string; - attestationConstitution: string; -}; - -export type DétailsGarantiesFinancièresProps = { - projet: ProjetBannerProps; - garantiesFinancieres: { - actuelles?: GarantiesFinancières; - dépôt?: GarantiesFinancières; - }; -}; - -export const DétailsGarantiesFinancièresPage: FC = ({ - projet, - garantiesFinancieres: { actuelles, dépôt }, -}) => { - if (!actuelles && !dépôt) { - return notFound(); - } - - if (actuelles) { - return ; - } - - if (dépôt) { - return ; - } - - return null; -}; - -type ConsulterGarantiesFinancièresProps = { - projet: DétailsGarantiesFinancièresProps['projet']; - garantiesFinancieres: GarantiesFinancières; -}; -const ConsulterGarantiesFinancières: FC = ({ - projet, - garantiesFinancieres, -}) => ( - }> - -
- - - {garantiesFinancieres.dateÉchéance && ( - - )} - - - - - -
- -
-
-
-); - -type ModifierGarantiesFinancièresProps = { - projet: DétailsGarantiesFinancièresProps['projet']; - garantiesFinancieres: GarantiesFinancières; -}; - -const ModifierGarantiesFinancières: FC = ({ - projet, - garantiesFinancieres, -}) => { - const router = useRouter(); - const [validationErrors, setValidationErrors] = useState>([]); - - return ( - } - heading={} - leftColumn={{ - children: ( -
- router.push(Routes.GarantiesFinancières.détail(projet.identifiantProjet)) - } - onValidationError={(validationErrors) => setValidationErrors(validationErrors)} - heading="Modifier des garanties financières" - > - - - - - - Attestation de constitution{' '} - {garantiesFinancieres.attestationConstitution && ( - <> -
- - Pour que la modification puisse fonctionner, merci de joindre un nouveau - fichier ou{' '} - - celui préalablement transmis - - - - )} - - } - hint="Format accepté : pdf" - nativeInputProps={{ - name: 'attestationConstitution', - required: true, - 'aria-required': true, - accept: '.pdf', - }} - state={validationErrors.includes('attestationConstitution') ? 'error' : 'default'} - stateRelatedMessage="Attestation de consitution des garantières financières obligatoire" - /> - -
- - Soumettre -
- - ), - }} - rightColumn={{ - children: ( - - Vous pouvez modifier ce dépôt jusqu'à sa validation par la DREAL concernée. -

- } - /> - ), - }} - /> - ); -}; diff --git "a/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251tails/D\303\251tailsGarantiesFinanci\303\250res.stories.tsx" "b/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251tails/D\303\251tailsGarantiesFinanci\303\250res.stories.tsx" deleted file mode 100644 index b194d2014c..0000000000 --- "a/packages/applications/ssr/src/components/pages/garanties-financi\303\250res/d\303\251tails/D\303\251tailsGarantiesFinanci\303\250res.stories.tsx" +++ /dev/null @@ -1,62 +0,0 @@ -import type { Meta, StoryObj } from '@storybook/react'; - -import { ProjetBannerProps } from '@/components/molecules/projet/ProjetBanner'; - -import { - DétailsGarantiesFinancièresPage, - DétailsGarantiesFinancièresProps, -} from './DétailsGarantiesFinancières.page'; - -const meta = { - title: 'Pages/Garanties-financières/Détails/DétailsGarantiesFinancières', - component: DétailsGarantiesFinancièresPage, - parameters: {}, - tags: ['autodocs'], - argTypes: {}, -} satisfies Meta; - -export default meta; -type Story = StoryObj; - -const projet: ProjetBannerProps = { - identifiantProjet: 'identifiantProjet#1', - appelOffre: 'Appel offre', - période: 'Période', - famille: 'Famille', - nom: 'Nom du projet', - dateDésignation: '2021-10-23', - localité: { - codePostal: 'XXXXX', - commune: 'Commune', - département: 'Département', - région: 'Région', - }, - statut: 'classé', -}; - -export const AvecDépôt: Story = { - args: { - projet, - garantiesFinancieres: { - dépôt: { - type: 'consignation', - dateConsitution: '2021-10-23', - attestationConstitution: 'path/to/attestationConstitution', - }, - }, - }, -}; - -export const AvecActuelles: Story = { - args: { - projet, - garantiesFinancieres: { - actuelles: { - type: 'avec date d’échéance', - dateÉchéance: '2021-10-23', - dateConsitution: '2021-10-23', - attestationConstitution: 'path/to/attestationConstitution', - }, - }, - }, -};