* add functionality to change location in booking and send out mail * add i18n * change location with dropdown like in event-types * small fixes and code clean up * clean code * improve format of current Location string * clean code * clear selection when dialog closed * added mutation and changed props (first working verison) * clean code * clean code * clean code * clean code * fix typo * change maxHeight of select * use useWatch for selectedLocation * pass default values with props * set current location directly in useState * clear selected values when updating location * fix trpc query for credentialst * change icons for editing booking * improve naming of variables * remove unnecessary orderBy * use locationOptionsToString method * fix current location naming for Cal Video * add phone input * save phone number as location of booking * remove input field for phone number for event-types * fix redirection issue * show previous selected location in event-type * remove attendee number from selection for booking * make first letter of location lowercase * remove input field for attendee phone number * clear Errors when changing location type * set location details to optional * clean code * fixing issue that dropdown doesn't close when dialog opens * clean code * make overflow visibile in dialog * fix existing bug with address not showing in event-type settings * fix issue with losing focus after validation * close rejection dialog * small spelling fixes * fix issue with LocationChangeEmail * fix failing E2E test * fix failing E2E test * fix E2E test * bug fix for saving user phone, and other minor changes * merge main * improve text * fix UI of booking list * Delete admin * remove selection after update and submit * add translation for error message * add default values for checkbox * add "your phone number" to locations on booking page * remove duplicate attributes from viewer.bookings Co-authored-by: Omar López <zomars@me.com> * check if user is authorized to make changes to booking * remove location string * clan code for displayLocaitonPublicly checkbox * fetch locationOptions on server side * remove trpc query for credentials * fix phone number input * fix labels of host and attendee phone number for booking page * Migrates edit location to tRPC * Link elemnt should only be used in `a` tags * Adds missin router * Migrates locationOptions to tRPC query * Type fixes Co-authored-by: CarinaWolli <wollencarina@gmail.com> Co-authored-by: Alan <alannnc@gmail.com> Co-authored-by: Omar López <zomars@me.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
107 lines
3.2 KiB
TypeScript
107 lines
3.2 KiB
TypeScript
import { ChevronDownIcon, DotsHorizontalIcon } from "@heroicons/react/solid";
|
|
import React, { FC } from "react";
|
|
|
|
import Button from "@calcom/ui/Button";
|
|
import Dropdown, { DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@calcom/ui/Dropdown";
|
|
|
|
import { SVGComponent } from "@lib/types/SVGComponent";
|
|
|
|
export type ActionType = {
|
|
id: string;
|
|
icon?: SVGComponent;
|
|
iconClassName?: string;
|
|
label: string;
|
|
disabled?: boolean;
|
|
color?: "primary" | "secondary";
|
|
} & (
|
|
| { 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();
|
|
};
|
|
|
|
const DropdownActions = ({
|
|
actions,
|
|
actionTrigger,
|
|
}: {
|
|
actions: ActionType[];
|
|
actionTrigger?: React.ReactNode;
|
|
}) => {
|
|
return (
|
|
<Dropdown>
|
|
{!actionTrigger ? (
|
|
<DropdownMenuTrigger className="h-[38px] w-[38px] cursor-pointer rounded-sm border border-transparent text-neutral-500 hover:border-gray-300 hover:text-neutral-900">
|
|
<DotsHorizontalIcon className="h-5 w-5 group-hover:text-gray-800" />
|
|
</DropdownMenuTrigger>
|
|
) : (
|
|
<DropdownMenuTrigger asChild>{actionTrigger}</DropdownMenuTrigger>
|
|
)}
|
|
<DropdownMenuContent portalled>
|
|
{actions.map((action) => (
|
|
<DropdownMenuItem key={action.id} className="focus-visible:outline-none">
|
|
<Button
|
|
type="button"
|
|
size="sm"
|
|
color="minimal"
|
|
className="w-full rounded-none font-normal"
|
|
href={action.href}
|
|
StartIcon={action.icon}
|
|
startIconClassName={action.iconClassName}
|
|
onClick={action.onClick || defaultAction}
|
|
data-testid={action.id}>
|
|
{action.label}
|
|
</Button>
|
|
</DropdownMenuItem>
|
|
))}
|
|
</DropdownMenuContent>
|
|
</Dropdown>
|
|
);
|
|
};
|
|
|
|
const TableActions: FC<Props> = ({ actions }) => {
|
|
const mobileActions = actions.flatMap((action) => {
|
|
if (action.actions) {
|
|
return action.actions;
|
|
}
|
|
return action;
|
|
});
|
|
return (
|
|
<>
|
|
<div className="hidden space-x-2 rtl:space-x-reverse lg:block">
|
|
{actions.map((action) => {
|
|
const button = (
|
|
<Button
|
|
key={action.id}
|
|
data-testid={action.id}
|
|
href={action.href}
|
|
onClick={action.onClick || defaultAction}
|
|
StartIcon={action.icon}
|
|
startIconClassName={action.iconClassName}
|
|
{...(action?.actions ? { EndIcon: ChevronDownIcon } : null)}
|
|
disabled={action.disabled}
|
|
color={action.color || "secondary"}>
|
|
{action.label}
|
|
</Button>
|
|
);
|
|
if (!action.actions) {
|
|
return button;
|
|
}
|
|
return <DropdownActions key={action.id} actions={action.actions} actionTrigger={button} />;
|
|
})}
|
|
</div>
|
|
<div className="inline-block text-left lg:hidden">
|
|
<DropdownActions actions={mobileActions} />
|
|
</div>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default TableActions;
|