import { Menu, Transition } from "@headlessui/react"; import { DotsHorizontalIcon } from "@heroicons/react/solid"; import React, { FC, Fragment } from "react"; import classNames from "@lib/classNames"; import { useLocale } from "@lib/hooks/useLocale"; import { SVGComponent } from "@lib/types/SVGComponent"; import Button from "./Button"; export type ActionType = { id: string; icon: SVGComponent; label: string; disabled?: boolean; color?: "primary" | "secondary"; } & ({ href?: never; onClick: () => any } | { href: string; onClick?: never }); interface Props { actions: ActionType[]; } const TableActions: FC = ({ actions }) => { const { t } = useLocale(); return ( <>
{actions.map((action) => ( ))}
{({ open }) => ( <>
{t("open_options")}
{actions.map((action) => { const Element = typeof action.onClick === "function" ? "span" : "a"; return ( {({ active }) => ( )} ); })}
)}
); }; export default TableActions;