import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from "@/components/ui/alert-dialog" import { buttonVariants } from "@/components/ui/button" import { IconButton } from "@/components/xui/icon-button" import { useTranslation } from "react-i18next" import { toast } from "sonner" import { KeyedMutator } from "swr" interface ButtonGroupProps { className?: string children: React.ReactNode delete: { fn: (id: E[]) => Promise; id: E; mutate: KeyedMutator } } interface BlockButtonGroupProps { className?: string children?: React.ReactNode block: { fn: (id: E[]) => Promise; id: E; mutate: KeyedMutator } } export function ActionButtonGroup({ className, children, delete: { fn, id, mutate }, }: ButtonGroupProps) { const { t } = useTranslation() const handleDelete = async () => { try { await fn([id]) } catch (error: any) { toast(t("Error"), { description: error.message, }) } await mutate() } return (
{children} {t("ConfirmDeletion")} {t("Results.ThisOperationIsUnrecoverable")} {t("Close")} {t("Confirm")}
) } export function BlockButtonGroup({ className, children, block: { fn, id, mutate }, }: BlockButtonGroupProps) { const { t } = useTranslation() const handleBlock = async () => { try { await fn([id]) } catch (error: any) { toast(t("Error"), { description: error.message, }) } await mutate() } return (
{children} {t("ConfirmBlock")} {t("Results.ThisOperationIsUnrecoverable")} {t("Close")} {t("Confirm")}
) }