Skip to content

Commit

Permalink
Merge pull request #398 from sanger/probeQc_completion_time
Browse files Browse the repository at this point in the history
Probe qc completion time
  • Loading branch information
sabrine33 authored Sep 8, 2023
2 parents df2f574 + fb9eeba commit beff022
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/pages/ProbeHybridisationQC.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ const getCommentTextFromField = (
return [];
};

const currentDateTime = getCurrentDateTime();

const mapSampleAddressCommentIds = (
address: string,
sampleId: number,
Expand Down Expand Up @@ -124,7 +122,7 @@ const formInitialValues: ProbeHybridisationQCFormValues = {
labwares: {
'': {
globalComments: [],
completionDateTime: currentDateTime,
completionDateTime: getCurrentDateTime(),
sampleAddressComments: { '': [] }
}
}
Expand Down Expand Up @@ -232,9 +230,7 @@ export default function ProbeHybridisationQC({ comments }: SectionComments) {
);

const validateCompletionDateTime = (selectedTime: string) => {
return new Date(selectedTime) > new Date(currentDateTime)
? 'Please select a time on or before current time'
: undefined;
return new Date(selectedTime) > new Date() ? 'Please select a time on or before current time' : undefined;
};

return (
Expand Down Expand Up @@ -296,12 +292,11 @@ export default function ProbeHybridisationQC({ comments }: SectionComments) {
data-testid={'completionDateTime'}
type="datetime-local"
name={`labwares[${labware.barcode}].completionDateTime`}
max={currentDateTime}
min={currentDateTime.split('T')[0] + 'T00:00'}
max={getCurrentDateTime()}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
setFieldValue(`labwares.${labware.barcode}.completionDateTime`, e.target.value);
}}
value={values.labwares[labware.barcode]?.completionDateTime || currentDateTime}
value={values.labwares[labware.barcode]?.completionDateTime || getCurrentDateTime()}
className="w-1/2"
validate={validateCompletionDateTime}
/>
Expand Down

0 comments on commit beff022

Please sign in to comment.