Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(feat) O3-3200 - service queues - prevent setting of queue entry's st… #1254

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function QueueTableActionCell({ queueEntry }: QueueTableCellComponentProp
size={isDesktop(layout) ? 'sm' : 'lg'}>
{t('transition', 'Transition')}
</Button>
<OverflowMenu aria-label="Actions menu" size={isDesktop(layout) ? 'sm' : 'lg'} flipped>
<OverflowMenu aria-label="Actions menu" size={isDesktop(layout) ? 'sm' : 'lg'} align="left" flipped>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor cosmetic fix to prevent the "Options" tooltip from expanding the table width on hover, which makes the horizontal scrollbar appear

image

<OverflowMenuItem
className={styles.menuItem}
aria-label={t('edit', 'Edit')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,33 @@ export const QueueEntryActionModal: React.FC<QueueEntryActionModalProps> = ({
});
};

const isTimeInvalid = useMemo(() => {
// non-null if the selected date+time is invalid
const timeInvalidMessage = useMemo(() => {
const now = new Date();
const startAtDate = new Date(formState.transitionDate);
const [hour, minute] = convertTime12to24(formState.transitionTime, formState.transitionTimeFormat);
startAtDate.setHours(hour, minute, 0, 0);
return startAtDate > now;
}, [formState.transitionDate, formState.transitionTime, formState.transitionTimeFormat]);

const previousQueueEntryStartTimeStr = queueEntry.previousQueueEntry?.startedAt;
const previousQueueEntryStartTime = previousQueueEntryStartTimeStr
? new Date(previousQueueEntryStartTimeStr)
: null;

if (startAtDate > now) {
return t('timeCannotBeInFuture', 'Time cannot be in the future');
}
if (startAtDate <= previousQueueEntryStartTime) {
return t(
'timeCannotBePriorToPreviousQueueEntry',
'Time cannot be before start of previous queue entry: {{time}}',
{
time: previousQueueEntryStartTime.toLocaleString(),
interpolation: { escapeValue: false },
},
);
}
return null;
}, [formState.transitionDate, formState.transitionTime, formState.transitionTimeFormat, t]);

const selectedPriorityIndex = priorities?.findIndex((p) => p.uuid == formState.selectedPriority);

Expand Down Expand Up @@ -329,8 +349,8 @@ export const QueueEntryActionModal: React.FC<QueueEntryActionModalProps> = ({
onChange={(event) => setTransitionTime(event.target.value)}
pattern={time12HourFormatRegexPattern}
value={formState.transitionTime}
invalid={isTimeInvalid}
invalidText={t('timeCannotBeInFuture', 'Time cannot be in the future')}
invalid={timeInvalidMessage != null}
invalidText={timeInvalidMessage}
disabled={!formState.modifyDefaultTransitionDateTime}>
<TimePickerSelect
id="visitStartTimeSelect"
Expand Down
Loading