From 2ae15e9f93ffd322b49b93ff5328174c7df59bf7 Mon Sep 17 00:00:00 2001 From: amel Date: Mon, 9 Dec 2024 14:47:35 +0800 Subject: [PATCH] upd: lainnya Deskripsi: - api get all forum (blm jadi) - loading on bussines map No Issues --- src/app/api/new/forum/route.ts | 67 +++++++++++++++++++++++++++ src/app_modules/map/ui/ui_map_new.tsx | 7 ++- 2 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 src/app/api/new/forum/route.ts diff --git a/src/app/api/new/forum/route.ts b/src/app/api/new/forum/route.ts new file mode 100644 index 00000000..84d3523a --- /dev/null +++ b/src/app/api/new/forum/route.ts @@ -0,0 +1,67 @@ +import { prisma } from "@/app/lib" +import { NextResponse } from "next/server"; +export const dynamic = "force-dynamic"; + +// GET ALL DATA PORTOFOLIO BY PROFILE ID +export async function GET(request: Request) { + try { + const { searchParams } = new URL(request.url) + const page = searchParams.get("page") + const search = searchParams.get("search") + const dataSkip = Number(page) * 5 - 5; + + const data = await prisma.forum_Posting.findMany({ + take: 5, + skip: dataSkip, + orderBy: { + createdAt: "desc", + }, + where: { + isActive: true, + diskusi: { + mode: "insensitive", + contains: (search == undefined || search == "null") ? "" : search, + }, + }, + select: { + id: true, + diskusi: true, + createdAt: true, + isActive: true, + authorId: true, + Author: { + select: { + id: true, + username: true, + Profile: { + select: { + id: true, + name: true, + imageId: true, + }, + }, + }, + }, + Forum_Komentar: { + where: { + isActive: true, + }, + }, + ForumMaster_StatusPosting: { + select: { + id: true, + status: true, + }, + }, + forumMaster_StatusPostingId: true, + }, + }); + + return NextResponse.json({ success: true, message: "Berhasil mendapatkan data", data }, { status: 200 }); + + } + catch (error) { + console.error(error); + return NextResponse.json({ success: false, message: "Gagal mendapatkan data, coba lagi nanti ", reason: (error as Error).message, }, { status: 500 }); + } +} \ No newline at end of file diff --git a/src/app_modules/map/ui/ui_map_new.tsx b/src/app_modules/map/ui/ui_map_new.tsx index 6797cee0..2ce61efc 100644 --- a/src/app_modules/map/ui/ui_map_new.tsx +++ b/src/app_modules/map/ui/ui_map_new.tsx @@ -2,7 +2,7 @@ import { APIs } from "@/app/lib"; import { AccentColor } from "@/app_modules/_global/color/color_pallet"; import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data"; -import { Avatar, Stack } from "@mantine/core"; +import { Avatar, Loader, Stack } from "@mantine/core"; import { useShallowEffect } from "@mantine/hooks"; import "mapbox-gl/dist/mapbox-gl.css"; import { useState } from "react"; @@ -44,7 +44,10 @@ export function UiMap_MapBoxViewNew({ mapboxToken, }: { mapboxToken: string }) { { loading ? - <> : + + + + :