refactor: use dynamic import in booking page (#7101)
Co-authored-by: zomars <[email protected]>
This commit is contained in:
1 parent
0f76530c11
commit
1fa5e296af
1 file changed
+22
-18
@@ -1,5 +1,6 @@
|
|||||||
import { useAutoAnimate } from "@formkit/auto-animate/react";
|
import { useAutoAnimate } from "@formkit/auto-animate/react";
|
||||||
import { EventType } from "@prisma/client";
|
import { EventType } from "@prisma/client";
|
||||||
|
import dynamic from "next/dynamic";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { useEffect, useMemo, useReducer, useState } from "react";
|
import { useEffect, useMemo, useReducer, useState } from "react";
|
||||||
import { Toaster } from "react-hot-toast";
|
import { Toaster } from "react-hot-toast";
|
||||||
@@ -35,15 +36,16 @@ import { timeZone as localStorageTimeZone } from "@lib/clock";
|
|||||||
import useRouterQuery from "@lib/hooks/useRouterQuery";
|
import useRouterQuery from "@lib/hooks/useRouterQuery";
|
||||||
|
|
||||||
import Gates, { Gate, GateState } from "@components/Gates";
|
import Gates, { Gate, GateState } from "@components/Gates";
|
||||||
import AvailableTimes from "@components/booking/AvailableTimes";
|
|
||||||
import BookingDescription from "@components/booking/BookingDescription";
|
import BookingDescription from "@components/booking/BookingDescription";
|
||||||
import TimeOptions from "@components/booking/TimeOptions";
|
import TimeOptions from "@components/booking/TimeOptions";
|
||||||
import PoweredByCal from "@components/ui/PoweredByCal";
|
|
||||||
|
|
||||||
import type { AvailabilityPageProps } from "../../../pages/[user]/[type]";
|
import type { AvailabilityPageProps } from "../../../pages/[user]/[type]";
|
||||||
import type { DynamicAvailabilityPageProps } from "../../../pages/d/[link]/[slug]";
|
import type { DynamicAvailabilityPageProps } from "../../../pages/d/[link]/[slug]";
|
||||||
import type { AvailabilityTeamPageProps } from "../../../pages/team/[slug]/[type]";
|
import type { AvailabilityTeamPageProps } from "../../../pages/team/[slug]/[type]";
|
||||||
|
|
||||||
|
const PoweredByCal = dynamic(() => import("@components/ui/PoweredByCal"));
|
||||||
|
const AvailableTimes = dynamic(() => import("@components/booking/AvailableTimes"));
|
||||||
|
|
||||||
const useSlots = ({
|
const useSlots = ({
|
||||||
eventTypeId,
|
eventTypeId,
|
||||||
eventTypeSlug,
|
eventTypeSlug,
|
||||||
@@ -197,22 +199,24 @@ const SlotPicker = ({
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<div ref={slotPickerRef}>
|
<div ref={slotPickerRef}>
|
||||||
<AvailableTimes
|
{selectedDate ? (
|
||||||
isLoading={isLoadingSelectedDateSlots}
|
<AvailableTimes
|
||||||
slots={
|
isLoading={isLoadingSelectedDateSlots}
|
||||||
selectedDate &&
|
slots={
|
||||||
(selectedDateSlots[selectedDate.format("YYYY-MM-DD")] ||
|
selectedDate &&
|
||||||
monthSlots[selectedDate.format("YYYY-MM-DD")])
|
(selectedDateSlots[selectedDate.format("YYYY-MM-DD")] ||
|
||||||
}
|
monthSlots[selectedDate.format("YYYY-MM-DD")])
|
||||||
date={selectedDate}
|
}
|
||||||
timeFormat={timeFormat}
|
date={selectedDate}
|
||||||
onTimeFormatChange={onTimeFormatChange}
|
timeFormat={timeFormat}
|
||||||
eventTypeId={eventType.id}
|
onTimeFormatChange={onTimeFormatChange}
|
||||||
eventTypeSlug={eventType.slug}
|
eventTypeId={eventType.id}
|
||||||
seatsPerTimeSlot={seatsPerTimeSlot}
|
eventTypeSlug={eventType.slug}
|
||||||
recurringCount={recurringEventCount}
|
seatsPerTimeSlot={seatsPerTimeSlot}
|
||||||
ethSignature={ethSignature}
|
recurringCount={recurringEventCount}
|
||||||
/>
|
ethSignature={ethSignature}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in new issue
Block a user