// Copyright (C) 2022-present Daniel31x13 // This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3. // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. // You should have received a copy of the GNU General Public License along with this program. If not, see . import React, { useState } from "react"; import CollectionSelection from "@/components/InputSelect/CollectionSelection"; import TagSelection from "@/components/InputSelect/TagSelection"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { ExtendedLink } from "@/types/global"; import { faPenToSquare } from "@fortawesome/free-regular-svg-icons"; import useLinkStore from "@/store/links"; type Props = { toggleLinkModal: Function; link: ExtendedLink; }; export default function EditLink({ toggleLinkModal, link }: Props) { const [currentLink, setCurrentLink] = useState(link); const { updateLink } = useLinkStore(); const shortendURL = new URL(link.url).host.toLowerCase(); const setTags = (e: any) => { const tagNames = e.map((e: any) => { return { name: e.label }; }); setCurrentLink({ ...currentLink, tags: tagNames }); }; const setCollection = (e: any) => { if (e?.__isNew__) e.value = null; setCurrentLink({ ...currentLink, collection: { id: e?.value, name: e?.label, ownerId: e?.ownerId } as any, }); }; const submit = async () => { updateLink(currentLink); toggleLinkModal(); }; return (

Edit Link

{shortendURL} | {link.title}

Name

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

Tags

{ return { label: e.name, value: e.id }; })} />

Collection

Edit Link
); }