From a3f9592cfc05b99fd8a846aa676bd545be32ff3b Mon Sep 17 00:00:00 2001 From: Bagasbanuna02 Date: Mon, 22 Sep 2025 11:14:35 +0800 Subject: [PATCH] Voting Add: - Status publish api: list arsip ### No Issue --- .../api/mobile/voting/[id]/[status]/route.ts | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/src/app/api/mobile/voting/[id]/[status]/route.ts b/src/app/api/mobile/voting/[id]/[status]/route.ts index 23295d65..ee836fef 100644 --- a/src/app/api/mobile/voting/[id]/[status]/route.ts +++ b/src/app/api/mobile/voting/[id]/[status]/route.ts @@ -14,19 +14,36 @@ async function GET( const fixStatusName = _.startCase(status); console.log("[STATUS]", fixStatusName); - const data = await prisma.voting.findMany({ - where: { - authorId: id, - Voting_Status: { - name: fixStatusName, + let fixData; + + if (fixStatusName === "Publish") { + fixData = await prisma.voting.findMany({ + where: { + authorId: id, + isActive: true, + akhirVote: { + gte: new Date(), + }, + Voting_Status: { + name: fixStatusName, + }, }, - }, - }); + }); + } else { + fixData = await prisma.voting.findMany({ + where: { + authorId: id, + Voting_Status: { + name: fixStatusName, + }, + }, + }); + } return NextResponse.json({ success: true, message: "Success get voting", - data: data, + data: fixData, }); } catch (error) { console.log("[ERROR]", error);