diff --git a/apps/web/src/app/page.tsx b/apps/web/src/app/page.tsx index ccceffe0..f3dc1bd4 100644 --- a/apps/web/src/app/page.tsx +++ b/apps/web/src/app/page.tsx @@ -7,13 +7,10 @@ import { storedContent, users, } from "@/server/db/schema"; -import { eq, inArray } from "drizzle-orm"; +import { and, eq, inArray, not } from "drizzle-orm"; import { cookies, headers } from "next/headers"; import { redirect } from "next/navigation"; -import Sidebar from "@/components/Sidebar/index"; -import Main from "@/components/Main"; -import MessagePoster from "./MessagePoster"; -import { transformContent } from "../../types/memory"; +import { fetchContentForSpace, fetchFreeMemories, transformContent } from "../../types/memory"; import { MemoryProvider } from "@/contexts/MemoryContext"; import Content from "./content"; @@ -49,35 +46,36 @@ export default async function Home() { return redirect("/api/auth/signin"); } - // Fetch all content for the user - const contents = await db + + const collectedSpaces = await db .select() - .from(storedContent) - .where(eq(storedContent.user, userData.id)) - .all(); + .from(space) + .where( + and(eq(storedContent.user, userData.id), not(eq(space.name, "none"))), + ); - const collectedSpaces = - contents.length > 0 ? await transformContent(contents) : []; - // collectedSpaces.push({ - // id: 2, - // title: "Test", - // content: [ - // { - // id: 1, - // content: "Test", - // title: "Vscode", - // description: "Test", - // url: "https://vscode-remake.vercel.app/", - // savedAt: new Date(), - // baseUrl: "https://vscode-remake.vercel.app/", - // image: "https://vscode-remake.vercel.app/favicon.svg", - // }, - // ], - // }); + // Fetch only first 3 content of each spaces + let contents: typeof storedContent.$inferSelect[] = [] + + await Promise.all([collectedSpaces.forEach(async (space) => { + contents = [...contents, ...(await fetchContentForSpace(space.id, { + offset: 0, + limit: 3 + }))] + })]) + + // freeMemories + const freeMemories = await fetchFreeMemories(userData.id) + + collectedSpaces.push({ + id: 1, + name: "Cool tech", + user: null, + }); return ( - + {/* */} diff --git a/apps/web/src/components/Sidebar/CategoryItem.tsx b/apps/web/src/components/Sidebar/CategoryItem.tsx deleted file mode 100644 index 7fb571b5..00000000 --- a/apps/web/src/components/Sidebar/CategoryItem.tsx +++ /dev/null @@ -1,298 +0,0 @@ -"use client"; -import { cleanUrl } from "@/lib/utils"; -import { StoredContent } from "@/server/db/schema"; -import { - DropdownMenu, - DropdownMenuTrigger, - DropdownMenuContent, - DropdownMenuItem, -} from "../ui/dropdown-menu"; -import { Label } from "../ui/label"; -import { - ArrowUpRight, - MoreHorizontal, - Tags, - ChevronDown, - Edit3, - Trash2, - Save, - ChevronRight, - Plus, - Minus, -} from "lucide-react"; -import { useState } from "react"; -import { - Drawer, - DrawerContent, - DrawerHeader, - DrawerTitle, - DrawerDescription, - DrawerFooter, - DrawerClose, -} from "../ui/drawer"; -import { Input } from "../ui/input"; -import { Textarea } from "../ui/textarea"; -import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover"; -import { - AnimatePresence, - motion, - Reorder, - useMotionValue, -} from "framer-motion"; - -const pages: StoredContent[] = [ - { - id: 1, - content: "", - title: "Visual Studio Code", - url: "https://code.visualstudio.com", - description: "", - image: "https://code.visualstudio.com/favicon.ico", - baseUrl: "https://code.visualstudio.com", - savedAt: new Date(), - }, - { - id: 2, - content: "", - title: "yxshv/vscode: An unofficial remake of vscode's landing page", - url: "https://github.com/yxshv/vscode", - description: "", - image: "https://github.com/favicon.ico", - baseUrl: "https://github.com", - savedAt: new Date(), - }, - { - id: 3, - content: "", - title: "yxshv/vscode: An unofficial remake of vscode's landing page", - url: "https://github.com/yxshv/vscode", - description: "", - image: "https://github.com/favicon.ico", - baseUrl: "https://github.com", - savedAt: new Date(), - }, - { - id: 4, - content: "", - title: "yxshv/vscode: An unofficial remake of vscode's landing page", - url: "https://github.com/yxshv/vscode", - description: "", - image: "https://github.com/favicon.ico", - baseUrl: "https://github.com", - savedAt: new Date(), - }, - { - id: 5, - content: "", - title: "yxshv/vscode: An unofficial remake of vscode's landing page", - url: "https://github.com/yxshv/vscode", - description: "", - image: "https://github.com/favicon.ico", - baseUrl: "https://github.com", - savedAt: new Date(), - }, - { - id: 6, - content: "", - title: "yxshv/vscode: An unofficial remake of vscode's landing page", - url: "https://github.com/yxshv/vscode", - description: "", - image: "https://github.com/favicon.ico", - baseUrl: "https://github.com", - savedAt: new Date(), - }, - { - id: 7, - content: "", - title: "yxshv/vscode: An unofficial remake of vscode's landing page", - url: "https://github.com/yxshv/vscode", - description: "", - image: "https://github.com/favicon.ico", - baseUrl: "https://github.com", - savedAt: new Date(), - }, - { - id: 8, - content: "", - title: "yxshv/vscode: An unofficial remake of vscode's landing page", - url: "https://github.com/yxshv/vscode", - description: "", - image: "https://github.com/favicon.ico", - baseUrl: "https://github.com", - savedAt: new Date(), - }, - { - id: 9, - content: "", - title: "yxshv/vscode: An unofficial remake of vscode's landing page", - url: "https://github.com/yxshv/vscode", - description: "", - image: "https://github.com/favicon.ico", - baseUrl: "https://github.com", - savedAt: new Date(), - }, -]; -export const CategoryItem: React.FC<{ item: StoredContent }> = ({ item }) => { - const [isExpanded, setIsExpanded] = useState(false); - const [isEditDrawerOpen, setIsEditDrawerOpen] = useState(false); - - const [items, setItems] = useState(pages); - - return ( - <> -
- - - - - - Edit Page Details - - Change the page details - - - {cleanUrl(item.url)} - - - -
- - -
-
- -