From c6ff3dca4a2d549815e293ee87b3fedd2c31def3 Mon Sep 17 00:00:00 2001 From: Nafees Nazik <84864519+G3root@users.noreply.github.com> Date: Fri, 17 Mar 2023 13:42:51 +0530 Subject: [PATCH] feat: take locale relavant while formatting date in /bookings (#7691) * feat: use locale while formatting * fix: tooltip content --- apps/web/components/booking/BookingListItem.tsx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/apps/web/components/booking/BookingListItem.tsx b/apps/web/components/booking/BookingListItem.tsx index 43588e6967..b597347628 100644 --- a/apps/web/components/booking/BookingListItem.tsx +++ b/apps/web/components/booking/BookingListItem.tsx @@ -46,7 +46,10 @@ function BookingListItem(booking: BookingItemProps) { // Get user so we can determine 12/24 hour format preferences const query = useMeQuery(); const user = query.data; - const { t } = useLocale(); + const { + t, + i18n: { language }, + } = useLocale(); const utils = trpc.useContext(); const router = useRouter(); const [rejectionReason, setRejectionReason] = useState(""); @@ -195,7 +198,9 @@ function BookingListItem(booking: BookingItemProps) { ); }; - const startTime = dayjs(booking.startTime).format(isUpcoming ? "ddd, D MMM" : "D MMMM YYYY"); + const startTime = dayjs(booking.startTime) + .locale(language) + .format(isUpcoming ? "ddd, D MMM" : "D MMMM YYYY"); const [isOpenRescheduleDialog, setIsOpenRescheduleDialog] = useState(false); const [isOpenSetLocationDialog, setIsOpenLocationDialog] = useState(false); const setLocationMutation = trpc.viewer.bookings.editLocation.useMutation({ @@ -431,7 +436,10 @@ const RecurringBookingsTooltip = ({ booking, recurringDates }: RecurringBookings // Get user so we can determine 12/24 hour format preferences const query = useMeQuery(); const user = query.data; - const { t } = useLocale(); + const { + t, + i18n: { language }, + } = useLocale(); const now = new Date(); const recurringCount = recurringDates.filter((date) => { return ( @@ -461,7 +469,7 @@ const RecurringBookingsTooltip = ({ booking, recurringDates }: RecurringBookings

{formatTime(aDate, user?.timeFormat, user?.timeZone)} {" - "} - {dayjs(aDate).format("D MMMM YYYY")} + {dayjs(aDate).locale(language).format("D MMMM YYYY")}

); })}>