From 0bb99fc667f5e9c6d68878bbb6e8a29e8cfa5ac9 Mon Sep 17 00:00:00 2001 From: Aldrin <53973174+Dhoni77@users.noreply.github.com> Date: Sat, 30 Sep 2023 03:24:22 +0530 Subject: [PATCH] =?UTF-8?q?refactor:=20=20=20to=20use=20?= =?UTF-8?q?=20to=20navigate=20instead=20of=20r=E2=80=A6=20(#11602)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Peer Richelsen --- .../components/booking/BookingListItem.tsx | 211 +++++++++--------- 1 file changed, 107 insertions(+), 104 deletions(-) diff --git a/apps/web/components/booking/BookingListItem.tsx b/apps/web/components/booking/BookingListItem.tsx index 4cba1243c5..86cbb4daa8 100644 --- a/apps/web/components/booking/BookingListItem.tsx +++ b/apps/web/components/booking/BookingListItem.tsx @@ -1,4 +1,4 @@ -import { useRouter } from "next/navigation"; +import Link from "next/link"; import { useState } from "react"; import type { EventLocationType } from "@calcom/app-store/locations"; @@ -26,11 +26,11 @@ import { DialogFooter, MeetingTimeInTimezones, showToast, - Tooltip, TableActions, TextAreaField, + Tooltip, } from "@calcom/ui"; -import { Check, Clock, MapPin, RefreshCcw, Send, Ban, X, CreditCard } from "@calcom/ui/components/icon"; +import { Ban, Check, Clock, CreditCard, MapPin, RefreshCcw, Send, X } from "@calcom/ui/components/icon"; import useMeQuery from "@lib/hooks/useMeQuery"; @@ -58,7 +58,6 @@ function BookingListItem(booking: BookingItemProps) { i18n: { language }, } = useLocale(); const utils = trpc.useContext(); - const router = useRouter(); const [rejectionReason, setRejectionReason] = useState(""); const [rejectionDialogIsOpen, setRejectionDialogIsOpen] = useState(false); const [chargeCardDialogIsOpen, setChargeCardDialogIsOpen] = useState(false); @@ -259,14 +258,16 @@ function BookingListItem(booking: BookingItemProps) { .concat(booking.recurringInfo?.bookings[BookingStatus.PENDING]) .sort((date1: Date, date2: Date) => date1.getTime() - date2.getTime()); - const onClickTableData = () => { + const buildBookingLink = () => { const urlSearchParams = new URLSearchParams({ allRemainingBookings: isTabRecurring.toString(), }); if (booking.attendees[0]) urlSearchParams.set("email", booking.attendees[0].email); - router.push(`/booking/${booking.uid}?${urlSearchParams.toString()}`); + return `/booking/${booking.uid}?${urlSearchParams.toString()}`; }; + const bookingLink = buildBookingLink(); + const title = booking.title; // To be used after we run query on legacy bookings // const showRecordingsButtons = booking.isRecorded && isPast && isConfirmed; @@ -337,54 +338,11 @@ function BookingListItem(booking: BookingItemProps) { - -
-
{startTime}
-
- {formatTime(booking.startTime, user?.timeFormat, user?.timeZone)} -{" "} - {formatTime(booking.endTime, user?.timeFormat, user?.timeZone)} - -
- {isPending && ( - - {t("unconfirmed")} - - )} - {booking.eventType?.team && ( - - {booking.eventType.team.name} - - )} - {booking.paid && !booking.payment[0] ? ( - - {t("error_collecting_card")} - - ) : booking.paid ? ( - - {booking.payment[0].paymentOption === "HOLD" ? t("card_held") : t("paid")} - - ) : null} - {recurringDates !== undefined && ( -
- -
- )} -
- - - {/* Time and Badges for mobile */} -
-
+ + +
{startTime}
-
+
{formatTime(booking.startTime, user?.timeFormat, user?.timeZone)} -{" "} {formatTime(booking.endTime, user?.timeFormat, user?.timeZone)}
+ {isPending && ( + + {t("unconfirmed")} + + )} + {booking.eventType?.team && ( + + {booking.eventType.team.name} + + )} + {booking.paid && !booking.payment[0] ? ( + + {t("error_collecting_card")} + + ) : booking.paid ? ( + + {booking.payment[0].paymentOption === "HOLD" ? t("card_held") : t("paid")} + + ) : null} + {recurringDates !== undefined && ( +
+ +
+ )}
- - {isPending && ( - - {t("unconfirmed")} - - )} - {booking.eventType?.team && ( - - {booking.eventType.team.name} - - )} - {!!booking?.eventType?.price && !booking.paid && ( - - {t("pending_payment")} - - )} - {recurringDates !== undefined && ( -
- + + + + + {/* Time and Badges for mobile */} +
+
+
{startTime}
+
+ {formatTime(booking.startTime, user?.timeFormat, user?.timeZone)} -{" "} + {formatTime(booking.endTime, user?.timeFormat, user?.timeZone)} + +
- )} -
-
-
- {title} - - - {paymentAppData.enabled && !booking.paid && booking.payment.length && ( - + {isPending && ( + + {t("unconfirmed")} + + )} + {booking.eventType?.team && ( + + {booking.eventType.team.name} + + )} + {!!booking?.eventType?.price && !booking.paid && ( + {t("pending_payment")} )} + {recurringDates !== undefined && ( +
+ +
+ )}
- {booking.description && ( + +
- "{booking.description}" + title={title} + className={classNames( + "max-w-10/12 sm:max-w-56 text-emphasis text-sm font-medium leading-6 md:max-w-full", + isCancelled ? "line-through" : "" + )}> + {title} + + + {paymentAppData.enabled && !booking.paid && booking.payment.length && ( + + {t("pending_payment")} + + )}
- )} - {booking.attendees.length !== 0 && ( - - )} - {isCancelled && booking.rescheduled && ( -
- -
- )} -
+ {booking.description && ( +
+ "{booking.description}" +
+ )} + {booking.attendees.length !== 0 && ( + + )} + {isCancelled && booking.rescheduled && ( +
+ +
+ )} +
+ {isUpcoming && !isCancelled ? (