From f420dc7616b2e66564a23881a9a2aec7f34df4e0 Mon Sep 17 00:00:00 2001 From: Dhravya Date: Sat, 29 Jun 2024 09:34:28 -0500 Subject: schema --- apps/web/app/(dash)/dynamicisland.tsx | 315 ----------- apps/web/app/(dash)/layout.tsx | 2 +- apps/web/app/(dash)/memories/page.tsx | 93 ++-- apps/web/app/(dash)/menu.tsx | 5 +- apps/web/app/actions/fetchers.ts | 11 +- apps/web/app/actions/types.ts | 1 + apps/web/migrations/0000_classy_speed_demon.sql | 113 ++++ apps/web/migrations/meta/0000_snapshot.json | 685 ++++++++++++++++++++++++ apps/web/migrations/meta/_journal.json | 13 + apps/web/server/db/schema.ts | 1 + package.json | 6 +- 11 files changed, 877 insertions(+), 368 deletions(-) delete mode 100644 apps/web/app/(dash)/dynamicisland.tsx create mode 100644 apps/web/migrations/0000_classy_speed_demon.sql create mode 100644 apps/web/migrations/meta/0000_snapshot.json create mode 100644 apps/web/migrations/meta/_journal.json diff --git a/apps/web/app/(dash)/dynamicisland.tsx b/apps/web/app/(dash)/dynamicisland.tsx deleted file mode 100644 index 8b1b4633..00000000 --- a/apps/web/app/(dash)/dynamicisland.tsx +++ /dev/null @@ -1,315 +0,0 @@ -"use client"; - -import { AddIcon } from "@repo/ui/icons"; -import Image from "next/image"; - -import { AnimatePresence, useMotionValueEvent, useScroll } from "framer-motion"; -import { useActionState, useEffect, useRef, useState } from "react"; -import { motion } from "framer-motion"; -import { Label } from "@repo/ui/shadcn/label"; -import { Input } from "@repo/ui/shadcn/input"; -import { Textarea } from "@repo/ui/shadcn/textarea"; -import { createMemory, createSpace } from "../actions/doers"; -import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue, -} from "@repo/ui/shadcn/select"; -import { Space } from "../actions/types"; -import { getSpaces } from "../actions/fetchers"; -import { toast } from "sonner"; -import { useFormStatus } from "react-dom"; - -export function DynamicIsland() { - const { scrollYProgress } = useScroll(); - const [visible, setVisible] = useState(true); - - useMotionValueEvent(scrollYProgress, "change", (current) => { - if (typeof current === "number") { - let direction = current! - scrollYProgress.getPrevious()!; - - if (direction < 0 || direction === 1) { - setVisible(true); - } else { - setVisible(false); - } - } - }); - - return ( -
- - - - - -
- ); -} - -export default DynamicIsland; - -function DynamicIslandContent() { - const [show, setshow] = useState(true); - function cancelfn() { - setshow(true); - } - - const lastBtn = useRef(); - - useEffect(() => { - document.addEventListener("keydown", (e) => { - if (e.key === "Escape") { - setshow(true); - } - - if (e.key === "a" && lastBtn.current === "Alt") { - setshow(false); - } - lastBtn.current = e.key; - }); - }, []); - return ( - <> - {show ? ( - - ) : ( - - )} - - ); -} - -const fakeitems = ["page", "spaces"]; - -function ToolBar({ cancelfn }: { cancelfn: () => void }) { - const [spaces, setSpaces] = useState([]); - - const [index, setIndex] = useState(0); - - 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 ( - - -
- setIndex(i)} - /> -
- {index === 1 ? ( - - ) : ( - - )} -
-
- ); -} - -export const HoverEffect = ({ - items, - index, - indexFn, -}: { - items: string[]; - index: number; - indexFn: (i: number) => void; -}) => { - return ( -
- {items.map((item, idx) => ( - - ))} -
- ); -}; - -function SpaceForm({ cancelfn }: { cancelfn: () => void }) { - return ( -
-
- - -
-
- {/* - pull from store - */} - {/*
- cancel -
*/} - -
-
- ); -} - -function PageForm({ - cancelfn, - spaces, -}: { - cancelfn: () => void; - spaces: Space[]; -}) { - const [loading, setLoading] = useState(false); - - const { pending } = useFormStatus(); - return ( -
{ - const content = e.get("content")?.toString(); - const space = e.get("space")?.toString(); - - toast.info("Creating memory..."); - - if (!content) { - toast.error("Content is required"); - return; - } - cancelfn(); - const cont = await createMemory({ - content: content, - spaces: space ? [space] : undefined, - }); - - if (cont.success) { - toast.success("Memory created"); - } else { - toast.error("Memory creation failed"); - } - }} - className="bg-secondary border border-muted-foreground px-4 py-3 rounded-2xl mt-2 flex flex-col gap-3 w-[100vw] md:w-[400px]" - > -
- - -
-
- -