diff --git a/components/booking/Slots.tsx b/components/booking/Slots.tsx
index 1b4a8bfd21..29ed9e7274 100644
--- a/components/booking/Slots.tsx
+++ b/components/booking/Slots.tsx
@@ -1,10 +1,9 @@
-import { useEffect, useState } from "react";
+import { useState, useEffect } from "react";
import { useRouter } from "next/router";
import getSlots from "../../lib/slots";
import dayjs, { Dayjs } from "dayjs";
import isBetween from "dayjs/plugin/isBetween";
import utc from "dayjs/plugin/utc";
-
dayjs.extend(isBetween);
dayjs.extend(utc);
@@ -12,9 +11,11 @@ type Props = {
eventLength: number;
minimumBookingNotice?: number;
date: Dayjs;
+ workingHours: [];
+ organizerTimeZone: string;
};
-const Slots = ({ eventLength, minimumBookingNotice, date, workingHours, organizerUtcOffset }: Props) => {
+const Slots = ({ eventLength, minimumBookingNotice, date, workingHours, organizerTimeZone }: Props) => {
minimumBookingNotice = minimumBookingNotice || 0;
const router = useRouter();
@@ -48,7 +49,7 @@ const Slots = ({ eventLength, minimumBookingNotice, date, workingHours, organize
inviteeDate: date,
workingHours,
minimumBookingNotice,
- organizerUtcOffset,
+ organizerTimeZone,
});
const timesLengthBeforeConflicts: number = times.length;
diff --git a/lib/slots.ts b/lib/slots.ts
index 3313fbce2f..862e8b145e 100644
--- a/lib/slots.ts
+++ b/lib/slots.ts
@@ -81,9 +81,12 @@ const organizerBoundaries = (
}
}
} else {
- boundaries.push({ lowerBound, upperBound });
+ if (item.days.includes(startDay)) {
+ boundaries.push({ lowerBound, upperBound });
+ }
}
});
+
return boundaries;
};
@@ -116,7 +119,7 @@ const getSlots = ({
workingHours,
organizerTimeZone,
}: GetSlots): Dayjs[] => {
- const startTime = dayjs.utc().isSame(dayjs(inviteeDate), "day")
+ const startTime = dayjs().utcOffset(inviteeDate.utcOffset()).isSame(inviteeDate, "day")
? inviteeDate.hour() * 60 + inviteeDate.minute() + (minimumBookingNotice || 0)
: 0;
diff --git a/pages/[user]/[type].tsx b/pages/[user]/[type].tsx
index 47c40dc5e6..e81812a1e6 100644
--- a/pages/[user]/[type].tsx
+++ b/pages/[user]/[type].tsx
@@ -2,10 +2,10 @@ import { useEffect, useState } from "react";
import { GetServerSideProps } from "next";
import Head from "next/head";
import { ChevronDownIcon, ClockIcon, GlobeIcon } from "@heroicons/react/solid";
-import prisma from "../../lib/prisma";
import { useRouter } from "next/router";
import { Dayjs } from "dayjs";
+import prisma, { whereAndSelect } from "@lib/prisma";
import { collectPageParameters, telemetryEventTypes, useTelemetry } from "../../lib/telemetry";
import AvailableTimes from "../../components/booking/AvailableTimes";
import TimeOptions from "../../components/booking/TimeOptions";
@@ -134,6 +134,7 @@ export default function Type(props): Type {
{
- const user = await prisma.user.findFirst({
- where: {
+ const user = await whereAndSelect(
+ prisma.user.findFirst,
+ {
username: context.query.user.toLowerCase(),
},
- select: {
- id: true,
- username: true,
- name: true,
- email: true,
- bio: true,
- avatar: true,
- eventTypes: true,
- startTime: true,
- timeZone: true,
- endTime: true,
- weekStart: true,
- availability: true,
- hideBranding: true,
- },
- });
+ [
+ "id",
+ "username",
+ "name",
+ "email",
+ "bio",
+ "avatar",
+ "eventTypes",
+ "startTime",
+ "endTime",
+ "timeZone",
+ "weekStart",
+ "availability",
+ "hideBranding",
+ ]
+ );
if (!user) {
return {
@@ -176,22 +178,14 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
};
}
- const eventType = await prisma.eventType.findFirst({
- where: {
+ const eventType = await whereAndSelect(
+ prisma.eventType.findFirst,
+ {
userId: user.id,
- slug: {
- equals: context.query.type,
- },
+ slug: context.query.type,
},
- select: {
- id: true,
- title: true,
- description: true,
- length: true,
- availability: true,
- timeZone: true,
- },
- });
+ ["id", "title", "description", "length", "availability", "timeZone"]
+ );
if (!eventType) {
return {