From bf99ee97f7c4d7580829d074816ebe0d32316d92 Mon Sep 17 00:00:00 2001 From: Yash Date: Thu, 11 Apr 2024 11:02:24 +0000 Subject: ok --- .../web/src/components/Sidebar/AddMemoryDialog.tsx | 100 +++++++++++---------- 1 file changed, 53 insertions(+), 47 deletions(-) (limited to 'apps/web/src/components/Sidebar/AddMemoryDialog.tsx') diff --git a/apps/web/src/components/Sidebar/AddMemoryDialog.tsx b/apps/web/src/components/Sidebar/AddMemoryDialog.tsx index aa86966f..886507ff 100644 --- a/apps/web/src/components/Sidebar/AddMemoryDialog.tsx +++ b/apps/web/src/components/Sidebar/AddMemoryDialog.tsx @@ -10,13 +10,17 @@ import { Input } from "../ui/input"; import { Label } from "../ui/label"; import { Markdown } from "tiptap-markdown"; import { useEffect, useRef, useState } from "react"; -import { FilterCombobox } from "./FilterCombobox"; +import { FilterSpaces } from "./FilterCombobox"; +import { useMemory } from "@/contexts/MemoryContext"; export function AddMemoryPage() { + const { addMemory } = useMemory(); + + const [url, setUrl] = useState(""); const [selectedSpacesId, setSelectedSpacesId] = useState([]); return ( -
+
Add a web page to memory @@ -30,25 +34,41 @@ export function AddMemoryPage() { type="url" data-modal-autofocus className="bg-rgray-4 mt-2 w-full" + value={url} + onChange={(e) => setUrl(e.target.value)} /> - - { + // @Dhravya this is adding a memory with insufficient information fix pls + await addMemory( + { + title: url, + content: "", + type: "page", + url: url, + image: "/icons/logo_without_bg.png", + savedAt: new Date(), + }, + selectedSpacesId, + ); + }} className="bg-rgray-4 hover:bg-rgray-5 focus-visible:bg-rgray-5 focus-visible:ring-rgray-7 rounded-md px-4 py-2 ring-transparent transition focus-visible:outline-none focus-visible:ring-2" > Add - + Cancel -
+ ); } @@ -60,16 +80,15 @@ export function NoteAddPage({ closeDialog }: { closeDialog: () => void }) { const [content, setContent] = useState(""); const [loading, setLoading] = useState(false); - function check() { + function check(): boolean { const data = { name: name.trim(), content, }; - console.log(name); if (!data.name || data.name.length < 1) { if (!inputRef.current) { alert("Please enter a name for the note"); - return; + return false; } inputRef.current.value = ""; inputRef.current.placeholder = "Please enter a title for the note"; @@ -79,7 +98,9 @@ export function NoteAddPage({ closeDialog }: { closeDialog: () => void }) { inputRef.current!.dataset["error"] = "false"; }, 500); inputRef.current.focus(); + return false; } + return true; } return ( @@ -87,7 +108,7 @@ export function NoteAddPage({ closeDialog }: { closeDialog: () => void }) { void }) { className="novel-editor bg-rgray-4 border-rgray-7 dark mt-5 max-h-[60vh] min-h-[40vh] w-[50vw] overflow-y-auto rounded-lg border [&>div>div]:p-5" /> - void }) { /> + Add + + Cancel -- cgit v1.2.3