Fixes user availability to be contextual to the user timezone (#1166)

* WIP, WIP, WIP, WIP

* Adds missing types

* Type fixes for useSlots

* Type fixes

* Fixes periodType 500 error when updating

* Adds missing dayjs plugin and type fixes

* An attempt was made to fix tests

* Save work in progress

* Added UTC overflow to days

* Update lib/availability.ts

Co-authored-by: Alex Johansson <[email protected]>

* No more magic numbers

* Fixed slots.test & added getWorkingHours.test

* Tests pass, simpler logic, profit?

* Timezone shifting!

* Forgot to unskip tests

* Updated the user page

* Added American seed user, some fixes

* tmp fix so to continue testing availability

* Removed timeZone parameter, fix defaultValue auto-scroll

Co-authored-by: Omar López <[email protected]>
Co-authored-by: Alex Johansson <[email protected]>
This commit is contained in:
authored and GitHub committed 2021-11-18 01:03:19 +00:00
1 parent f3c95fa3de
commit ffdf0b9217
23 files changed
+587 -333

No files matched your search

+4 -5
View File
@@ -1,7 +1,6 @@
import { SchedulingType, EventType, Availability } from "@prisma/client";
import { EventType, SchedulingType } from "@prisma/client";
export type OpeningHours = Pick<Availability, "days" | "startTime" | "endTime">;
export type DateOverride = Pick<Availability, "date" | "startTime" | "endTime">;
import { WorkingHours } from "./schedule";
export type AdvancedOptions = {
eventName?: string;
@@ -21,7 +20,7 @@ export type AdvancedOptions = {
label: string;
avatar: string;
}[];
availability?: { openingHours: OpeningHours[]; dateOverrides: DateOverride[] };
availability?: { openingHours: WorkingHours[]; dateOverrides: WorkingHours[] };
customInputs?: EventTypeCustomInput[];
timeZone: string;
hidden: boolean;
@@ -58,5 +57,5 @@ export type EventTypeInput = AdvancedOptions & {
locations: unknown;
customInputs: EventTypeCustomInput[];
timeZone: string;
availability?: { openingHours: OpeningHours[]; dateOverrides: DateOverride[] };
availability?: { openingHours: WorkingHours[]; dateOverrides: WorkingHours[] };
};
+12
View File
@@ -4,3 +4,15 @@ export type TimeRange = {
};
export type Schedule = TimeRange[][];
/**
* ```text
* Ensure startTime and endTime in minutes since midnight; serialized to UTC by using the organizer timeZone, either by using the schedule timeZone or the user timeZone.
* @see lib/availability.ts getWorkingHours(timeZone: string, availability: Availability[])
* ```
*/
export type WorkingHours = {
days: number[];
startTime: number;
endTime: number;
};