Skip to content

Commit

Permalink
♻️ Inputfile in legacy done
Browse files Browse the repository at this point in the history
  • Loading branch information
VioMrqs committed Sep 19, 2024
1 parent 68bebb3 commit 18c1923
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type InputFileProps = {
export const InputFile = ({
id = 'file',
name = 'file',
required,
required = true,
disabled,
className,
}: InputFileProps) => {
Expand All @@ -23,11 +23,11 @@ export const InputFile = ({
name={name}
id={id}
required={required}
aria-required
aria-required={required}
disabled={disabled}
className={className}
/>
<LabelDescription>Taille maximale du fichier : 50 MB</LabelDescription>
<LabelDescription className="italic">Taille maximale du fichier : 50 Mo</LabelDescription>
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ import {
} from '../components';
import { hydrateOnClient } from '../helpers/hydrateOnClient';

export type UploadLegacyModificationFileResult =
| {
filename: string;
} & ({ error: false } | { error: true; message: string });
export type UploadLegacyModificationFileResult = {
filename: string;
} & ({ error: false } | { error: true; message: string });

type UploadLegacyModificationFilesProps = {
request: Request;
Expand Down Expand Up @@ -78,7 +77,7 @@ export const UploadLegacyModificationFiles = ({
</div>
<Input type="file" multiple name="files" id="files" />
<div className="text-sm mt-2">
Vous pouvez attacher jusqu'à 50Mo de fichiers à la fois
Vous pouvez attacher des fichiers de 50Mo max à la fois
</div>
</div>
<PrimaryButton type="submit" name="submit" id="submit">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
Form,
ChampsObligatoiresLégende,
LabelDescription,
InputFile,
} from '../../components';
import { hydrateOnClient } from '../../helpers';
import { CHAMPS_FOURNISSEURS, CORRESPONDANCE_CHAMPS_FOURNISSEURS } from '../../../modules/project';
Expand Down Expand Up @@ -142,7 +143,7 @@ export const ChangerFournisseur = ({ request, project, appelOffre }: ChangerFour
)}
<div>
<Label htmlFor="file">Pièce-jointe</Label>
<Input type="file" name="file" id="file" required aria-required="true" />
<InputFile />
</div>
<div>
<Label htmlFor="justification">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
Form,
Heading1,
Input,
InputFile,
Label,
LabelDescription,
LegacyPageTemplate,
Expand Down Expand Up @@ -101,14 +102,7 @@ export const ChangerProducteur = ({ request, project, appelOffre }: ChangerProdu
</div>
<div>
<Label htmlFor="file">Joindre les statuts mis à jour</Label>
<Input
type="file"
name="file"
id="file"
required
aria-required
{...(!appelOffre?.changementProducteurPossibleAvantAchèvement && { disabled: true })}
/>
<InputFile disabled={!appelOffre?.changementProducteurPossibleAvantAchèvement} />
</div>
<div>
<Label htmlFor="justification" optionnel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
LabelDescription,
Callout,
AlertBox,
InputFile,
} from '../../../components';
import { AlertePuissanceMaxDepassee } from './AlertePuissanceMaxDepassee';
import { AlertePuissanceHorsRatios } from './AlertePuissanceHorsRatios';
Expand Down Expand Up @@ -214,13 +215,7 @@ export const ChangementPuissance = ({
>
Courrier explicatif ou décision administrative
</Label>
<Input
type="file"
name="file"
id="file"
required={fichierEtJustificationRequis}
aria-required={fichierEtJustificationRequis}
/>
<InputFile required={fichierEtJustificationRequis} />
</div>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
Form,
InfoBox,
Input,
InputFile,
Label,
PageProjetTemplate,
PrimaryButton,
Expand Down Expand Up @@ -85,7 +86,7 @@ export const CorrigerDelaiAccorde = ({
</li>
<li>
<span>Téléversez le courrier signé : </span>
<Input type="file" name="file" id="file" required aria-required />
<InputFile />
</li>
</ol>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ export const PuissanceForm = ({ modificationRequest }: PuissanceFormProps) => {
optionnel={true}
reasonForOptionnel={`en cas de refus ou de décision favorable de l'État`}
/>

<div>
<div>
Nouvelle {textPuissance.toLowerCase()} demandée :{' '}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { DownloadResponseTemplate } from '.';
import { ModificationRequestPageDTO } from '../../../../modules/modificationRequest';
import { Input, Label } from '../../../components';
import { InputFile, Label } from '../../../components';

interface UploadResponseFileProps {
modificationRequest: ModificationRequestPageDTO & { type: string };
Expand All @@ -19,13 +19,7 @@ export const UploadResponseFile = ({
<Label htmlFor="file" optionnel={optionnel} reasonForOptionnel={reasonForOptionnel}>
Réponse signée (fichier pdf)
</Label>
<Input
type="file"
name="file"
id="file"
required={modificationRequest.type !== 'puissance'}
aria-required={modificationRequest.type !== 'puissance'}
/>
<InputFile required={modificationRequest.type !== 'puissance'} />
</div>
<DownloadResponseTemplate modificationRequest={modificationRequest} />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
Callout,
ChampsObligatoiresLégende,
Input,
InputFile,
Label,
LabelDescription,
TextArea,
Expand Down Expand Up @@ -44,7 +45,7 @@ export const ChangementActionnaire = ({
<LabelDescription>
Vous pouvez transmettre un fichier compressé si il y a plusieurs documents
</LabelDescription>
<Input type="file" name="file" id="file" required aria-required="true" />
<InputFile />
</div>
<div>
<Label htmlFor="justification" optionnel={true}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react';

import {
Input,
Label,
TextArea,
ChampsObligatoiresLégende,
LabelDescription,
InputFile,
} from '../../../../components';

type DemandeRecoursProps = {
Expand Down Expand Up @@ -36,7 +36,7 @@ export const DemandeRecours = ({ justification }: DemandeRecoursProps) => (
<LabelDescription>
Vous pouvez transmettre un fichier compressé si il y a plusieurs documents
</LabelDescription>
<Input type="file" name="file" id="file" required aria-required="true" />
<InputFile />
</div>
</>
);
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
Label,
Form,
ChampsObligatoiresLégende,
InputFile,
} from '../../../components';

type AttachFileProps = {
Expand Down Expand Up @@ -56,14 +57,7 @@ export const AttachFile = ({ projectId }: AttachFileProps) => {
<div>
<Label htmlFor="file">Fichier(s) à attacher</Label>
{Array.from({ length: fileCount }, (v, i) => i).map((i) => (
<Input
key={`file_${i}`}
type="file"
name="file"
id="file"
required
aria-required="true"
/>
<InputFile key={`file_${i}`} />
))}
<Link onClick={() => setFileCount(fileCount + 1)}>+ Ajouter un autre fichier</Link>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
Label,
LabelDescription,
Input,
InputFile,
} from '../../components';
import { ProjectDataForSignalerDemandeDelaiPage } from '../../../modules/project';
import routes from '../../../routes';
Expand Down Expand Up @@ -142,7 +143,7 @@ export const SignalerDemandeDelai = ({
<Label htmlFor="file" optionnel>
Courrier de la réponse (fichier joint)
</Label>
<Input name="file" type="file" className="rounded-none" id="file" />
<InputFile className="rounded-none" required={false} />
</div>

<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
Radio,
Form,
ChampsObligatoiresLégende,
InputFile,
} from '../../components';
import routes from '../../../routes';
import { ProjectDataForSignalerDemandeRecoursPage } from '../../../modules/project';
Expand Down Expand Up @@ -98,14 +99,7 @@ export const SignalerDemandeRecours = ({

<div>
<Label htmlFor="file">Courrier de la réponse (fichier joint)</Label>
<Input
name="file"
type="file"
className="rounded-none"
id="file"
required
aria-required="true"
/>
<InputFile className="rounded-none" />
</div>

<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const UploadNewDocument: FC<Omit<UploadDocumentProps, 'documentKey'>> = ({
setUploadFileName(fileName);
}}
/>
<div className="fr-hint-text">Taille maximale acceptée : XX MB</div>
{/* <div className="fr-hint-text">Taille maximale acceptée : XX MB</div> */}

<Button className="!mt-0" type="button" priority="secondary" onClick={browseForFile}>
<Icon id="fr-icon-folder-2-fill" className="md:mr-1" />
Expand Down

0 comments on commit 18c1923

Please sign in to comment.