* use booking.uid instead of booking.id for url param * show timezone on calendar * fix type * restore horizontal tab and remove header and subtitle * clean up sidebar items * fix event propagation from attendees * fetch all statuses except for cancelled on calendar view * clean up styles of the badges on BookingListItem * fix useMediaQuery * add close button to the header * add assignment reason to the details sheet * use separator row * use ToggleGroup for the top bookings tab * move ViewToggleButton * resize the action button * remove wrong prop * fix type error * fix type error * hide view toggle button on mobile (and fix the breakpoint) * remove unused e2e tests * fix e2e tests * hide toggle button when feature flag is off * update skeleton * improve attendees on booking list item and slide over * improve attendee dropdown * fix type error * move query to containers * select attendee email * infinite fetching for calendar view * update styles * fix compatibility * fix: add backward compatibility for status field in getAllUserBookings * increase calendar height * fix type error * support Member filter only for admin / owners * add debug log (TEMP) * add event border color * show Reject / Accept buttons on BookingDetailsSheet * move description section to the top * update When section * update style of Who section * add CancelBookingDialog WIP * fix CancelBookingDialog * increase clickable area * add schedule info section WIP * fix flaky reject button * fixing reschedule info WIP * add fromReschedule index to Booking * improve rescheduled information * improve reassignment * fix type error * fix unit test * respect user's weekStart value on the booking calendar view * update debug log * improve payment section * clean up * fix log message * reposition filters on list view * fix bookings controller api2 e2e test * clean up file by extracting logic into custom hooks * rename files * merge BookingCalendar into its container * extract logic into separate hook files * remove redundant logic * rearrange items on calendar view * add WeekPicker * extract filter button * responsive header on list view * horizontal scroll for ToggleGroup WIP * fix type error * fix cancelling recurring event * address feedback * fix e2e tests * fix unit test * fix e2e tests * make hover style more visible for ToggleGroup * fix margin on CancelBookingDialog * update styles on the slide over (mostly font weight) * update style of CancelBookingDialog * update styles * update margin top for the header * refactor getBookingDetails handler * fix gap in who section * auto-filter the current user on the calendar view * calculate calendar height considering top banners * improve booking details sheet interaction without overlay * update calendar event styles * update reject dialog style * put uid first in the query params * fix class name * memoize functions in useMediaQuery * query attendee with id instead of email * update margins * replace TRPCError with ErrorWithCode * move calculation outside loop * remove dead code
105 lines
2.9 KiB
TypeScript
105 lines
2.9 KiB
TypeScript
import type { FC } from "react";
|
|
import React from "react";
|
|
|
|
import type { ButtonBaseProps } from "../button";
|
|
import { Button } from "../button";
|
|
import {
|
|
Dropdown,
|
|
DropdownItem,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuPortal,
|
|
DropdownMenuTrigger,
|
|
} from "../dropdown";
|
|
import type { IconName } from "../icon";
|
|
|
|
export type ActionType = {
|
|
id: string;
|
|
icon?: IconName;
|
|
iconClassName?: string;
|
|
label: string;
|
|
disabled?: boolean;
|
|
color?: ButtonBaseProps["color"];
|
|
bookingUid?: string;
|
|
} & (
|
|
| { href: string; onClick?: never; actions?: never }
|
|
| { href?: never; onClick: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void; actions?: never }
|
|
| { actions?: ActionType[]; href?: never; onClick?: never }
|
|
);
|
|
|
|
interface Props {
|
|
actions: ActionType[];
|
|
}
|
|
|
|
const defaultAction = (e: React.MouseEvent<HTMLElement, MouseEvent>) => {
|
|
e.stopPropagation();
|
|
};
|
|
|
|
export const DropdownActions = ({
|
|
actions,
|
|
actionTrigger,
|
|
}: {
|
|
actions: ActionType[];
|
|
actionTrigger?: React.ReactNode;
|
|
}) => {
|
|
return (
|
|
<Dropdown>
|
|
{!actionTrigger ? (
|
|
<DropdownMenuTrigger asChild>
|
|
<Button type="button" color="secondary" variant="icon" StartIcon="ellipsis" />
|
|
</DropdownMenuTrigger>
|
|
) : (
|
|
<DropdownMenuTrigger asChild>{actionTrigger}</DropdownMenuTrigger>
|
|
)}
|
|
<DropdownMenuPortal>
|
|
<DropdownMenuContent>
|
|
{actions.map((action) => (
|
|
<DropdownMenuItem key={action.id}>
|
|
<DropdownItem
|
|
type="button"
|
|
color={action.color}
|
|
data-testid={action.id}
|
|
StartIcon={action.icon}
|
|
href={action.href}
|
|
data-booking-uid={action.bookingUid}
|
|
onClick={action.onClick || defaultAction}>
|
|
{action.label}
|
|
</DropdownItem>
|
|
</DropdownMenuItem>
|
|
))}
|
|
</DropdownMenuContent>
|
|
</DropdownMenuPortal>
|
|
</Dropdown>
|
|
);
|
|
};
|
|
|
|
export const TableActions: FC<Props> = ({ actions }) => {
|
|
return (
|
|
<>
|
|
<div className="flex space-x-2 rtl:space-x-reverse">
|
|
{actions.map((action) => {
|
|
const button = (
|
|
<Button
|
|
className="whitespace-nowrap"
|
|
key={action.id}
|
|
data-testid={action.id}
|
|
href={action.href}
|
|
onClick={action.onClick || defaultAction}
|
|
StartIcon={action.icon}
|
|
{...(action?.actions ? { EndIcon: "chevron-down" } : null)}
|
|
disabled={action.disabled}
|
|
data-booking-uid={action.bookingUid}
|
|
color={action.color || "secondary"}>
|
|
{action.label}
|
|
</Button>
|
|
);
|
|
if (!action.actions) {
|
|
return button;
|
|
}
|
|
return <DropdownActions key={action.id} actions={action.actions} actionTrigger={button} />;
|
|
})}
|
|
</div>
|
|
</>
|
|
);
|
|
};
|