From 5b340071245cfe9906fd3534ec5176de1e3fd3bd Mon Sep 17 00:00:00 2001 From: yxshv Date: Sat, 13 Apr 2024 18:11:14 +0530 Subject: spaces dialog --- .../web/src/components/Sidebar/AddMemoryDialog.tsx | 66 ++++++++++++++++++---- 1 file changed, 55 insertions(+), 11 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 886507ff..4f8ef734 100644 --- a/apps/web/src/components/Sidebar/AddMemoryDialog.tsx +++ b/apps/web/src/components/Sidebar/AddMemoryDialog.tsx @@ -10,8 +10,11 @@ import { Input } from "../ui/input"; import { Label } from "../ui/label"; import { Markdown } from "tiptap-markdown"; import { useEffect, useRef, useState } from "react"; -import { FilterSpaces } from "./FilterCombobox"; +import { FilterMemories, FilterSpaces } from "./FilterCombobox"; import { useMemory } from "@/contexts/MemoryContext"; +import { Command, Plus, X } from "lucide-react"; +import { StoredContent } from "@/server/db/schema"; +import { cleanUrl } from "@/lib/utils"; export function AddMemoryPage() { const { addMemory } = useMemory(); @@ -153,29 +156,28 @@ export function NoteAddPage({ closeDialog }: { closeDialog: () => void }) { } export function SpaceAddPage({ closeDialog }: { closeDialog: () => void }) { - const [selectedSpacesId, setSelectedSpacesId] = useState([]); const inputRef = useRef(null); const [name, setName] = useState(""); - const [content, setContent] = useState(""); const [loading, setLoading] = useState(false); + const [selected, setSelected] = useState([]); + + 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 false; } inputRef.current.value = ""; - inputRef.current.placeholder = "Please enter a title for the note"; + inputRef.current.placeholder = "Please enter a title for the space"; inputRef.current.dataset["error"] = "true"; setTimeout(() => { - inputRef.current!.placeholder = "Title of the note"; + inputRef.current!.placeholder = "Enter the name of the space"; inputRef.current!.dataset["error"] = "false"; }, 500); inputRef.current.focus(); @@ -191,19 +193,48 @@ export function SpaceAddPage({ closeDialog }: { closeDialog: () => void }) { setName(e.target.value)} + className="bg-rgray-4 mt-2 w-full focus-visible:data-[error=true]:ring-red-500/10 data-[error=true]:placeholder:text-red-400 placeholder:transition placeholder:duration-500" /> - + {selected.length > 0 && ( + <> + +
+ {selected.map(i => ( + setSelected(prev => prev.filter(p => p.id !== i.id))} + {...i} + /> + ))} +
+ + )} - + + Memory + + Cancel @@ -211,3 +242,16 @@ export function SpaceAddPage({ closeDialog }: { closeDialog: () => void }) { ); } + +export function MemorySelectedItem({ id, title, url, image, onRemove }: StoredContent & { onRemove: () => void; }) { + return ( +
+ + + {title} + {cleanUrl(url)} +
+ ) +} -- cgit v1.2.3