import React, { useState } from "react"; import CollectionSelection from "./InputSelect/CollectionSelection"; import TagSelection from "./InputSelect/TagSelection"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faPlus } from "@fortawesome/free-solid-svg-icons"; import { useRouter } from "next/router"; import { NewLink } from "@/types/global"; import useLinkSlice from "@/store/links"; export default function ({ toggleLinkModal }: { toggleLinkModal: Function }) { const router = useRouter(); const [newLink, setNewLink] = useState({ name: "", url: "", tags: [], collection: { id: Number(router.query.id) }, }); const { addLink } = useLinkSlice(); const setTags = (e: any) => { const tagNames = e.map((e: any) => { return e.label; }); setNewLink({ ...newLink, tags: tagNames }); }; const setCollection = (e: any) => { const collection = { id: e?.value, isNew: e?.__isNew__ }; setNewLink({ ...newLink, collection: collection }); }; const submitLink = async () => { const response = await addLink(newLink); if (response) toggleLinkModal(); }; return (

New Link

Name

setNewLink({ ...newLink, name: e.target.value })} type="text" placeholder="e.g. Example Link" className="w-60 rounded p-3 border-sky-100 border-solid border text-sm outline-none focus:border-sky-500 duration-100" />

URL

setNewLink({ ...newLink, url: e.target.value })} type="text" placeholder="e.g. http://example.com/" className="w-60 rounded p-3 border-sky-100 border-solid border text-sm outline-none focus:border-sky-500 duration-100" />

Tags

Collection

Add Link
); }