import React from "react"; import { usePathname, useRouter } from "next/navigation"; import { ActionButton } from "@/components/ui/action-button"; import ActionConfirmingDialog from "@/components/ui/action-confirming-dialog"; import { Label } from "@/components/ui/label"; import { Switch } from "@/components/ui/switch"; import { toast } from "@/components/ui/use-toast"; import { useTranslation } from "@/lib/i18n/client"; import type { ZBookmarkList } from "@karakeep/shared/types/lists"; import { useDeleteBookmarkList } from "@karakeep/shared-react/hooks/lists"; export default function DeleteListConfirmationDialog({ list, children, open, setOpen, }: { list: ZBookmarkList; children?: React.ReactNode; open: boolean; setOpen: (v: boolean) => void; }) { const { t } = useTranslation(); const currentPath = usePathname(); const router = useRouter(); const [deleteChildren, setDeleteChildren] = React.useState(false); const { mutate: deleteList, isPending } = useDeleteBookmarkList({ onSuccess: () => { toast({ description: `List "${list.icon} ${list.name}" ${deleteChildren ? "and all its children are " : "is "} deleted!`, }); setOpen(false); if (currentPath.includes(list.id)) { router.push("/dashboard/lists"); } }, onError: () => { toast({ variant: "destructive", description: `Something went wrong`, }); }, }); return (

Are you sure you want to delete {list.icon} {list.name}?

{t("lists.delete_list.description")}

{t("lists.delete_list.delete_children_description")}

} actionButton={() => ( deleteList({ listId: list.id, deleteChildren })} > {t("actions.delete")} )} > {children}
); }