From 2659da517aeec0fe955422dee76f7de292f1a591 Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Thu, 8 Feb 2024 02:16:51 +0000 Subject: [feature] Introduce a sidebar --- web/app/dashboard/bookmarks/components/AddLink.tsx | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 web/app/dashboard/bookmarks/components/AddLink.tsx (limited to 'web/app/dashboard/bookmarks/components/AddLink.tsx') diff --git a/web/app/dashboard/bookmarks/components/AddLink.tsx b/web/app/dashboard/bookmarks/components/AddLink.tsx new file mode 100644 index 00000000..fab4db8b --- /dev/null +++ b/web/app/dashboard/bookmarks/components/AddLink.tsx @@ -0,0 +1,43 @@ +"use client"; + +import { Button } from "@/components/ui/button"; +import { Input } from "@/components/ui/input"; +import APIClient from "@/lib/api"; +import { Plus } from "lucide-react"; +import { useRouter } from "next/navigation"; +import { useState } from "react"; + +export default function AddLink() { + const router = useRouter(); + const [link, setLink] = useState(""); + + const bookmarkLink = async () => { + const [_resp, error] = await APIClient.bookmarkLink(link); + if (error) { + // TODO: Proper error handling + alert(error.message); + return; + } + router.refresh(); + }; + + return ( +
+ setLink(val.target.value)} + onKeyUp={async (event) => { + if (event.key == "Enter") { + bookmarkLink(); + setLink(""); + } + }} + /> + +
+ ); +} -- cgit v1.2.3-70-g09d2