Compare commits
2 Commits
mobile-api
...
v1.5.6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa8dec5391 | ||
|
|
fd09783c19 |
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.5.6](https://wibugit.wibudev.com/bip/hipmi/compare/v1.5.5...v1.5.6) (2025-10-21)
|
||||||
|
|
||||||
## [1.5.5](https://wibugit.wibudev.com/bip/hipmi/compare/v1.5.4...v1.5.5) (2025-10-20)
|
## [1.5.5](https://wibugit.wibudev.com/bip/hipmi/compare/v1.5.4...v1.5.5) (2025-10-20)
|
||||||
|
|
||||||
## [1.5.4](https://wibugit.wibudev.com/bip/hipmi/compare/v1.5.3...v1.5.4) (2025-10-17)
|
## [1.5.4](https://wibugit.wibudev.com/bip/hipmi/compare/v1.5.3...v1.5.4) (2025-10-17)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hipmi",
|
"name": "hipmi",
|
||||||
"version": "1.5.5",
|
"version": "1.5.6",
|
||||||
"private": true,
|
"private": true,
|
||||||
"prisma": {
|
"prisma": {
|
||||||
"seed": "bun prisma/seed.ts"
|
"seed": "bun prisma/seed.ts"
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { prisma } from "@/lib";
|
import { prisma } from "@/lib";
|
||||||
|
import _ from "lodash";
|
||||||
|
|
||||||
export { GET };
|
export { GET , PUT};
|
||||||
|
|
||||||
async function GET(request: Request, { params }: { params: { id: string } }) {
|
async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||||
const { id } = params;
|
const { id } = params;
|
||||||
@@ -36,3 +37,73 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||||
|
const { id } = params;
|
||||||
|
const { data } = await request.json();
|
||||||
|
const { searchParams } = new URL(request.url);
|
||||||
|
const status = searchParams.get("status");
|
||||||
|
const fixStatus = _.startCase(status as string);
|
||||||
|
let fixData;
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
const checkStatus = await prisma.voting_Status.findFirst({
|
||||||
|
where: {
|
||||||
|
name: fixStatus,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!checkStatus)
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "Error update data voting",
|
||||||
|
reason: "Status not found",
|
||||||
|
},
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
|
|
||||||
|
if (fixStatus === "Reject") {
|
||||||
|
const updateStatus = await prisma.voting.update({
|
||||||
|
where: {
|
||||||
|
id: id,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
voting_StatusId: checkStatus.id,
|
||||||
|
catatan: data,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
fixData = updateStatus;
|
||||||
|
} else if (fixStatus === "Publish") {
|
||||||
|
const updateStatus = await prisma.voting.update({
|
||||||
|
where: {
|
||||||
|
id: id,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
voting_StatusId: checkStatus.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
fixData = updateStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: true,
|
||||||
|
message: "Success update data voting",
|
||||||
|
data: fixData,
|
||||||
|
},
|
||||||
|
{ status: 200 }
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR UPDATE DATA VOTING]", error);
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "Error update data voting",
|
||||||
|
reason: (error as Error).message,
|
||||||
|
},
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -15,9 +15,6 @@ async function GET(request: Request) {
|
|||||||
const skipData = Number(page) * takeData - takeData;
|
const skipData = Number(page) * takeData - takeData;
|
||||||
let fixData;
|
let fixData;
|
||||||
|
|
||||||
console.log("CATEGORY", category);
|
|
||||||
console.log("FIX TO STATUS", fixToStatus);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (category === "dashboard") {
|
if (category === "dashboard") {
|
||||||
const publish = await prisma.voting.count({
|
const publish = await prisma.voting.count({
|
||||||
@@ -79,8 +76,44 @@ async function GET(request: Request) {
|
|||||||
history,
|
history,
|
||||||
};
|
};
|
||||||
} else if (category === "history") {
|
} else if (category === "history") {
|
||||||
|
fixData = await prisma.voting.findMany({
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
|
orderBy: {
|
||||||
|
updatedAt: "desc",
|
||||||
|
},
|
||||||
|
where: {
|
||||||
|
Voting_Status: {
|
||||||
|
name: "Publish",
|
||||||
|
},
|
||||||
|
isActive: true,
|
||||||
|
isArsip: false,
|
||||||
|
akhirVote: {
|
||||||
|
lte: new Date(),
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
contains: search ? search : "",
|
||||||
|
mode: "insensitive",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
include: {
|
||||||
|
Author: {
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
username: true,
|
||||||
|
Profile: {
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
name: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Voting_Kontributor: true,
|
||||||
|
Voting_DaftarNamaVote: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// ====== Status Publish Start ====== //
|
// ====== Status Publish Start ====== //
|
||||||
if (fixToStatus === "Publish") {
|
if (fixToStatus === "Publish") {
|
||||||
const getAllData = await prisma.voting.findMany({
|
const getAllData = await prisma.voting.findMany({
|
||||||
|
|||||||
Reference in New Issue
Block a user