import { Dispatch, SetStateAction, useState } from "react"; import { faFolder, faPenToSquare, faPlus, } from "@fortawesome/free-solid-svg-icons"; import useCollectionStore from "@/store/collections"; import { CollectionIncludingMembersAndLinkCount } from "@/types/global"; import RequiredBadge from "../../RequiredBadge"; import SubmitButton from "@/components/SubmitButton"; import { HexColorPicker } from "react-colorful"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { toast } from "react-hot-toast"; type Props = { toggleCollectionModal: Function; setCollection: Dispatch< SetStateAction >; collection: CollectionIncludingMembersAndLinkCount; method: "CREATE" | "UPDATE"; }; export default function CollectionInfo({ toggleCollectionModal, setCollection, collection, method, }: Props) { const [submitLoader, setSubmitLoader] = useState(false); const { updateCollection, addCollection } = useCollectionStore(); const submit = async () => { if (!collection) return null; setSubmitLoader(true); const load = toast.loading( method === "UPDATE" ? "Applying..." : "Creating..." ); let response; if (method === "CREATE") response = await addCollection(collection); else response = await updateCollection(collection); toast.dismiss(load); if (response.ok) { toast.success( `Collection ${method === "UPDATE" ? "Saved!" : "Created!"}` ); toggleCollectionModal(); } else toast.error(response.data as string); setSubmitLoader(false); }; return (

Name

setCollection({ ...collection, name: e.target.value }) } type="text" placeholder="e.g. Example Collection" className="w-full rounded-md p-3 border-sky-100 dark:border-sky-800 dark:bg-blue-950 border-solid border outline-none focus:border-sky-700 duration-100" />

Icon Color

setCollection({ ...collection, color: "#0ea5e9" }) } > Reset
setCollection({ ...collection, color: e })} />

Description