Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
89e6198
Extracted UI related logic on the DatePicker, stripped out all logic
emrysal Apr 23, 2022
c278801
Merge branch 'main' into feature/datepicker-refactor
PeerRich Apr 24, 2022
7a92d67
Merge branch 'main' into feature/datepicker-refactor
kodiakhq[bot] May 9, 2022
dba86d3
Merge branch 'main' into feature/datepicker-refactor
kodiakhq[bot] May 9, 2022
c932d2b
Merge branch 'main' into feature/datepicker-refactor
kodiakhq[bot] May 9, 2022
171e557
Merge branch 'main' into feature/datepicker-refactor
kodiakhq[bot] May 9, 2022
f376251
Merge branch 'main' into feature/datepicker-refactor
kodiakhq[bot] May 9, 2022
00bbc6c
Merge branch 'main' into feature/datepicker-refactor
kodiakhq[bot] May 9, 2022
0043de5
Merge branch 'main' into feature/datepicker-refactor
kodiakhq[bot] May 9, 2022
c7e8151
Merge branch 'main' into feature/datepicker-refactor
kodiakhq[bot] May 9, 2022
2170fea
In between push concluding merge
emrysal Jun 7, 2022
d529cd3
wip
emrysal Jun 9, 2022
6e64e65
Merge conflicts fixed
emrysal Jun 10, 2022
799d26c
fixed small regression due to merge
emrysal Jun 10, 2022
2d4f29c
Fix alignment of the chevrons
emrysal Jun 10, 2022
a84b5cb
Added isToday dot, added onMonthChange so we can fetch this month slots
emrysal Jun 11, 2022
244c137
Conclude merge with zomars availability changes
emrysal Jun 12, 2022
3dc0ed1
Added includedDates to inverse excludedDates
emrysal Jun 13, 2022
124d62f
removed trpcState
emrysal Jun 13, 2022
fa211e9
Improvements to the state
emrysal Jun 13, 2022
cd54677
All params are now dynamic
emrysal Jun 13, 2022
2a50ac7
This builds the flat map so not all paths block on every new build
emrysal Jun 13, 2022
8cbcef9
Added requiresConfirmation
emrysal Jun 13, 2022
9a261c8
Correctly take into account getFilteredTimes to make the calendar fun…
emrysal Jun 14, 2022
7725614
Rewritten team availability, seems to work
emrysal Jun 14, 2022
2f4df18
Circumvent i18n flicker by showing the loader instead
emrysal Jun 15, 2022
33c888f
'You can remove this code. Its not being used now' - Hariom
emrysal Jun 15, 2022
33abde4
Nailed a persistent little bug, new Date() caused the current day to …
emrysal Jun 15, 2022
a0e4e35
TS fixes
emrysal Jun 15, 2022
459cfd2
Fix some eventType details in AvailableTimes
emrysal Jun 15, 2022
c7504bd
'5 / 6 Seats Available' instead of '6 / Seats Available'
emrysal Jun 15, 2022
488ffcf
More type fixes
emrysal Jun 15, 2022
8a8b40d
Merged main, replicating to ensure order
emrysal Jun 15, 2022
a9e1114
Removed unrelated merge artifact
emrysal Jun 15, 2022
caabf3a
Use WEBAPP_URL instead of hardcoded
emrysal Jun 15, 2022
a989f53
Next round of TS fixes
emrysal Jun 15, 2022
671f530
I believe this was mistyped
emrysal Jun 15, 2022
79575a1
Temporarily disabled rescheduling 'this is when you originally schedu…
emrysal Jun 15, 2022
3df09c4
Merge branch 'main' into feature/booking-page-refactor
emrysal Jun 15, 2022
cba7e0e
Sorting some dead code
emrysal Jun 15, 2022
e0f6db2
Merge branch 'feature/booking-page-refactor' of github.com:calcom/cal…
emrysal Jun 15, 2022
f89316f
Merge branch 'main' into feature/booking-page-refactor
PeerRich Jun 15, 2022
41bf129
This page has a lot of red, not all related to this PR
emrysal Jun 15, 2022
cf0e417
Merge branch 'feature/booking-page-refactor' of github.com:calcom/cal…
emrysal Jun 15, 2022
997d9d1
Merge branch 'main' into feature/booking-page-refactor
zomars Jun 15, 2022
e6f0ee8
Merge branch 'main' into feature/booking-page-refactor
zomars Jun 15, 2022
9d6bf9f
A PR to your PR (#3067)
zomars Jun 15, 2022
264d156
Fixed border position (transparent border) to prevent dot from jumpin…
emrysal Jun 15, 2022
a46c6e7
Disabled style nitpicks
zomars Jun 15, 2022
329c4f7
Delete useSlots.ts
emrysal Jun 15, 2022
ead7a50
Merge branch 'main' into feature/booking-page-refactor
emrysal Jun 15, 2022
9276d8d
Unlock DatePicker locale
emrysal Jun 15, 2022
241cce9
Adds mini spinner to DatePicker
zomars Jun 15, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 11 additions & 49 deletions apps/web/components/booking/AvailableTimes.tsx
Original file line number Diff line number Diff line change
@@ -1,66 +1,44 @@
import { ExclamationIcon } from "@heroicons/react/solid";
import { SchedulingType } from "@prisma/client";
import dayjs, { Dayjs } from "dayjs";
import Link from "next/link";
import { useRouter } from "next/router";
import React, { FC, useEffect, useState } from "react";
import { FC, useEffect, useState } from "react";

import { useLocale } from "@calcom/lib/hooks/useLocale";
import { nameOfDay } from "@calcom/lib/weekday";

import classNames from "@lib/classNames";
import { timeZone } from "@lib/clock";
import { useLocale } from "@lib/hooks/useLocale";
import { useSlots } from "@lib/hooks/useSlots";

import Loader from "@components/Loader";
import type { Slot } from "@server/routers/viewer/slots";

type AvailableTimesProps = {
timeFormat: string;
minimumBookingNotice: number;
beforeBufferTime: number;
afterBufferTime: number;
eventTypeId: number;
eventLength: number;
recurringCount: number | undefined;
eventTypeSlug: string;
slotInterval: number | null;
date: Dayjs;
users: {
username: string | null;
}[];
schedulingType: SchedulingType | null;
seatsPerTimeSlot?: number | null;
slots?: Slot[];
};

const AvailableTimes: FC<AvailableTimesProps> = ({
slots = [],
date,
eventLength,
eventTypeId,
eventTypeSlug,
slotInterval,
minimumBookingNotice,
recurringCount,
timeFormat,
users,
schedulingType,
beforeBufferTime,
afterBufferTime,
seatsPerTimeSlot,
}) => {
const { t, i18n } = useLocale();
const router = useRouter();
const { rescheduleUid } = router.query;
const { slots, loading, error } = useSlots({
date,
slotInterval,
eventLength,
schedulingType,
users,
minimumBookingNotice,
beforeBufferTime,
afterBufferTime,
eventTypeId,
});

const [brand, setBrand] = useState("#292929");

Expand All @@ -80,8 +58,7 @@ const AvailableTimes: FC<AvailableTimesProps> = ({
</span>
</div>
<div className="flex-grow overflow-y-auto md:h-[364px]">
{!loading &&
slots?.length > 0 &&
{slots?.length > 0 &&
slots.map((slot) => {
type BookingURL = {
pathname: string;
Expand All @@ -91,7 +68,7 @@ const AvailableTimes: FC<AvailableTimesProps> = ({
pathname: "book",
query: {
...router.query,
date: slot.time.format(),
date: dayjs(slot.time).format(),
type: eventTypeId,
slug: eventTypeSlug,
/** Treat as recurring only when a count exist and it's not a rescheduling workflow */
Expand All @@ -113,15 +90,15 @@ const AvailableTimes: FC<AvailableTimesProps> = ({
}

return (
<div key={slot.time.format()}>
<div key={dayjs(slot.time).format()}>
{/* Current there is no way to disable Next.js Links */}
{seatsPerTimeSlot && slot.attendees && slot.attendees >= seatsPerTimeSlot ? (
<div
className={classNames(
"text-primary-500 mb-2 block rounded-sm border bg-white py-4 font-medium opacity-25 dark:border-transparent dark:bg-gray-600 dark:text-neutral-200 ",
brand === "#fff" || brand === "#ffffff" ? "border-brandcontrast" : "border-brand"
)}>
{slot.time.format(timeFormat)}
{dayjs(slot.time).tz(timeZone()).format(timeFormat)}
{!!seatsPerTimeSlot && <p className={`text-sm`}>{t("booking_full")}</p>}
</div>
) : (
Expand All @@ -132,7 +109,7 @@ const AvailableTimes: FC<AvailableTimesProps> = ({
brand === "#fff" || brand === "#ffffff" ? "border-brandcontrast" : "border-brand"
)}
data-testid="time">
{dayjs.tz(slot.time, timeZone()).format(timeFormat)}
{dayjs(slot.time).tz(timeZone()).format(timeFormat)}
{!!seatsPerTimeSlot && (
<p
className={`${
Expand All @@ -152,26 +129,11 @@ const AvailableTimes: FC<AvailableTimesProps> = ({
</div>
);
})}
{!loading && !error && !slots.length && (
{!slots.length && (
<div className="-mt-4 flex h-full w-full flex-col content-center items-center justify-center">
<h1 className="my-6 text-xl text-black dark:text-white">{t("all_booked_today")}</h1>
</div>
)}

{loading && <Loader />}

{error && (
<div className="border-l-4 border-yellow-400 bg-yellow-50 p-4">
<div className="flex">
<div className="flex-shrink-0">
<ExclamationIcon className="h-5 w-5 text-yellow-400" aria-hidden="true" />
</div>
<div className="ltr:ml-3 rtl:mr-3">
<p className="text-sm text-yellow-700">{t("slots_load_fail")}</p>
</div>
</div>
</div>
)}
</div>
</div>
);
Expand Down
10 changes: 2 additions & 8 deletions apps/web/components/booking/DatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,15 +249,9 @@ function DatePicker({
day.disabled ? { ...disabledDateButtonEmbedStyles } : { ...enabledDateButtonEmbedStyles }
}
className={classNames(
"absolute top-0 left-0 right-0 bottom-0 mx-auto w-full rounded-sm text-center",
"hover:border-brand hover:border dark:hover:border-white",
day.disabled
? "text-bookinglighter cursor-default font-light hover:border-0"
: "font-medium",
"hover:border-brand disabled:text-bookinglighter absolute top-0 left-0 right-0 bottom-0 mx-auto w-full rounded-sm text-center font-medium hover:border disabled:cursor-default disabled:font-light disabled:hover:border-0 dark:hover:border-white",
date && date.isSame(browsingDate.date(day.date), "day")
? "bg-brand text-brandcontrast dark:bg-darkmodebrand dark:text-darkmodebrandcontrast"
: !day.disabled
? " bg-gray-100 dark:bg-gray-600 dark:text-white"
? "bg-brand text-brandcontrast dark:bg-darkmodebrand dark:text-darkmodebrandcontrast disabled:bg-gray-100 disabled:dark:bg-gray-600 disabled:dark:text-white"
: ""
)}
data-testid="day"
Expand Down
Loading