import React, { useState } from "react"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faTrashCan } from "@fortawesome/free-solid-svg-icons"; import { CollectionIncludingMembers } from "@/types/global"; import useCollectionStore from "@/store/collections"; import { useRouter } from "next/router"; type Props = { toggleDeleteCollectionModal: Function; collection: CollectionIncludingMembers; }; export default function DeleteCollection({ toggleDeleteCollectionModal, collection, }: Props) { const [inputField, setInputField] = useState(""); const { removeCollection } = useCollectionStore(); const router = useRouter(); const submit = async () => { if (!collection.id || collection.name !== inputField) return null; const response = await removeCollection(collection.id); if (response) { toggleDeleteCollectionModal(); router.push("/collections"); } }; return (
Warning!
Please note that deleting the collection will permanently remove all its contents, including the following:
Please double-check that you have backed up any essential data and have informed the relevant members about this action.
To confirm, type " {collection.name} " in the box below:
setInputField(e.target.value)} type="text" placeholder={`Type "${collection.name}" Here.`} className="w-72 sm:w-96 rounded-md p-3 mx-auto border-sky-100 border-solid border outline-none focus:border-sky-500 duration-100" />