fix installation date is not ediable issue

This commit is contained in:
Yinyin Liu 2026-05-19 13:24:18 +02:00
parent 795e77d304
commit c21f222f86
1 changed files with 18 additions and 2 deletions

View File

@ -366,6 +366,16 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) {
const handleSubmit = () => { const handleSubmit = () => {
setLoading(true); setLoading(true);
setError(false); setError(false);
if (canEdit && installationDateChecklistId !== null) {
axiosConfig
.put('/UpdateChecklistItem', null, {
params: {
checklistItemId: installationDateChecklistId,
doneAt: installationDate ?? ''
}
})
.catch(() => {});
}
updateInstallation(formValues, props.type); updateInstallation(formValues, props.type);
}; };
@ -405,6 +415,7 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) {
const [networkProviders, setNetworkProviders] = useState<string[]>([]); const [networkProviders, setNetworkProviders] = useState<string[]>([]);
const [loadingProviders, setLoadingProviders] = useState(false); const [loadingProviders, setLoadingProviders] = useState(false);
const [installationDate, setInstallationDate] = useState<string>(''); const [installationDate, setInstallationDate] = useState<string>('');
const [installationDateChecklistId, setInstallationDateChecklistId] = useState<number | null>(null);
useEffect(() => { useEffect(() => {
setLoadingProviders(true); setLoadingProviders(true);
@ -427,9 +438,13 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) {
(i: { stepNumber?: number }) => i.stepNumber === 10 (i: { stepNumber?: number }) => i.stepNumber === 10
); );
setInstallationDate(step10?.doneAt ?? ''); setInstallationDate(step10?.doneAt ?? '');
setInstallationDateChecklistId(step10?.id ?? null);
} }
}) })
.catch(() => setInstallationDate('')); .catch(() => {
setInstallationDate('');
setInstallationDateChecklistId(null);
});
}, [props.values.id]); }, [props.values.id]);
return ( return (
@ -879,10 +894,11 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) {
label={<FormattedMessage id="installationDate" defaultMessage="Installation Date" />} label={<FormattedMessage id="installationDate" defaultMessage="Installation Date" />}
type="date" type="date"
value={installationDate} value={installationDate}
onChange={(e) => setInstallationDate(e.target.value)}
variant="outlined" variant="outlined"
fullWidth fullWidth
InputLabelProps={{ shrink: true }} InputLabelProps={{ shrink: true }}
inputProps={{ readOnly: true }} inputProps={{ readOnly: !canEdit }}
/> />
</div> </div>