Skip to content

Commit d469f7d

Browse files
committed
Handle sample form (WIP)
1 parent 91eb2d3 commit d469f7d

File tree

4 files changed

+60
-21
lines changed

4 files changed

+60
-21
lines changed

frontend/src/views/SampleView/SampleFormStep1.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ const SampleFormStep1 = ({}: Props) => {
152152
/>
153153
</div>
154154
)}
155+
<hr className={cx('fr-mt-3w', 'fr-mx-0')} />
155156

156157
<div className={cx('fr-col-12')}>
157158
<Button data-testid="submit-button" onClick={submit}>

frontend/src/views/SampleView/SampleFormStep2.tsx

+15
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const SampleFormStep2 = ({ sample }: Props) => {
4141
sample.temperatureMaintenance
4242
);
4343
const [expiryDate, setExpiryDate] = useState(sample.expiryDate);
44+
const [locationSiret, setLocationSiret] = useState(sample.locationSiret);
4445
const [sealId, setSealId] = useState(sample.sealId);
4546

4647
const [updateSample] = useUpdateSampleMutation();
@@ -62,6 +63,7 @@ const SampleFormStep2 = ({ sample }: Props) => {
6263
sampleCount,
6364
temperatureMaintenance,
6465
expiryDate,
66+
locationSiret,
6567
sealId,
6668
});
6769

@@ -93,6 +95,7 @@ const SampleFormStep2 = ({ sample }: Props) => {
9395
sampleCount,
9496
temperatureMaintenance,
9597
expiryDate,
98+
locationSiret,
9699
sealId,
97100
},
98101
});
@@ -281,6 +284,18 @@ const SampleFormStep2 = ({ sample }: Props) => {
281284
</div>
282285
<hr className={cx('fr-mt-3w', 'fr-mx-0')} />
283286
<div className={cx('fr-grid-row', 'fr-grid-row--gutters')}>
287+
<div className={cx('fr-col-12', 'fr-col-sm-4')}>
288+
<AppTextInput<FormShape>
289+
defaultValue={locationSiret ?? ''}
290+
onChange={(e) => setLocationSiret(e.target.value)}
291+
inputForm={form}
292+
inputKey="locationSiret"
293+
whenValid="SIRET valide"
294+
data-testid="locationSiret-input"
295+
label="SIRET (obligatoire)"
296+
required
297+
/>
298+
</div>
284299
<div className={cx('fr-col-12', 'fr-col-sm-4')}>
285300
<AppTextInput<FormShape>
286301
type="number"

frontend/src/views/SampleView/SampleFormStep3.tsx

+38-20
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,50 @@
1-
import ButtonsGroup from '@codegouvfr/react-dsfr/ButtonsGroup';
2-
import { cx } from '@codegouvfr/react-dsfr/fr/cx';
3-
import { PartialSample, SampleUpdate } from 'shared/schema/Sample';
1+
import Button from '@codegouvfr/react-dsfr/Button';
2+
import { PartialSample } from 'shared/schema/Sample';
43

54
interface Props {
65
sample: PartialSample;
76
}
87

98
const SampleFormStep3 = ({ sample }: Props) => {
10-
const Form = SampleUpdate;
11-
12-
type FormShape = typeof Form.shape;
13-
149
const submit = async (e: React.MouseEvent<HTMLElement>) => {};
1510

1611
return (
17-
<form data-testid="draft_sample_3_form">
18-
<div className={cx('fr-col-12')}>
19-
<ButtonsGroup
20-
inlineLayoutWhen="md and up"
21-
buttons={[
22-
{
23-
children: 'Valider le prélèvement',
24-
onClick: submit,
25-
},
26-
]}
27-
/>
28-
</div>
29-
</form>
12+
<div>
13+
<p>
14+
Vérifiez que les informations saisies sont correctes avant de valider
15+
l'envoi de votre prélèvement.
16+
</p>
17+
<ul>
18+
<li>
19+
<strong>Numéro de résytal :</strong> {sample.resytalId}
20+
</li>
21+
<li>
22+
<strong>Contexte du prélèvement :</strong> {sample.context}
23+
</li>
24+
<li>
25+
<strong>Département :</strong> {sample.department}
26+
</li>
27+
<li>
28+
<strong>Matrice :</strong> {sample.matrix}
29+
</li>
30+
<li>
31+
<strong>Partie du végétal :</strong> {sample.matrixPart}
32+
</li>
33+
<li>
34+
<strong>Stade du végétal :</strong> {sample.stage}
35+
</li>
36+
<li>
37+
<strong>Quantité :</strong> {sample.quantity} {sample.quantityUnit}
38+
</li>
39+
<li>
40+
<strong>Nombre de prélèvements :</strong> {sample.sampleCount}
41+
</li>
42+
<li>
43+
<strong>Numéro de scellé :</strong> {sample.sealId}
44+
</li>
45+
</ul>
46+
<Button data-testid="submit-button">Envoyer le prélèvement</Button>
47+
</div>
3048
);
3149
};
3250

shared/schema/Sample.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ export const Sample = z.object({
3030
createdBy: z.string(),
3131
context: SampleContext,
3232
userLocation: UserLocation,
33-
locationSiret: z.string().optional().nullable(),
33+
locationSiret: z
34+
.string({
35+
required_error: 'Veuillez renseigner le SIRET du lieu de prélèvement.',
36+
})
37+
.regex(/^[0-9]{14}$/g, 'SIRET invalide.'),
3438
locationName: z.string().optional().nullable(),
3539
locationAddress: z.string().optional().nullable(),
3640
matrixKind: z.string({
@@ -97,6 +101,7 @@ export const SampleUpdate = Sample.pick({
97101
sampleCount: true,
98102
temperatureMaintenance: true,
99103
expiryDate: true,
104+
locationSiret: true,
100105
sealId: true,
101106
});
102107

0 commit comments

Comments
 (0)