From ea02e7afa1ea71b6a4bc8e6d30735a7067465171 Mon Sep 17 00:00:00 2001 From: sabovyan Date: Sun, 26 Nov 2023 14:38:50 +0400 Subject: [PATCH 01/15] make anchor text smaller --- components/Anchor.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/Anchor.tsx b/components/Anchor.tsx index dea7dde..282ade7 100644 --- a/components/Anchor.tsx +++ b/components/Anchor.tsx @@ -4,5 +4,5 @@ import { RouteType } from 'next/dist/lib/load-custom-routes'; import Link, { LinkProps } from 'next/link'; export function Anchor(props: PropsWithChildren>) { - return ; + return ; } From 2ff2693a50b9fa0725c3bbcc07cdc69aa8022e14 Mon Sep 17 00:00:00 2001 From: sabovyan Date: Sun, 26 Nov 2023 15:49:59 +0400 Subject: [PATCH 02/15] [spaces] add routes and navigation --- app/page.tsx | 2 +- app/spaces/add/page.tsx | 22 +++++++++ app/spaces/edit/page.tsx | 7 +++ app/spaces/page.tsx | 41 ++++++++++++++++ components/Nav.tsx | 5 +- components/SpacesNav.tsx | 36 ++++++++++++++ lib/prisma.ts | 8 ++-- .../20231126110633_spaces/migration.sql | 48 +++++++++++++++++++ .../migration.sql | 16 +++++++ .../20231126111343_remove_admin/migration.sql | 11 +++++ .../20231126112121_spaces_typo/migration.sql | 44 +++++++++++++++++ prisma/schema.prisma | 14 ++---- 12 files changed, 237 insertions(+), 17 deletions(-) create mode 100644 app/spaces/add/page.tsx create mode 100644 app/spaces/edit/page.tsx create mode 100644 app/spaces/page.tsx create mode 100644 components/SpacesNav.tsx create mode 100644 prisma/migrations/20231126110633_spaces/migration.sql create mode 100644 prisma/migrations/20231126110936_change_field_to_admin_id/migration.sql create mode 100644 prisma/migrations/20231126111343_remove_admin/migration.sql create mode 100644 prisma/migrations/20231126112121_spaces_typo/migration.sql diff --git a/app/page.tsx b/app/page.tsx index 32d50fe..f4340c2 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,7 +1,7 @@ export default function Home() { return (
-

main content

+

hello

); } diff --git a/app/spaces/add/page.tsx b/app/spaces/add/page.tsx new file mode 100644 index 0000000..fcf6ae5 --- /dev/null +++ b/app/spaces/add/page.tsx @@ -0,0 +1,22 @@ +import { FormField } from '@/components/formField'; +import { Button } from '@/components/ui/button'; + +export default function NewSpace() { + return ( +
+

ADD NEW SPACE

+ +
+ + + + + +
+ ); +} diff --git a/app/spaces/edit/page.tsx b/app/spaces/edit/page.tsx new file mode 100644 index 0000000..371d02e --- /dev/null +++ b/app/spaces/edit/page.tsx @@ -0,0 +1,7 @@ +export default function NewSpace() { + return ( +
+

EDIT

+
+ ); +} diff --git a/app/spaces/page.tsx b/app/spaces/page.tsx new file mode 100644 index 0000000..66ac23c --- /dev/null +++ b/app/spaces/page.tsx @@ -0,0 +1,41 @@ +import { redirect } from 'next/navigation'; + +import { auth } from '@/lib/auth'; +import { prisma } from '@/lib/prisma'; + +export default async function Groups() { + const session = await auth(); + + const email = session?.user?.email; + + if (!email) { + redirect('/'); + } + + const user = await prisma.user.findUnique({ + where: { + email + }, + include: { + spaces: true + } + }); + + if (!user) { + // TODO handle it - either redirect it to sign it page or show not sign in view + throw new Error('handle it'); + } + + return ( +
+
+

Your Space Management

+
+ {user.spaces.length ? ( +
your spaces
+ ) : ( +
no space was found
+ )} +
+ ); +} diff --git a/components/Nav.tsx b/components/Nav.tsx index 0bbfa58..3bcb2eb 100644 --- a/components/Nav.tsx +++ b/components/Nav.tsx @@ -4,6 +4,7 @@ import { userAgent } from 'next/server'; import { auth } from '@/lib/auth'; // import { AddExpense } from './AddExpense/AddExpense'; +import { SpacesNav } from './SpacesNav'; import { UserAccount } from './UserAccount/UserAccount'; export async function Nav() { @@ -14,9 +15,11 @@ export async function Nav() { const session = await auth(); return ( -