From d138f59264b0b10ac47e66d9fc72906d662d34c1 Mon Sep 17 00:00:00 2001 From: KATT Date: Fri, 19 Nov 2021 11:38:42 +0100 Subject: [PATCH] tweak --- components/booking/DatePicker.tsx | 61 ++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 22 deletions(-) diff --git a/components/booking/DatePicker.tsx b/components/booking/DatePicker.tsx index bc207579a2..87f8722500 100644 --- a/components/booking/DatePicker.tsx +++ b/components/booking/DatePicker.tsx @@ -4,10 +4,12 @@ import dayjs, { Dayjs } from "dayjs"; // Then, include dayjs-business-time import dayjsBusinessTime from "dayjs-business-time"; import utc from "dayjs/plugin/utc"; +import Link from "next/link"; import { useEffect, useState } from "react"; import classNames from "@lib/classNames"; import { useLocale } from "@lib/hooks/useLocale"; +import { useRouterAsPath } from "@lib/hooks/useRouterPath"; import getSlots from "@lib/slots"; import { WorkingHours } from "@lib/types/schedule"; @@ -16,7 +18,6 @@ dayjs.extend(utc); type DatePickerProps = { weekStart: string; - onDatePicked: (pickedDate: Dayjs) => void; workingHours: WorkingHours[]; eventLength: number; date: Dayjs | null; @@ -30,7 +31,6 @@ type DatePickerProps = { function DatePicker({ weekStart, - onDatePicked, workingHours, eventLength, date, @@ -43,7 +43,7 @@ function DatePicker({ }: DatePickerProps): JSX.Element { const { t } = useLocale(); const [days, setDays] = useState<({ disabled: boolean; date: number } | null)[]>([]); - + const asPath = useRouterAsPath(); const [selectedMonth, setSelectedMonth] = useState( date ? periodType === PeriodType.RANGE @@ -194,25 +194,42 @@ function DatePicker({ {day === null ? (
) : ( - + + { + if (day.disabled) { + e.preventDefault(); + } + }} + data-testid="day" + data-disabled={day.disabled}> + + {day.date} + + + )}
))}