From e6ea714b5ce5a23ffb649d5987f4f7df48039595 Mon Sep 17 00:00:00 2001 From: codeTorso Date: Mon, 12 Aug 2024 02:15:35 +0530 Subject: why is this novel shit broke --- apps/web/app/(dash)/dialogContentContainer.tsx | 223 ---------------- apps/web/app/(dash)/dialogTriggerWrapper.tsx | 50 ---- apps/web/app/(dash)/menu.tsx | 355 +++++++++++-------------- apps/web/migrations/0001_Adding_jobs_table.sql | 19 -- 4 files changed, 160 insertions(+), 487 deletions(-) delete mode 100644 apps/web/app/(dash)/dialogContentContainer.tsx delete mode 100644 apps/web/app/(dash)/dialogTriggerWrapper.tsx delete mode 100644 apps/web/migrations/0001_Adding_jobs_table.sql (limited to 'apps') diff --git a/apps/web/app/(dash)/dialogContentContainer.tsx b/apps/web/app/(dash)/dialogContentContainer.tsx deleted file mode 100644 index 0b2b615c..00000000 --- a/apps/web/app/(dash)/dialogContentContainer.tsx +++ /dev/null @@ -1,223 +0,0 @@ -import { StoredSpace } from "@repo/db/schema"; -import { useEffect, useMemo, useState } from "react"; -import { createMemory, createSpace } from "../actions/doers"; -import ComboboxWithCreate from "@repo/ui/shadcn/combobox"; -import { toast } from "sonner"; -import { getSpaces } from "../actions/fetchers"; -import { MinusIcon, PlusCircleIcon } from "lucide-react"; -import { - DialogContent, - DialogDescription, - DialogFooter, - DialogHeader, - DialogTitle, -} from "@repo/ui/shadcn/dialog"; -import { Label } from "@repo/ui/shadcn/label"; -import { Textarea } from "@repo/ui/shadcn/textarea"; -import { Button } from "@repo/ui/shadcn/button"; - -export function DialogContentContainer({ - DialogClose, -}: { - DialogClose: () => void; -}) { - const [spaces, setSpaces] = useState([]); - const [content, setContent] = useState(""); - const [selectedSpaces, setSelectedSpaces] = useState([]); - - const options = useMemo( - () => - spaces.map((x) => ({ - label: x.name, - value: x.id.toString(), - })), - [spaces], - ); - - const autoDetectedType = useMemo(() => { - if (content.length === 0) { - return "none"; - } - - if ( - content.match(/https?:\/\/(x\.com|twitter\.com)\/[\w]+\/[\w]+\/[\d]+/) - ) { - return "tweet"; - } else if (content.match(/https?:\/\/[\w\.]+/)) { - return "page"; - } else if (content.match(/https?:\/\/www\.[\w\.]+/)) { - return "page"; - } else { - return "note"; - } - }, [content]); - - const handleSubmit = async (content?: string, spaces?: number[]) => { - DialogClose(); - - toast.info("Creating memory...", { - icon: , - duration: 7500, - }); - - if (!content || content.length === 0) { - toast.error("Content is required"); - return; - } - - console.log(spaces); - - const cont = await createMemory({ - content: content, - spaces: spaces ?? undefined, - }); - - setContent(""); - setSelectedSpaces([]); - }; - - useEffect(() => { - (async () => { - let spaces = await getSpaces(); - - if (!spaces.success || !spaces.data) { - toast.warning("Unable to get spaces", { - richColors: true, - }); - setSpaces([]); - return; - } - setSpaces(spaces.data); - })(); - }, []); - - return ( - -
{ - const content = e.get("content")?.toString(); - - await handleSubmit(content, selectedSpaces); - }} - className="flex flex-col gap-4 " - > - - Add memory - - A "Memory" is a bookmark, something you want to remember. - - - -
- -