import React from "react"; import useLinkStore from "@/store/links"; import toast from "react-hot-toast"; import Modal from "../Modal"; 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)); toast.dismiss(load); response.ok && toast.success(`Deleted ${selectedLinks.length} Link${selectedLinks.length > 1 ? "s" : ""}`); setSelectedLinks([]); onClose(); }; 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.

); }