From f2c3a7371374e4e2de840b033a5f9920ba5e7837 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 16 Feb 2024 12:20:22 +0100 Subject: [PATCH] feat: form for move property --- src/i18n/identificationMessage.js | 3 ++ src/ui/SurveyUnit/IdentificationCard.jsx | 46 ++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/src/i18n/identificationMessage.js b/src/i18n/identificationMessage.js index bbdde9fc..8fc4f2e2 100644 --- a/src/i18n/identificationMessage.js +++ b/src/i18n/identificationMessage.js @@ -20,6 +20,9 @@ const identificationMessage = { housingCategory: { fr: 'Catégorie du logement', en: 'Housing category' }, housingOccupant: { fr: "Identification de l'occupant", en: 'Occupant identification' }, identification: { fr: 'Repérage', en: 'Identification' }, + move: { fr: 'Déplacement terrain', en: 'Moving in the field' }, + yes: { fr: 'Oui', en: 'Yes' }, + no: { fr: 'Non', en: 'No' }, }; export default identificationMessage; diff --git a/src/ui/SurveyUnit/IdentificationCard.jsx b/src/ui/SurveyUnit/IdentificationCard.jsx index 1afc29ec..5e0bbcc1 100644 --- a/src/ui/SurveyUnit/IdentificationCard.jsx +++ b/src/ui/SurveyUnit/IdentificationCard.jsx @@ -9,6 +9,9 @@ import { ButtonLine } from '../ButtonLine'; import { useIdentificationQuestions } from '../../utils/hooks/useIdentificationQuestions'; import DialogTitle from '@mui/material/DialogTitle'; +import FormGroup from '@mui/material/FormGroup'; +import FormControlLabel from '@mui/material/FormControlLabel'; +import Checkbox from '@mui/material/Checkbox'; import Dialog from '@mui/material/Dialog'; import DialogContent from '@mui/material/DialogContent'; import DialogActions from '@mui/material/DialogActions'; @@ -16,6 +19,7 @@ import Button from '@mui/material/Button'; import React, { useState } from 'react'; import { RadioLine } from '../RadioLine'; import RadioGroup from '@mui/material/RadioGroup'; +import { surveyUnitIDBService } from '../../utils/indexeddb/services/surveyUnit-idb-service'; /** * @param {SurveyUnit} surveyUnit @@ -44,6 +48,7 @@ export function IdentificationCard({ surveyUnit }) { onClick={() => setQuestion(question)} /> ))} + @@ -60,6 +65,47 @@ export function IdentificationCard({ surveyUnit }) { ); } +/** + * @param {SurveyUnit} surveyUnit + */ +function MoveQuestion({ surveyUnit }) { + const options = [ + { label: D.yes, value: true }, + { label: D.no, value: false }, + ]; + const value = surveyUnit.move; + const handleChange = e => { + surveyUnitIDBService.addOrUpdateSU({ + ...surveyUnit, + move: e.target.checked ? e.target.value === 'true' : null, + }); + }; + return ( + + + {D.move} + + + {options.map(option => ( + + } + label={option.label} + /> + ))} + + + ); +} + function IdentificationDialog({ answers, question, onClose, onSubmit }) { const [localAnswer, setLocalAnswer] = useState(question?.answer?.value);