Skip to content

Commit

Permalink
Validate that end time is after start time before setting state.
Browse files Browse the repository at this point in the history
  • Loading branch information
ziggabyte committed Sep 12, 2023
1 parent b4fc78a commit ae0ae5d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/features/events/components/EventOverviewCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -260,16 +260,19 @@ const EventOverviewCard: FC<EventOverviewCardProps> = ({
return (
<TimeField
ampm={false}
disableIgnoringDatePartForTimeValidation={true}
format="HH:mm"
fullWidth
label={messages.eventOverviewCard.endTime()}
minTime={dayjs(naiveStart).add(1, 'min')}
onChange={(newEndTime) => {
if (newEndTime) {
const endTimeString = makeNaiveTimeString(
newEndTime.utc().toDate()
);
setEndTime(endTimeString);
if (newEndTime >= dayjs(naiveStart).add(1, 'min')) {
const endTimeString = makeNaiveTimeString(
newEndTime.utc().toDate()
);
setEndTime(endTimeString);
}
}
}}
slotProps={{
Expand Down

0 comments on commit ae0ae5d

Please sign in to comment.