API Table Kategori Donasi
This commit is contained in:
44
src/app/api/admin/donasi/kategori/route.ts
Normal file
44
src/app/api/admin/donasi/kategori/route.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { prisma } from "@/app/lib";
|
||||
import backendLogger from "@/util/backendLogger";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
export async function GET(request: Request) {
|
||||
const method = request.method;
|
||||
if (method !== "GET") {
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
message: "Method nol allowed"
|
||||
},
|
||||
{ status: 405 }
|
||||
)
|
||||
}
|
||||
try {
|
||||
const data = await prisma.donasiMaster_Kategori.findMany({
|
||||
orderBy: {
|
||||
createdAt: 'asc'
|
||||
},
|
||||
where: {
|
||||
|
||||
active: true
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
message: "Success get kategori",
|
||||
data: data
|
||||
})
|
||||
} catch (error) {
|
||||
backendLogger.error("Error get kategori", error);
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
message: "Failed get kategori",
|
||||
reason: (error as Error).message
|
||||
},
|
||||
{ status: 500 }
|
||||
)
|
||||
} finally {
|
||||
await prisma.$disconnect
|
||||
}
|
||||
}
|
||||
@@ -2,11 +2,11 @@ import { AdminDonasi_TableKategori } from "@/app_modules/admin/donasi";
|
||||
import adminDonasi_getMasterKategori from "@/app_modules/admin/donasi/fun/master/get_list_kategori";
|
||||
|
||||
export default async function Page() {
|
||||
const listKategori = await adminDonasi_getMasterKategori();
|
||||
// const listKategori = await adminDonasi_getMasterKategori();
|
||||
|
||||
return (
|
||||
<>
|
||||
<AdminDonasi_TableKategori listKategori={listKategori} />
|
||||
<AdminDonasi_TableKategori />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user