From be3bd7993fd1d12ca6a5ed2fd4a089ac59db1264 Mon Sep 17 00:00:00 2001 From: Riccardo Date: Sun, 7 Jul 2024 17:51:49 +0200 Subject: [PATCH] ci: trigger vercel --- app/api/protected/customer-form/route.ts | 32 ++++--- app/costumer-form/page.tsx | 4 +- app/page.tsx | 110 +---------------------- 3 files changed, 24 insertions(+), 122 deletions(-) diff --git a/app/api/protected/customer-form/route.ts b/app/api/protected/customer-form/route.ts index 4ac5a85..25ef8bf 100644 --- a/app/api/protected/customer-form/route.ts +++ b/app/api/protected/customer-form/route.ts @@ -1,4 +1,5 @@ import { getSession, withApiAuthRequired } from '@auth0/nextjs-auth0'; +import { CustomerForm } from '@prisma/client'; import prisma from '@prisma/prisma'; import { randomUUID } from 'crypto'; import { NextResponse } from 'next/server'; @@ -6,20 +7,25 @@ import { NextResponse } from 'next/server'; export const GET = withApiAuthRequired(async () => { const session = await getSession(); - console.log('GET', session?.user); + try { + const userModules = await prisma.user.findUniqueOrThrow({ + where: { + email: session?.user.email + }, + include: { + CustomerForm: true + } + }); - // const userModules = await prisma.user.findUniqueOrThrow({ - // where: { - // email: session?.user.email - // }, - // include: { - // CustomerForm: true - // } - // }); + const customerForms: CustomerForm[] = userModules.CustomerForm; - // const customerForms: CustomerForm[] = userModules.CustomerForm; - - return NextResponse.json([]); + return NextResponse.json({ success: true, data: customerForms }); + } catch (error) { + return NextResponse.json( + { success: false, message: 'Something went wrong.' }, + { status: 500 } + ); + } }); export const POST = withApiAuthRequired(async request => { @@ -28,8 +34,6 @@ export const POST = withApiAuthRequired(async request => { const body = await request.json(); - console.log('POST', session?.user); - const newCustomerForm = await prisma.customerForm.create({ data: { type: body.type, diff --git a/app/costumer-form/page.tsx b/app/costumer-form/page.tsx index 5679702..6839057 100644 --- a/app/costumer-form/page.tsx +++ b/app/costumer-form/page.tsx @@ -60,7 +60,9 @@ export default function Modules() { } ); - const validatedResponse = CustomerFormSchema.safeParse(response.data); + const validatedResponse = CustomerFormSchema.safeParse( + response.data.data + ); if (!validatedResponse.success) { console.error(validatedResponse.error); diff --git a/app/page.tsx b/app/page.tsx index 273d7f2..91cac2c 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,113 +1,9 @@ -import Image from 'next/image'; - export default function Home() { return (
-
-

- Get started by editing  - app/page.tsx -

-
- - By{' '} - Vercel Logo - -
-
- -
- Next.js Logo -
- -
- -

- Docs{' '} - - -> - -

-

- Find in-depth information about Next.js features and API. -

-
- - -

- Learn{' '} - - -> - -

-

- Learn about Next.js in an interactive course with quizzes! -

-
- - -

- Templates{' '} - - -> - -

-

- Explore starter templates for Next.js. -

-
- - -

- Deploy{' '} - - -> - -

-

- Instantly deploy your Next.js site to a shareable URL with Vercel. -

-
-
+

+ Next.js + Auth0 Starter +

); }