From 354f3cbd85fb104defd190dd5868ac2c014f21ea Mon Sep 17 00:00:00 2001 From: amel Date: Wed, 2 Oct 2024 10:57:36 +0800 Subject: [PATCH] upd: baner Deskripsi: - banner No Issues --- src/app/(application)/banner/create/page.tsx | 3 +++ .../(application)/banner/edit/[id]/page.tsx | 3 +++ src/app/(application)/banner/page.tsx | 3 +++ src/app/api/discussion/route.ts | 24 ++++++++++++++++++- src/module/banner/index.ts | 1 + src/module/banner/lib/git.keep | 0 src/module/banner/ui/git.keep | 0 7 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 src/app/(application)/banner/create/page.tsx create mode 100644 src/app/(application)/banner/edit/[id]/page.tsx create mode 100644 src/app/(application)/banner/page.tsx create mode 100644 src/module/banner/index.ts create mode 100644 src/module/banner/lib/git.keep create mode 100644 src/module/banner/ui/git.keep diff --git a/src/app/(application)/banner/create/page.tsx b/src/app/(application)/banner/create/page.tsx new file mode 100644 index 0000000..78a7dff --- /dev/null +++ b/src/app/(application)/banner/create/page.tsx @@ -0,0 +1,3 @@ +export default function Page() { + return
Tambah Banner
; +} \ No newline at end of file diff --git a/src/app/(application)/banner/edit/[id]/page.tsx b/src/app/(application)/banner/edit/[id]/page.tsx new file mode 100644 index 0000000..6dea5fd --- /dev/null +++ b/src/app/(application)/banner/edit/[id]/page.tsx @@ -0,0 +1,3 @@ +export default function Page({ params }: { params: { id: string } }) { + return
Edit Banner
; +} \ No newline at end of file diff --git a/src/app/(application)/banner/page.tsx b/src/app/(application)/banner/page.tsx new file mode 100644 index 0000000..057359c --- /dev/null +++ b/src/app/(application)/banner/page.tsx @@ -0,0 +1,3 @@ +export default function Page() { + return
List Banner
; +} \ No newline at end of file diff --git a/src/app/api/discussion/route.ts b/src/app/api/discussion/route.ts index afce46f..6cadf5f 100644 --- a/src/app/api/discussion/route.ts +++ b/src/app/api/discussion/route.ts @@ -100,6 +100,9 @@ export async function POST(request: Request) { return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 }); } + const userRoleLogin = user.idUserRole + const userId = user.id + const { idDivision, desc } = (await request.json()); const cekDivision = await prisma.division.count({ @@ -148,6 +151,25 @@ export async function POST(request: Request) { desc: 'Terdapat diskusi baru. Silahkan periksa detailnya.' })) + if (userRoleLogin != "supadmin") { + const perbekel = await prisma.user.findFirst({ + where: { + isActive: true, + idUserRole: "supadmin", + idVillage: user.idVillage + } + }) + + dataNotif.push({ + idUserTo: perbekel?.id, + idUserFrom: userId, + category: 'division/' + idDivision + '/discussion', + idContent: data.id, + title: 'Diskusi Baru', + desc: 'Terdapat diskusi baru. Silahkan periksa detailnya.' + }) + } + const insertNotif = await prisma.notifications.createMany({ data: dataNotif }) @@ -155,7 +177,7 @@ export async function POST(request: Request) { // create log user const log = await createLogUser({ act: 'CREATE', desc: 'User membuat data diskusi', table: 'divisionDisscussion', data: data.id }) - return NextResponse.json({ success: true, message: "Berhasil menambahkan diskusi", data, }, { status: 200 }); + return NextResponse.json({ success: true, message: "Berhasil menambahkan diskusi", notif: dataNotif }, { status: 200 }); } catch (error) { console.error(error); return NextResponse.json({ success: false, message: "Gagal menambahkan diskusi, coba lagi nanti", reason: (error as Error).message, }, { status: 500 }); diff --git a/src/module/banner/index.ts b/src/module/banner/index.ts new file mode 100644 index 0000000..0a07d17 --- /dev/null +++ b/src/module/banner/index.ts @@ -0,0 +1 @@ +//cobaa \ No newline at end of file diff --git a/src/module/banner/lib/git.keep b/src/module/banner/lib/git.keep new file mode 100644 index 0000000..e69de29 diff --git a/src/module/banner/ui/git.keep b/src/module/banner/ui/git.keep new file mode 100644 index 0000000..e69de29