From daebbf0154a290fb690ed94fca23377e0f739f53 Mon Sep 17 00:00:00 2001
From: MohamedBassem <me@mbassem.com>
Date: Wed, 7 Feb 2024 02:48:38 +0000
Subject: [ui] Very first draft of the link grid

---
 web/app/bookmarks/components/AddLink.tsx | 40 ++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
 create mode 100644 web/app/bookmarks/components/AddLink.tsx

(limited to 'web/app/bookmarks/components/AddLink.tsx')

diff --git a/web/app/bookmarks/components/AddLink.tsx b/web/app/bookmarks/components/AddLink.tsx
new file mode 100644
index 00000000..54cf9137
--- /dev/null
+++ b/web/app/bookmarks/components/AddLink.tsx
@@ -0,0 +1,40 @@
+"use client";
+
+import APIClient from "@/lib/api";
+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) {
+      alert(error.message);
+      return;
+    }
+    router.refresh();
+  };
+
+  return (
+    <div className="p-4">
+      <input
+        type="text"
+        placeholder="Link"
+        value={link}
+        onChange={(val) => setLink(val.target.value)}
+        onKeyUp={async (event) => {
+          if (event.key == "Enter") {
+            bookmarkLink();
+            setLink("");
+          }
+        }}
+        className="w-10/12 px-4 py-2 border rounded-md focus:outline-none focus:border-blue-300"
+      />
+      <button className="w-2/12 px-1 py-2" onClick={bookmarkLink}>
+        Submit
+      </button>
+    </div>
+  );
+}
-- 
cgit v1.2.3-70-g09d2

