Skip to content

Commit

Permalink
(fix) O3-3260: When editing an appointment, changing the service prev…
Browse files Browse the repository at this point in the history
…ents form submission due to duration field error (#1149)
  • Loading branch information
mccarthyaaron authored Aug 7, 2024
1 parent ac24702 commit 1c21bdd
Showing 1 changed file with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -489,11 +489,22 @@ const AppointmentsForm: React.FC<AppointmentsFormProps> = ({
invalidText="Required"
labelText={t('selectService', 'Select a service')}
onChange={(event) => {
if (context === 'creating') {
setValue(
'duration',
services?.find((service) => service.name === event.target.value)?.durationMins,
);
} else if (context === 'editing') {
const previousServiceDuration = services?.find(
(service) => service.name === getValues('selectedService'),
)?.durationMins;
const selectedServiceDuration = services?.find((service) => service.name === event.target.value)
?.durationMins;
if (selectedServiceDuration && previousServiceDuration === getValues('duration')) {
setValue('duration', selectedServiceDuration);
}
}
onChange(event);
setValue(
'duration',
services?.find((service) => service.name === event.target.value)?.durationMins,
);
}}
onBlur={onBlur}
value={value}
Expand Down

0 comments on commit 1c21bdd

Please sign in to comment.