2022-05-18 21:05:49 +00:00
|
|
|
import {
|
|
|
|
BanIcon,
|
|
|
|
CheckIcon,
|
|
|
|
ClockIcon,
|
2022-05-27 23:27:41 +00:00
|
|
|
LocationMarkerIcon,
|
2022-05-18 21:05:49 +00:00
|
|
|
PaperAirplaneIcon,
|
|
|
|
PencilAltIcon,
|
|
|
|
XIcon,
|
|
|
|
} from "@heroicons/react/outline";
|
2022-05-05 21:16:25 +00:00
|
|
|
import { RefreshIcon } from "@heroicons/react/solid";
|
2021-09-30 10:46:39 +00:00
|
|
|
import { BookingStatus } from "@prisma/client";
|
|
|
|
import dayjs from "dayjs";
|
2022-05-18 21:05:49 +00:00
|
|
|
import { useRouter } from "next/router";
|
2022-02-09 18:25:58 +00:00
|
|
|
import { useState } from "react";
|
2021-09-30 10:46:39 +00:00
|
|
|
import { useMutation } from "react-query";
|
|
|
|
|
2022-06-10 00:32:34 +00:00
|
|
|
import { parseRecurringEvent } from "@calcom/lib";
|
2022-04-14 21:25:24 +00:00
|
|
|
import classNames from "@calcom/lib/classNames";
|
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
2022-05-27 23:27:41 +00:00
|
|
|
import showToast from "@calcom/lib/notification";
|
2022-06-10 20:38:06 +00:00
|
|
|
import { getEveryFreqFor } from "@calcom/lib/recurringStrings";
|
2022-03-16 23:36:43 +00:00
|
|
|
import Button from "@calcom/ui/Button";
|
|
|
|
import { Dialog, DialogClose, DialogContent, DialogFooter, DialogHeader } from "@calcom/ui/Dialog";
|
2022-05-05 21:16:25 +00:00
|
|
|
import { Tooltip } from "@calcom/ui/Tooltip";
|
2022-03-16 23:36:43 +00:00
|
|
|
import { TextArea } from "@calcom/ui/form/fields";
|
|
|
|
|
2021-09-30 10:46:39 +00:00
|
|
|
import { HttpError } from "@lib/core/http/error";
|
2022-05-04 21:05:57 +00:00
|
|
|
import useMeQuery from "@lib/hooks/useMeQuery";
|
2022-06-03 11:28:33 +00:00
|
|
|
import { linkValueToString } from "@lib/linkValueToString";
|
2022-05-27 23:27:41 +00:00
|
|
|
import { LocationType } from "@lib/location";
|
2022-05-05 21:16:25 +00:00
|
|
|
import { parseRecurringDates } from "@lib/parseDate";
|
2022-05-18 21:05:49 +00:00
|
|
|
import { inferQueryInput, inferQueryOutput, trpc } from "@lib/trpc";
|
2021-09-30 10:46:39 +00:00
|
|
|
|
2022-05-27 23:27:41 +00:00
|
|
|
import { EditLocationDialog } from "@components/dialog/EditLocationDialog";
|
2022-04-14 21:25:24 +00:00
|
|
|
import { RescheduleDialog } from "@components/dialog/RescheduleDialog";
|
2022-02-11 22:20:10 +00:00
|
|
|
import TableActions, { ActionType } from "@components/ui/TableActions";
|
2021-09-30 10:46:39 +00:00
|
|
|
|
2022-05-05 21:16:25 +00:00
|
|
|
type BookingListingStatus = inferQueryInput<"viewer.bookings">["status"];
|
|
|
|
|
2021-12-17 16:58:23 +00:00
|
|
|
type BookingItem = inferQueryOutput<"viewer.bookings">["bookings"][number];
|
2021-09-30 10:46:39 +00:00
|
|
|
|
2022-05-05 21:16:25 +00:00
|
|
|
type BookingItemProps = BookingItem & {
|
|
|
|
listingStatus: BookingListingStatus;
|
|
|
|
recurringCount?: number;
|
|
|
|
};
|
|
|
|
|
|
|
|
function BookingListItem(booking: BookingItemProps) {
|
2022-02-28 16:24:47 +00:00
|
|
|
// Get user so we can determine 12/24 hour format preferences
|
|
|
|
const query = useMeQuery();
|
|
|
|
const user = query.data;
|
2021-10-25 13:05:21 +00:00
|
|
|
const { t, i18n } = useLocale();
|
2021-09-30 10:46:39 +00:00
|
|
|
const utils = trpc.useContext();
|
2022-05-18 21:05:49 +00:00
|
|
|
const router = useRouter();
|
2022-02-09 18:25:58 +00:00
|
|
|
const [rejectionReason, setRejectionReason] = useState<string>("");
|
|
|
|
const [rejectionDialogIsOpen, setRejectionDialogIsOpen] = useState(false);
|
2021-09-30 10:46:39 +00:00
|
|
|
const mutation = useMutation(
|
|
|
|
async (confirm: boolean) => {
|
2022-05-05 21:16:25 +00:00
|
|
|
let body = {
|
|
|
|
id: booking.id,
|
|
|
|
confirmed: confirm,
|
|
|
|
language: i18n.language,
|
|
|
|
reason: rejectionReason,
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* Only pass down the recurring event id when we need to confirm the entire series, which happens in
|
2022-06-10 20:38:06 +00:00
|
|
|
* the "Recurring" tab, to support confirming discretionally in the "Recurring" tab.
|
2022-05-05 21:16:25 +00:00
|
|
|
*/
|
2022-06-10 20:38:06 +00:00
|
|
|
if (booking.listingStatus === "recurring" && booking.recurringEventId !== null) {
|
2022-05-05 21:16:25 +00:00
|
|
|
body = Object.assign({}, body, { recurringEventId: booking.recurringEventId });
|
|
|
|
}
|
2021-09-30 10:46:39 +00:00
|
|
|
const res = await fetch("/api/book/confirm", {
|
|
|
|
method: "PATCH",
|
2022-05-05 21:16:25 +00:00
|
|
|
body: JSON.stringify(body),
|
2021-09-30 10:46:39 +00:00
|
|
|
headers: {
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
},
|
|
|
|
});
|
|
|
|
if (!res.ok) {
|
|
|
|
throw new HttpError({ statusCode: res.status });
|
|
|
|
}
|
2022-05-27 23:27:41 +00:00
|
|
|
setRejectionDialogIsOpen(false);
|
2021-09-30 10:46:39 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
async onSettled() {
|
2021-10-12 18:59:52 +00:00
|
|
|
await utils.invalidateQueries(["viewer.bookings"]);
|
2021-09-30 10:46:39 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
);
|
|
|
|
const isUpcoming = new Date(booking.endTime) >= new Date();
|
|
|
|
const isCancelled = booking.status === BookingStatus.CANCELLED;
|
2022-06-06 16:54:47 +00:00
|
|
|
const isConfirmed = booking.status === BookingStatus.ACCEPTED;
|
|
|
|
const isRejected = booking.status === BookingStatus.REJECTED;
|
|
|
|
const isPending = booking.status === BookingStatus.PENDING;
|
2021-09-30 10:46:39 +00:00
|
|
|
|
2021-10-12 13:11:33 +00:00
|
|
|
const pendingActions: ActionType[] = [
|
2021-09-30 10:46:39 +00:00
|
|
|
{
|
|
|
|
id: "reject",
|
2022-05-05 21:16:25 +00:00
|
|
|
label:
|
2022-06-10 20:38:06 +00:00
|
|
|
booking.listingStatus === "recurring" && booking.recurringEventId !== null
|
2022-05-05 21:16:25 +00:00
|
|
|
? t("reject_all")
|
|
|
|
: t("reject"),
|
2022-05-27 23:27:41 +00:00
|
|
|
onClick: () => {
|
2022-05-18 21:05:49 +00:00
|
|
|
setRejectionDialogIsOpen(true);
|
|
|
|
},
|
2021-09-30 10:46:39 +00:00
|
|
|
icon: BanIcon,
|
|
|
|
disabled: mutation.isLoading,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "confirm",
|
2022-05-05 21:16:25 +00:00
|
|
|
label:
|
2022-06-10 20:38:06 +00:00
|
|
|
booking.listingStatus === "recurring" && booking.recurringEventId !== null
|
2022-05-05 21:16:25 +00:00
|
|
|
? t("confirm_all")
|
|
|
|
: t("confirm"),
|
2022-05-27 23:27:41 +00:00
|
|
|
onClick: () => {
|
2022-05-18 21:05:49 +00:00
|
|
|
mutation.mutate(true);
|
|
|
|
},
|
2021-09-30 10:46:39 +00:00
|
|
|
icon: CheckIcon,
|
|
|
|
disabled: mutation.isLoading,
|
|
|
|
color: "primary",
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2022-06-10 20:38:06 +00:00
|
|
|
let bookedActions: ActionType[] = [
|
2021-09-30 10:46:39 +00:00
|
|
|
{
|
|
|
|
id: "cancel",
|
2022-06-10 20:38:06 +00:00
|
|
|
label:
|
|
|
|
booking.listingStatus === "recurring" && booking.recurringEventId !== null
|
|
|
|
? t("cancel_all_remaining")
|
|
|
|
: t("cancel"),
|
2021-09-30 10:46:39 +00:00
|
|
|
href: `/cancel/${booking.uid}`,
|
|
|
|
icon: XIcon,
|
|
|
|
},
|
|
|
|
{
|
2022-05-27 23:27:41 +00:00
|
|
|
id: "edit_booking",
|
|
|
|
label: t("edit_booking"),
|
|
|
|
icon: PencilAltIcon,
|
2022-04-14 21:25:24 +00:00
|
|
|
actions: [
|
|
|
|
{
|
2022-05-27 23:27:41 +00:00
|
|
|
id: "reschedule",
|
|
|
|
icon: ClockIcon,
|
|
|
|
label: t("reschedule_booking"),
|
2022-04-14 21:25:24 +00:00
|
|
|
href: `/reschedule/${booking.uid}`,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "reschedule_request",
|
2022-05-27 23:27:41 +00:00
|
|
|
icon: PaperAirplaneIcon,
|
|
|
|
iconClassName: "rotate-45 w-[18px] -ml-[2px]",
|
2022-04-14 21:25:24 +00:00
|
|
|
label: t("send_reschedule_request"),
|
2022-05-27 23:27:41 +00:00
|
|
|
onClick: () => {
|
2022-05-18 21:05:49 +00:00
|
|
|
setIsOpenRescheduleDialog(true);
|
|
|
|
},
|
2022-04-14 21:25:24 +00:00
|
|
|
},
|
2022-05-27 23:27:41 +00:00
|
|
|
{
|
|
|
|
id: "change_location",
|
|
|
|
label: t("edit_location"),
|
|
|
|
onClick: () => {
|
|
|
|
setIsOpenLocationDialog(true);
|
|
|
|
},
|
|
|
|
icon: LocationMarkerIcon,
|
|
|
|
},
|
2022-04-14 21:25:24 +00:00
|
|
|
],
|
2021-09-30 10:46:39 +00:00
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2022-06-10 20:38:06 +00:00
|
|
|
if (booking.listingStatus === "recurring" && booking.recurringEventId !== null) {
|
|
|
|
bookedActions = bookedActions.filter((action) => action.id !== "edit_booking");
|
|
|
|
}
|
|
|
|
|
2022-04-14 21:25:24 +00:00
|
|
|
const RequestSentMessage = () => {
|
|
|
|
return (
|
|
|
|
<div className="ml-1 mr-8 flex text-gray-500" data-testid="request_reschedule_sent">
|
|
|
|
<PaperAirplaneIcon className="-mt-[1px] w-4 rotate-45" />
|
|
|
|
<p className="ml-2 ">{t("reschedule_request_sent")}</p>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
2021-09-30 10:46:39 +00:00
|
|
|
|
2022-04-14 21:25:24 +00:00
|
|
|
const startTime = dayjs(booking.startTime).format(isUpcoming ? "ddd, D MMM" : "D MMMM YYYY");
|
|
|
|
const [isOpenRescheduleDialog, setIsOpenRescheduleDialog] = useState(false);
|
2022-05-27 23:27:41 +00:00
|
|
|
const [isOpenSetLocationDialog, setIsOpenLocationDialog] = useState(false);
|
|
|
|
const setLocationMutation = trpc.useMutation("viewer.bookings.editLocation", {
|
|
|
|
onSuccess: () => {
|
|
|
|
showToast(t("location_updated"), "success");
|
|
|
|
setIsOpenLocationDialog(false);
|
|
|
|
utils.invalidateQueries("viewer.bookings");
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
const saveLocation = (newLocationType: LocationType, details: { [key: string]: string }) => {
|
|
|
|
let newLocation = newLocationType as string;
|
|
|
|
if (
|
|
|
|
newLocationType === LocationType.InPerson ||
|
|
|
|
newLocationType === LocationType.Link ||
|
|
|
|
newLocationType === LocationType.UserPhone
|
|
|
|
) {
|
|
|
|
newLocation = details[Object.keys(details)[0]];
|
|
|
|
}
|
|
|
|
setLocationMutation.mutate({ bookingId: booking.id, newLocation });
|
|
|
|
};
|
2022-05-05 21:16:25 +00:00
|
|
|
|
2022-06-10 20:38:06 +00:00
|
|
|
// Calculate the booking date(s) and setup recurring event data to show
|
2022-05-05 21:16:25 +00:00
|
|
|
let recurringStrings: string[] = [];
|
2022-06-10 20:38:06 +00:00
|
|
|
let recurringDates: Date[] = [];
|
|
|
|
const today = new Date();
|
|
|
|
if (booking.recurringCount && booking.eventType.recurringEvent?.freq !== undefined) {
|
|
|
|
[recurringStrings, recurringDates] = parseRecurringDates(
|
2022-05-05 21:16:25 +00:00
|
|
|
{
|
|
|
|
startDate: booking.startTime,
|
2022-06-10 00:32:34 +00:00
|
|
|
recurringEvent: parseRecurringEvent(booking.eventType.recurringEvent),
|
2022-05-05 21:16:25 +00:00
|
|
|
recurringCount: booking.recurringCount,
|
|
|
|
},
|
|
|
|
i18n
|
|
|
|
);
|
2022-06-10 20:38:06 +00:00
|
|
|
if (booking.status === BookingStatus.PENDING) {
|
|
|
|
// Only take into consideration next up instances if booking is confirmed
|
|
|
|
recurringDates = recurringDates.filter((aDate) => aDate >= today);
|
|
|
|
recurringStrings = recurringDates.map((_, key) => recurringStrings[key]);
|
|
|
|
}
|
2022-05-05 21:16:25 +00:00
|
|
|
}
|
2022-05-18 21:05:49 +00:00
|
|
|
|
2022-06-03 11:28:33 +00:00
|
|
|
let location = booking.location || "";
|
|
|
|
|
|
|
|
if (location.includes("integration")) {
|
|
|
|
if (booking.status === BookingStatus.CANCELLED || booking.status === BookingStatus.REJECTED) {
|
|
|
|
location = t("web_conference");
|
2022-06-06 16:54:47 +00:00
|
|
|
} else if (isConfirmed) {
|
2022-06-03 11:28:33 +00:00
|
|
|
location = linkValueToString(booking.location, t);
|
|
|
|
} else {
|
|
|
|
location = t("web_conferencing_details_to_follow");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-27 23:27:41 +00:00
|
|
|
const onClick = () => {
|
|
|
|
router.push({
|
|
|
|
pathname: "/success",
|
|
|
|
query: {
|
|
|
|
date: booking.startTime,
|
2022-06-06 09:41:11 +00:00
|
|
|
// TODO: Booking when fetched should have id 0 already(for Dynamic Events).
|
|
|
|
type: booking.eventType.id || 0,
|
2022-05-27 23:27:41 +00:00
|
|
|
eventSlug: booking.eventType.slug,
|
|
|
|
user: user?.username || "",
|
2022-05-30 18:17:50 +00:00
|
|
|
name: booking.attendees[0] ? booking.attendees[0].name : undefined,
|
|
|
|
email: booking.attendees[0] ? booking.attendees[0].email : undefined,
|
2022-06-03 11:28:33 +00:00
|
|
|
location: location,
|
2022-05-27 23:27:41 +00:00
|
|
|
eventName: booking.eventType.eventName || "",
|
|
|
|
bookingId: booking.id,
|
|
|
|
recur: booking.recurringEventId,
|
2022-06-06 16:54:47 +00:00
|
|
|
reschedule: isConfirmed,
|
2022-05-30 18:17:50 +00:00
|
|
|
listingStatus: booking.listingStatus,
|
|
|
|
status: booking.status,
|
2022-05-27 23:27:41 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
2021-09-30 10:46:39 +00:00
|
|
|
return (
|
2022-02-09 18:25:58 +00:00
|
|
|
<>
|
2022-04-14 21:25:24 +00:00
|
|
|
<RescheduleDialog
|
|
|
|
isOpenDialog={isOpenRescheduleDialog}
|
|
|
|
setIsOpenDialog={setIsOpenRescheduleDialog}
|
|
|
|
bookingUId={booking.uid}
|
|
|
|
/>
|
2022-05-27 23:27:41 +00:00
|
|
|
<EditLocationDialog
|
|
|
|
booking={booking}
|
|
|
|
saveLocation={saveLocation}
|
|
|
|
isOpenDialog={isOpenSetLocationDialog}
|
|
|
|
setShowLocationModal={setIsOpenLocationDialog}
|
|
|
|
/>
|
2022-04-14 21:25:24 +00:00
|
|
|
|
|
|
|
{/* NOTE: Should refactor this dialog component as is being rendered multiple times */}
|
2022-02-09 18:25:58 +00:00
|
|
|
<Dialog open={rejectionDialogIsOpen} onOpenChange={setRejectionDialogIsOpen}>
|
|
|
|
<DialogContent>
|
|
|
|
<DialogHeader title={t("rejection_reason_title")} />
|
|
|
|
|
|
|
|
<p className="-mt-4 text-sm text-gray-500">{t("rejection_reason_description")}</p>
|
|
|
|
<p className="mt-6 mb-2 text-sm font-bold text-black">
|
|
|
|
{t("rejection_reason")}
|
|
|
|
<span className="font-normal text-gray-500"> (Optional)</span>
|
|
|
|
</p>
|
|
|
|
<TextArea
|
|
|
|
name={t("rejection_reason")}
|
|
|
|
value={rejectionReason}
|
|
|
|
onChange={(e) => setRejectionReason(e.target.value)}
|
|
|
|
className="mb-5 sm:mb-6"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<DialogFooter>
|
|
|
|
<DialogClose>
|
|
|
|
<Button color="secondary">{t("cancel")}</Button>
|
|
|
|
</DialogClose>
|
|
|
|
|
|
|
|
<Button
|
|
|
|
disabled={mutation.isLoading}
|
|
|
|
onClick={() => {
|
|
|
|
mutation.mutate(false);
|
|
|
|
}}>
|
|
|
|
{t("rejection_confirmation")}
|
|
|
|
</Button>
|
|
|
|
</DialogFooter>
|
|
|
|
</DialogContent>
|
|
|
|
</Dialog>
|
|
|
|
|
2022-05-27 23:27:41 +00:00
|
|
|
<tr className="flex hover:bg-neutral-50">
|
2022-06-10 20:38:06 +00:00
|
|
|
<td className="hidden align-top ltr:pl-6 rtl:pr-6 sm:table-cell sm:w-64" onClick={onClick}>
|
2022-05-27 23:27:41 +00:00
|
|
|
<div className="cursor-pointer py-4">
|
|
|
|
<div className="text-sm leading-6 text-gray-900">{startTime}</div>
|
|
|
|
<div className="text-sm text-gray-500">
|
|
|
|
{dayjs(booking.startTime).format(user && user.timeFormat === 12 ? "h:mma" : "HH:mm")} -{" "}
|
|
|
|
{dayjs(booking.endTime).format(user && user.timeFormat === 12 ? "h:mma" : "HH:mm")}
|
|
|
|
</div>
|
|
|
|
<div className="text-sm text-gray-400">
|
|
|
|
{booking.recurringCount &&
|
|
|
|
booking.eventType?.recurringEvent?.freq &&
|
2022-06-10 20:38:06 +00:00
|
|
|
(booking.listingStatus === "recurring" || booking.listingStatus === "cancelled") && (
|
2022-05-27 23:27:41 +00:00
|
|
|
<div className="underline decoration-gray-400 decoration-dashed underline-offset-2">
|
|
|
|
<div className="flex">
|
|
|
|
<Tooltip
|
|
|
|
content={recurringStrings.map((aDate, key) => (
|
|
|
|
<p key={key}>{aDate}</p>
|
|
|
|
))}>
|
2022-06-10 20:38:06 +00:00
|
|
|
<div className="text-gray-600 dark:text-white">
|
|
|
|
<RefreshIcon className="float-left mr-1 mt-[2px] inline-block h-4 w-4 text-gray-400" />
|
|
|
|
<p className="pl-[21px]">
|
|
|
|
{booking.status === BookingStatus.ACCEPTED
|
|
|
|
? `${t("event_remaining", {
|
|
|
|
count: recurringDates.length,
|
|
|
|
})}`
|
|
|
|
: getEveryFreqFor({
|
|
|
|
t,
|
|
|
|
recurringEvent: booking.eventType.recurringEvent,
|
|
|
|
recurringCount: booking.recurringCount,
|
|
|
|
})}
|
|
|
|
</p>
|
|
|
|
</div>
|
2022-05-27 23:27:41 +00:00
|
|
|
</Tooltip>
|
|
|
|
</div>
|
2022-05-05 21:16:25 +00:00
|
|
|
</div>
|
2022-05-27 23:27:41 +00:00
|
|
|
)}
|
|
|
|
</div>
|
2022-05-05 21:16:25 +00:00
|
|
|
</div>
|
2022-02-09 18:25:58 +00:00
|
|
|
</td>
|
2022-06-06 16:54:47 +00:00
|
|
|
<td className={"flex-1 ltr:pl-4 rtl:pr-4" + (isRejected ? " line-through" : "")} onClick={onClick}>
|
2022-05-27 23:27:41 +00:00
|
|
|
<div className="cursor-pointer py-4">
|
|
|
|
<div className="sm:hidden">
|
2022-06-06 16:54:47 +00:00
|
|
|
{isPending && <Tag className="mb-2 ltr:mr-2 rtl:ml-2">{t("unconfirmed")}</Tag>}
|
2022-05-27 23:27:41 +00:00
|
|
|
{!!booking?.eventType?.price && !booking.paid && (
|
|
|
|
<Tag className="mb-2 ltr:mr-2 rtl:ml-2">Pending payment</Tag>
|
|
|
|
)}
|
|
|
|
<div className="text-sm font-medium text-gray-900">
|
|
|
|
{startTime}:{" "}
|
|
|
|
<small className="text-sm text-gray-500">
|
|
|
|
{dayjs(booking.startTime).format("HH:mm")} - {dayjs(booking.endTime).format("HH:mm")}
|
|
|
|
</small>
|
|
|
|
</div>
|
2022-02-09 18:25:58 +00:00
|
|
|
</div>
|
2022-05-27 23:27:41 +00:00
|
|
|
<div
|
|
|
|
title={booking.title}
|
|
|
|
className={classNames(
|
|
|
|
"max-w-56 truncate text-sm font-medium leading-6 text-neutral-900 md:max-w-max",
|
|
|
|
isCancelled ? "line-through" : ""
|
|
|
|
)}>
|
|
|
|
{booking.eventType?.team && <strong>{booking.eventType.team.name}: </strong>}
|
|
|
|
{booking.title}
|
|
|
|
{!!booking?.eventType?.price && !booking.paid && (
|
|
|
|
<Tag className="hidden ltr:ml-2 rtl:mr-2 sm:inline-flex">Pending payment</Tag>
|
|
|
|
)}
|
2022-06-06 16:54:47 +00:00
|
|
|
{isPending && <Tag className="hidden ltr:ml-2 rtl:mr-2 sm:inline-flex">{t("unconfirmed")}</Tag>}
|
2022-05-27 23:27:41 +00:00
|
|
|
</div>
|
|
|
|
{booking.description && (
|
|
|
|
<div
|
|
|
|
className="max-w-52 md:max-w-96 truncate text-sm text-gray-500"
|
|
|
|
title={booking.description}>
|
|
|
|
"{booking.description}"
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
|
|
|
|
{booking.attendees.length !== 0 && (
|
|
|
|
<a
|
|
|
|
className="text-sm text-gray-900 hover:text-blue-500"
|
|
|
|
href={"mailto:" + booking.attendees[0].email}
|
|
|
|
onClick={(e) => e.stopPropagation()}>
|
|
|
|
{booking.attendees[0].email}
|
|
|
|
</a>
|
2022-02-09 18:25:58 +00:00
|
|
|
)}
|
2022-05-27 23:27:41 +00:00
|
|
|
{isCancelled && booking.rescheduled && (
|
|
|
|
<div className="mt-2 inline-block text-left text-sm md:hidden">
|
|
|
|
<RequestSentMessage />
|
|
|
|
</div>
|
2022-02-09 18:25:58 +00:00
|
|
|
)}
|
2021-09-30 10:46:39 +00:00
|
|
|
</div>
|
2022-02-09 18:25:58 +00:00
|
|
|
</td>
|
2021-09-30 10:46:39 +00:00
|
|
|
|
2022-02-09 18:25:58 +00:00
|
|
|
<td className="whitespace-nowrap py-4 text-right text-sm font-medium ltr:pr-4 rtl:pl-4">
|
|
|
|
{isUpcoming && !isCancelled ? (
|
|
|
|
<>
|
2022-06-06 16:54:47 +00:00
|
|
|
{isPending && user?.id === booking.user?.id && <TableActions actions={pendingActions} />}
|
|
|
|
{isConfirmed && <TableActions actions={bookedActions} />}
|
|
|
|
{isRejected && <div className="text-sm text-gray-500">{t("rejected")}</div>}
|
2022-02-09 18:25:58 +00:00
|
|
|
</>
|
|
|
|
) : null}
|
2022-04-14 21:25:24 +00:00
|
|
|
{isCancelled && booking.rescheduled && (
|
|
|
|
<div className="hidden h-full items-center md:flex">
|
|
|
|
<RequestSentMessage />
|
|
|
|
</div>
|
|
|
|
)}
|
2022-02-09 18:25:58 +00:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</>
|
2021-09-30 10:46:39 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-12-17 16:58:23 +00:00
|
|
|
const Tag = ({ children, className = "" }: React.PropsWithChildren<{ className?: string }>) => {
|
|
|
|
return (
|
|
|
|
<span
|
2022-02-09 00:05:13 +00:00
|
|
|
className={`inline-flex items-center rounded-sm bg-yellow-100 px-1.5 py-0.5 text-xs font-medium text-yellow-800 ${className}`}>
|
2021-12-17 16:58:23 +00:00
|
|
|
{children}
|
|
|
|
</span>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2021-09-30 10:46:39 +00:00
|
|
|
export default BookingListItem;
|