Add 23:59 as a valid availability select option (#6137)
Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>pull/6140/head
parent
9de19d35a8
commit
8eda30d88c
|
@ -300,18 +300,26 @@ const useOptions = () => {
|
|||
|
||||
const options = useMemo(() => {
|
||||
const end = dayjs().utc().endOf("day");
|
||||
let t: Dayjs = dayjs().utc().startOf("day");
|
||||
|
||||
const options: IOption[] = [];
|
||||
while (t.isBefore(end)) {
|
||||
for (
|
||||
let t = dayjs().utc().startOf("day");
|
||||
t.isBefore(end);
|
||||
t = t.add(INCREMENT + (!t.add(INCREMENT).isSame(t, "day") ? -1 : 0), "minutes")
|
||||
) {
|
||||
options.push({
|
||||
value: t.toDate().valueOf(),
|
||||
label: dayjs(t)
|
||||
.utc()
|
||||
.format(timeFormat === 12 ? "h:mma" : "HH:mm"),
|
||||
});
|
||||
t = t.add(INCREMENT, "minutes");
|
||||
}
|
||||
// allow 23:59
|
||||
options.push({
|
||||
value: end.toDate().valueOf(),
|
||||
label: dayjs(end)
|
||||
.utc()
|
||||
.format(timeFormat === 12 ? "h:mma" : "HH:mm"),
|
||||
});
|
||||
return options;
|
||||
}, [timeFormat]);
|
||||
|
||||
|
|
|
@ -84,7 +84,13 @@ export const availabilityRouter = router({
|
|||
return {
|
||||
name: schedule.name,
|
||||
rawSchedule: schedule,
|
||||
schedule: availability,
|
||||
schedule: availability.map((a) =>
|
||||
a.map((startAndEnd) => ({
|
||||
...startAndEnd,
|
||||
// Turn our limited granularity into proper end of day.
|
||||
end: new Date(startAndEnd.end.toISOString().replace("23:59:00.000Z", "23:59:59.999Z")),
|
||||
}))
|
||||
),
|
||||
dateOverrides: schedule.availability.reduce((acc, override) => {
|
||||
// only iff future date override
|
||||
if (!override.date || override.date < new Date()) {
|
||||
|
|
Loading…
Reference in New Issue