Merge pull request 'API Mobile: Donatiion' (#30) from mobile/7-oct-25 into staging

Reviewed-on: bip/hipmi#30
This commit is contained in:
2025-10-07 11:46:52 +08:00
4 changed files with 63 additions and 12 deletions

View File

@@ -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.
## [1.4.45](https://wibugit.wibudev.com/bip/hipmi/compare/v1.4.44...v1.4.45) (2025-10-06)
## [1.4.44](https://wibugit.wibudev.com/bip/hipmi/compare/v1.4.43...v1.4.44) (2025-10-02)
## [1.4.43](https://wibugit.wibudev.com/bip/hipmi/compare/v1.4.42...v1.4.43) (2025-09-29)

View File

@@ -1,6 +1,6 @@
{
"name": "hipmi",
"version": "1.4.44",
"version": "1.4.45",
"private": true,
"prisma": {
"seed": "bun prisma/seed.ts"

View File

@@ -9,9 +9,6 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
const category = searchParams.get("category");
let fixData;
console.log("[ID]", id);
console.log("[CATEGORY]", category);
try {
if (category === "temporary") {
fixData = await prisma.donasi_TemporaryCreate.findUnique({
@@ -61,8 +58,6 @@ async function DELETE(
) {
try {
const id = params.id;
console.log("[ID]", id);
const checkData = await prisma.donasi.findUnique({
where: {
id: id,
@@ -76,8 +71,6 @@ async function DELETE(
},
});
console.log(["DATA"], checkData);
const deleteStory = await prisma.donasi_Cerita.delete({
where: {
donasiId: id,
@@ -154,10 +147,6 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
const { searchParams } = new URL(request.url);
const category = searchParams.get("category");
console.log("[ID]", id);
console.log("[DATA]", data);
console.log("[CATEGORY]", category);
try {
if (category === "edit-donation") {
if (data && data.newImageId) {
@@ -203,8 +192,67 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
if (!deleteImageDonasi) {
console.log("[DELETE IMAGE DONASI]", deleteImageDonasi);
}
} else if (category === "edit-story") {
if (data && data.newImageId) {
await prisma.donasi_Cerita.update({
where: {
donasiId: id,
},
data: {
imageId: data.newImageId,
},
});
}
const update = await prisma.donasi_Cerita.update({
where: {
donasiId: id,
},
data: {
pembukaan: data.pembukaan,
cerita: data.cerita,
},
});
if (!update)
return NextResponse.json({
status: 400,
success: false,
reason: "Gagal mengupdate cerita donasi",
});
const deleteImageStory = await fetch(
`https://wibu-storage.wibudev.com/api/files/${data.imageId}/delete`,
{
method: "DELETE",
headers: {
Authorization: `Bearer ${process.env.WS_APIKEY}`,
},
}
);
if (!deleteImageStory) {
console.log("[DELETE IMAGE STORY]", deleteImageStory);
}
} else if (category === "edit-bank-account") {
const update = await prisma.donasi.update({
where: {
id: id,
},
data: {
namaBank: data.namaBank,
rekening: data.rekening,
},
});
if (!update)
return NextResponse.json({
status: 400,
success: false,
reason: "Gagal mengupdate bank donasi",
});
}
return NextResponse.json({

View File

@@ -1,5 +1,6 @@
import { prisma } from "@/lib";
import { NextResponse } from "next/server";
export const dynamic = "force-dynamic";
// GET ALL DATA MASTER UNTUK INVESTASI
export async function GET(request: Request) {