From 2b68db0e7b786c809616353da0a811ab60e67030 Mon Sep 17 00:00:00 2001 From: sabovyan Date: Sun, 15 Sep 2024 07:35:14 +0400 Subject: [PATCH] rest --- middleware.ts => _middleware.ts | 0 app/page.tsx | 45 +++++++++- .../@list/components/ListCompoent.tsx | 6 +- .../[spaceId]/lists/[listId]/@list/page.tsx | 78 +----------------- .../lists/[listId]/effective_react.jpg | Bin 0 -> 77914 bytes app/spaces/[spaceId]/lists/[listId]/page.tsx | 1 + app/spaces/[spaceId]/page.tsx | 20 +---- components/ListItem.tsx | 73 ++++++++++++++++ pnpm-lock.yaml | 31 ------- utils/listItem.ts | 14 ++++ 10 files changed, 137 insertions(+), 131 deletions(-) rename middleware.ts => _middleware.ts (100%) create mode 100644 app/spaces/[spaceId]/lists/[listId]/effective_react.jpg create mode 100644 components/ListItem.tsx create mode 100644 utils/listItem.ts diff --git a/middleware.ts b/_middleware.ts similarity index 100% rename from middleware.ts rename to _middleware.ts diff --git a/app/page.tsx b/app/page.tsx index f4340c2..f2d3694 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,7 +1,48 @@ -export default function Home() { +import { SpaceList } from '@/components/ListItem'; +import { auth } from '@/lib/auth'; +import { prisma } from '@/lib/prisma'; + +export default async function Home() { + const session = await auth(); + + if (!session) { + return ( +
+

hello

+
+ ); + } + + const lists = await prisma.list.findMany({ + where: { + favorite: true, + creatorId: session.user.id + }, + include: { + items: { + include: { + creator: { + select: { + name: true + } + } + } + } + } + }); + return (
-

hello

+
+

Favorites

+ {lists.length > 0 && ( +
    + {lists.map((list) => ( + + ))} +
+ )} +
); } diff --git a/app/spaces/[spaceId]/lists/[listId]/@list/components/ListCompoent.tsx b/app/spaces/[spaceId]/lists/[listId]/@list/components/ListCompoent.tsx index c4bf670..f2983e0 100644 --- a/app/spaces/[spaceId]/lists/[listId]/@list/components/ListCompoent.tsx +++ b/app/spaces/[spaceId]/lists/[listId]/@list/components/ListCompoent.tsx @@ -14,10 +14,10 @@ type ListItems = Array<{ type Props = { type: 'ONGOING' | 'COMPLETED'; - items: List; + items?: List; listId: string; spaceId: string; - title: string; + title?: string; }; export function ListComponent({ @@ -29,7 +29,7 @@ export function ListComponent({ }: Props) { return ( <> -

{title}

+ {title &&

{title}

}