From 257e355ae3b47e9de37f9686b400fa598904c6cb Mon Sep 17 00:00:00 2001 From: Yash Date: Thu, 11 Apr 2024 06:24:56 +0000 Subject: [PATCH] new schema --- .../components/Sidebar/AddMemoryDialog.tsx | 77 +++++++++++++++++++ apps/web/src/server/db/schema.ts | 3 + 2 files changed, 80 insertions(+) diff --git a/apps/web/src/components/Sidebar/AddMemoryDialog.tsx b/apps/web/src/components/Sidebar/AddMemoryDialog.tsx index ace930a6..aa86966f 100644 --- a/apps/web/src/components/Sidebar/AddMemoryDialog.tsx +++ b/apps/web/src/components/Sidebar/AddMemoryDialog.tsx @@ -128,3 +128,80 @@ 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); + + function check() { + 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; + } + inputRef.current.value = ""; + inputRef.current.placeholder = "Please enter a title for the note"; + inputRef.current.dataset["error"] = "true"; + setTimeout(() => { + inputRef.current!.placeholder = "Title of the note"; + inputRef.current!.dataset["error"] = "false"; + }, 500); + inputRef.current.focus(); + } + } + + return ( +
+ setName(e.target.value)} + /> + { + if (!editor) return; + setContent(editor.storage.markdown.getMarkdown()); + }} + extensions={[Markdown]} + 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" + /> + + + + + Cancel + + +
+ ); +} diff --git a/apps/web/src/server/db/schema.ts b/apps/web/src/server/db/schema.ts index e0ddbdbc..d78c0a89 100644 --- a/apps/web/src/server/db/schema.ts +++ b/apps/web/src/server/db/schema.ts @@ -88,6 +88,9 @@ export const storedContent = createTable( url: text("url").notNull(), savedAt: int("savedAt", { mode: "timestamp" }).notNull(), baseUrl: text("baseUrl", { length: 255 }), + type: text("type", { enum: ["note", "page", "twitter-bookmark"] }).default( + "page", + ), image: text("image", { length: 255 }), user: text("user", { length: 255 }).references(() => users.id), },