diff --git a/src/app/api/profile/edit/route.ts b/src/app/api/profile/edit/route.ts new file mode 100644 index 00000000..d41cd1d4 --- /dev/null +++ b/src/app/api/profile/edit/route.ts @@ -0,0 +1,33 @@ +import { myConsole } from "@/app/fun/my_console"; +import prisma from "@/app/lib/prisma"; +import { NextResponse } from "next/server"; + +export async function POST(req: Request) { + if (req.method === "POST") { + const body = await req.json(); + // myConsole(body); + + const data = await prisma.profile.update({ + where: { + id: body.id + }, + data: { + name: body.name, + email: body.email, + alamat: body.alamat, + jenisKelamin: body.jenisKelamin + } + }) + + if(data) { + return NextResponse.json({status: 200}) + } else { + return new Response("Error",{ status :401 }); + } + + + + return NextResponse.json({ success: true }); + } + return NextResponse.json({ success: false }); +} diff --git a/src/app/dev/katalog/profile/edit/layout.tsx b/src/app/dev/katalog/profile/edit/layout.tsx new file mode 100644 index 00000000..9b8d49f1 --- /dev/null +++ b/src/app/dev/katalog/profile/edit/layout.tsx @@ -0,0 +1,9 @@ +import { EditProfileLayout } from "@/app_modules/katalog/profile"; + +export default function Layout({ children }: { children: any }) { + return ( + <> + {children} + + ); +} diff --git a/src/app/dev/katalog/profile/edit/page.tsx b/src/app/dev/katalog/profile/edit/page.tsx new file mode 100644 index 00000000..a1684084 --- /dev/null +++ b/src/app/dev/katalog/profile/edit/page.tsx @@ -0,0 +1,13 @@ +import { getProfile } from "@/app_modules/katalog/profile"; +import EditProfile from "@/app_modules/katalog/profile/edit/view"; + +export default async function Page() { + const data = await getProfile(); + + return ( + <> + {/* {JSON.stringify(data)} */} + + + ); +} diff --git a/src/app/dev/katalog/view/page.tsx b/src/app/dev/katalog/view/page.tsx index 5463ee42..62de781d 100644 --- a/src/app/dev/katalog/view/page.tsx +++ b/src/app/dev/katalog/view/page.tsx @@ -1,7 +1,12 @@ +import { getProfile } from "@/app_modules/katalog/profile"; import { KatalogView } from "@/app_modules/katalog/view"; export default async function Page() { - return <> - + const data = await getProfile(); + return ( + <> + {/* {JSON.stringify(data)} */} + -} \ No newline at end of file + ); +} diff --git a/src/app/fun/my_console.ts b/src/app/fun/my_console.ts index 631977d6..3be763da 100644 --- a/src/app/fun/my_console.ts +++ b/src/app/fun/my_console.ts @@ -1,5 +1,5 @@ export function myConsole(value: any) { - const onData = false; + const onData = true; if (onData) { console.log(value); }