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 options = useMemo(() => {
|
||||||
const end = dayjs().utc().endOf("day");
|
const end = dayjs().utc().endOf("day");
|
||||||
let t: Dayjs = dayjs().utc().startOf("day");
|
|
||||||
|
|
||||||
const options: IOption[] = [];
|
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({
|
options.push({
|
||||||
value: t.toDate().valueOf(),
|
value: t.toDate().valueOf(),
|
||||||
label: dayjs(t)
|
label: dayjs(t)
|
||||||
.utc()
|
.utc()
|
||||||
.format(timeFormat === 12 ? "h:mma" : "HH:mm"),
|
.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;
|
return options;
|
||||||
}, [timeFormat]);
|
}, [timeFormat]);
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,13 @@ export const availabilityRouter = router({
|
||||||
return {
|
return {
|
||||||
name: schedule.name,
|
name: schedule.name,
|
||||||
rawSchedule: schedule,
|
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) => {
|
dateOverrides: schedule.availability.reduce((acc, override) => {
|
||||||
// only iff future date override
|
// only iff future date override
|
||||||
if (!override.date || override.date < new Date()) {
|
if (!override.date || override.date < new Date()) {
|
||||||
|
|
Loading…
Reference in New Issue