feat: configure availability time picker interval by env variable (#12174)
This commit is contained in:
parent
26637cda08
commit
0d1b6ea5b2
|
@ -207,6 +207,8 @@ CSP_POLICY=
|
|||
EDGE_CONFIG=
|
||||
|
||||
NEXT_PUBLIC_MINUTES_TO_BOOK=5 # Minutes
|
||||
# Control time intervals on a user's Schedule availability
|
||||
NEXT_PUBLIC_AVAILABILITY_SCHEDULE_INTERVAL=
|
||||
|
||||
# - ORGANIZATIONS *******************************************************************************************
|
||||
# Enable Organizations non-prod domain setup, works in combination with organizations feature flag
|
||||
|
|
4
app.json
4
app.json
|
@ -83,6 +83,10 @@
|
|||
"NEXT_PUBLIC_TEAM_IMPERSONATION": {
|
||||
"description": "Set the following value to true if you wish to enable Team Impersonation",
|
||||
"value": "false"
|
||||
},
|
||||
"NEXT_PUBLIC_AVAILABILITY_SCHEDULE_INTERVAL": {
|
||||
"description": "Control time intervals on a user's Schedule availability",
|
||||
"value": "15"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
|
|
|
@ -326,7 +326,7 @@ interface IOption {
|
|||
* 23:45:00 (End of day with enough time for 15 min booking)
|
||||
*/
|
||||
/** Begin Time Increments For Select */
|
||||
const INCREMENT = 15;
|
||||
const INCREMENT = Number(process.env.NEXT_PUBLIC_AVAILABILITY_SCHEDULE_INTERVAL) || 15;
|
||||
const useOptions = () => {
|
||||
// Get user so we can determine 12/24 hour format preferences
|
||||
const query = useMeQuery();
|
||||
|
|
|
@ -300,3 +300,46 @@ describe("Tests the slot logic", () => {
|
|||
expect(slots[0].time.format()).toBe("2023-07-13T08:00:00+05:30");
|
||||
});
|
||||
});
|
||||
|
||||
describe("Tests the date-range slot logic with custom env variable", () => {
|
||||
beforeAll(() => {
|
||||
vi.stubEnv("NEXT_PUBLIC_AVAILABILITY_SCHEDULE_INTERVAL", "10");
|
||||
});
|
||||
|
||||
it("can fit 11 10 minute slots within a 2 hour window using a 10 mintue availabilty option with a starting time of 10 past the hour", async () => {
|
||||
expect(Number(process.env.NEXT_PUBLIC_AVAILABILITY_SCHEDULE_INTERVAL)).toBe(10);
|
||||
expect(
|
||||
getSlots({
|
||||
inviteeDate: dayjs.utc().add(1, "day"),
|
||||
frequency: 10,
|
||||
minimumBookingNotice: 0,
|
||||
workingHours: [
|
||||
{
|
||||
userId: 1,
|
||||
days: Array.from(Array(7).keys()),
|
||||
startTime: 10,
|
||||
endTime: 120,
|
||||
},
|
||||
],
|
||||
eventLength: 10,
|
||||
offsetStart: 0,
|
||||
organizerTimeZone: "America/Toronto",
|
||||
})
|
||||
).toHaveLength(11);
|
||||
});
|
||||
|
||||
it("test buildSlotsWithDateRanges using a 10 mintue interval", async () => {
|
||||
expect(Number(process.env.NEXT_PUBLIC_AVAILABILITY_SCHEDULE_INTERVAL)).toBe(10);
|
||||
expect(
|
||||
getSlots({
|
||||
inviteeDate: dayjs.utc().add(1, "day"),
|
||||
frequency: 10,
|
||||
minimumBookingNotice: 0,
|
||||
eventLength: 10,
|
||||
offsetStart: 0,
|
||||
organizerTimeZone: "America/Toronto",
|
||||
dateRanges: [{ start: dayjs("2023-07-13T00:10:00.000Z"), end: dayjs("2023-07-13T02:00:00.000Z") }],
|
||||
})
|
||||
).toHaveLength(11);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -169,7 +169,7 @@ function buildSlotsWithDateRanges({
|
|||
? range.start
|
||||
: startTimeWithMinNotice;
|
||||
|
||||
let interval = 15;
|
||||
let interval = Number(process.env.NEXT_PUBLIC_AVAILABILITY_SCHEDULE_INTERVAL) || 15;
|
||||
|
||||
const intervalsWithDefinedStartTimes = [60, 30, 20, 10];
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ declare namespace NodeJS {
|
|||
/** @deprecated use `NEXT_PUBLIC_WEBSITE_URL` */
|
||||
readonly NEXT_PUBLIC_APP_URL: string | undefined;
|
||||
readonly NEXTAUTH_SECRET: string | undefined;
|
||||
readonly NEXT_PUBLIC_AVAILABILITY_SCHEDULE_INTERVAL: string | undefined;
|
||||
readonly MS_GRAPH_CLIENT_ID: string | undefined;
|
||||
readonly MS_GRAPH_CLIENT_SECRET: string | undefined;
|
||||
readonly ZOOM_CLIENT_ID: string | undefined;
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
"dependsOn": ["^build"],
|
||||
"outputs": [".next/**"],
|
||||
"env": [
|
||||
"NEXT_PUBLIC_AVAILABILITY_SCHEDULE_INTERVAL",
|
||||
"NEXT_PUBLIC_IS_E2E",
|
||||
"NEXT_PUBLIC_SENTRY_DSN",
|
||||
"NEXT_PUBLIC_STRIPE_PREMIUM_PLAN_PRICE_MONTHLY",
|
||||
|
@ -70,6 +71,7 @@
|
|||
"DATOCMS_WEBHOOK_SECRET",
|
||||
"DATOCMS_PREVIEW_SECRET",
|
||||
"ENVIRONMENT_URL",
|
||||
"NEXT_PUBLIC_AVAILABILITY_SCHEDULE_INTERVAL",
|
||||
"NEXT_PUBLIC_IS_PREMIUM_NEW_PLAN",
|
||||
"NEXT_PUBLIC_STRIPE_FREE_PLAN_PRICE",
|
||||
"NEXT_PUBLIC_STRIPE_PREMIUM_NEW_PLAN_PRICE",
|
||||
|
|
Loading…
Reference in New Issue
Block a user