import React from "react"; import useLinkStore from "@/store/links"; import toast from "react-hot-toast"; import Modal from "../Modal"; import Button from "../ui/Button"; type Props = { onClose: Function; }; export default function BulkDeleteLinksModal({ onClose }: Props) { const { selectedLinks, setSelectedLinks, deleteLinksById } = useLinkStore(); const deleteLink = async () => { const load = toast.loading( `Deleting ${selectedLinks.length} Link${ selectedLinks.length > 1 ? "s" : "" }...` ); const response = await deleteLinksById( selectedLinks.map((link) => link.id as number) ); toast.dismiss(load); if (response.ok) { toast.success( `Deleted ${selectedLinks.length} Link${ selectedLinks.length > 1 ? "s" : "" }` ); setSelectedLinks([]); onClose(); } else toast.error(response.data as string); }; return (

Delete {selectedLinks.length} Link{selectedLinks.length > 1 ? "s" : ""}

{selectedLinks.length > 1 ? (

Are you sure you want to delete {selectedLinks.length} links?

) : (

Are you sure you want to delete this link?

)}
Warning: This action is irreversible!

Hold the Shift key while clicking 'Delete' to bypass this confirmation in the future.

); }