Investmen & Donation
Add:
src/app/api/mobile/donation/
src/app/api/mobile/investment/[id]/news/
src/app/api/mobile/master/donation/
### No Issue
This commit is contained in:
72
src/app/api/mobile/master/donation/route.ts
Normal file
72
src/app/api/mobile/master/donation/route.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
export { GET };
|
||||
|
||||
async function GET(request: Request) {
|
||||
const { searchParams } = new URL(request.url);
|
||||
const category = searchParams.get("category");
|
||||
console.log("[CATEGORY]", category);
|
||||
let fixData;
|
||||
|
||||
try {
|
||||
// CODE HERE
|
||||
|
||||
if (category === "category") {
|
||||
fixData = await prisma.donasiMaster_Kategori.findMany({
|
||||
orderBy: {
|
||||
createdAt: "asc",
|
||||
},
|
||||
where: {
|
||||
active: true,
|
||||
},
|
||||
});
|
||||
} else if (category === "duration") {
|
||||
fixData = await prisma.donasiMaster_Durasi.findMany({
|
||||
orderBy: {
|
||||
createdAt: "asc",
|
||||
},
|
||||
where: {
|
||||
active: true,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
const category = await prisma.donasiMaster_Kategori.findMany({
|
||||
orderBy: {
|
||||
createdAt: "asc",
|
||||
},
|
||||
where: {
|
||||
active: true,
|
||||
},
|
||||
});
|
||||
|
||||
const duration = await prisma.donasiMaster_Durasi.findMany({
|
||||
orderBy: {
|
||||
createdAt: "asc",
|
||||
},
|
||||
where: {
|
||||
active: true,
|
||||
},
|
||||
});
|
||||
|
||||
fixData = {
|
||||
category: category,
|
||||
duration: duration,
|
||||
};
|
||||
}
|
||||
|
||||
return NextResponse.json({
|
||||
status: 200,
|
||||
success: true,
|
||||
message: "Master berhasil diambil",
|
||||
data: fixData,
|
||||
});
|
||||
} catch (error) {
|
||||
console.log("[ERROR]", error);
|
||||
return NextResponse.json({
|
||||
status: 500,
|
||||
success: false,
|
||||
error: "Gagal mengambil data master",
|
||||
reason: (error as Error).message,
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user