upd: api project
Deskripsi: - api project tahun - api get project - qwen NoIssues
This commit is contained in:
@@ -26,14 +26,11 @@ export async function GET(request: Request) {
|
||||
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 200 });
|
||||
}
|
||||
|
||||
let grup
|
||||
let grup, tahunFilter = String(tahun)
|
||||
const dataSkip = Number(page) * 10 - 10;
|
||||
const roleUser = userMobile.idUserRole
|
||||
const villageId = userMobile.idVillage
|
||||
const userId = userMobile.id
|
||||
const tahunFilter = tahun ? tahun : new Date().getFullYear().toString();
|
||||
const startTahun = new Date(`${tahunFilter}-01-01T00:00:00.000Z`);
|
||||
const endTahun = new Date(`${parseInt(tahunFilter) + 1}-01-01T00:00:00.000Z`);
|
||||
|
||||
if (idGroup == "null" || idGroup == undefined || idGroup == "" || idGroup == "undefined") {
|
||||
grup = userMobile.idGroup
|
||||
@@ -41,6 +38,14 @@ export async function GET(request: Request) {
|
||||
grup = idGroup
|
||||
}
|
||||
|
||||
if (tahun == "null" || tahun == undefined || tahun == "" || tahun == "undefined") {
|
||||
tahunFilter = new Date().getFullYear().toString();
|
||||
}
|
||||
|
||||
const startTahun = new Date(`${tahunFilter}-01-01T00:00:00.000Z`);
|
||||
const endTahun = new Date(`${parseInt(tahunFilter) + 1}-01-01T00:00:00.000Z`);
|
||||
|
||||
|
||||
const cek = await prisma.group.count({
|
||||
where: {
|
||||
id: grup,
|
||||
@@ -151,7 +156,7 @@ export async function GET(request: Request) {
|
||||
})
|
||||
|
||||
|
||||
return NextResponse.json({ success: true, message: "Berhasil mendapatkan kegiatan", data: omitData, filter, total: totalData }, { status: 200 });
|
||||
return NextResponse.json({ success: true, message: "Berhasil mendapatkan kegiatan", data: omitData, filter, tahun: tahunFilter, total: totalData }, { status: 200 });
|
||||
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
||||
@@ -36,6 +36,11 @@ export async function GET(request: Request) {
|
||||
// (opsional) urutkan dari terbaru ke lama
|
||||
uniqueYears.sort((a, b) => b - a);
|
||||
|
||||
return NextResponse.json({ success: true, message: "Success", data: uniqueYears }, { status: 200 });
|
||||
const formattedData = uniqueYears.map(year => ({
|
||||
id: String(year),
|
||||
name: String(year)
|
||||
}));
|
||||
|
||||
return NextResponse.json({ success: true, message: "Success", data: formattedData }, { status: 200 });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user