Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
51c70ef98a | ||
|
|
8b378e8ab0 | ||
|
|
e7530a093b |
@@ -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.1](https://wibugit.wibudev.com/bip/hipmi/compare/v1.5.0...v1.5.1) (2025-10-14)
|
||||||
|
|
||||||
## 1.5.0 (2025-10-09)
|
## 1.5.0 (2025-10-09)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hipmi",
|
"name": "hipmi",
|
||||||
"version": "1.5.0",
|
"version": "1.5.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"prisma": {
|
"prisma": {
|
||||||
"seed": "bun prisma/seed.ts"
|
"seed": "bun prisma/seed.ts"
|
||||||
|
|||||||
@@ -19,8 +19,6 @@ async function GET(
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("[CHECK STATUS]", checkStatus);
|
|
||||||
|
|
||||||
if (!checkStatus)
|
if (!checkStatus)
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
status: 400,
|
status: 400,
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ export { POST, GET, PUT };
|
|||||||
async function POST(request: Request, { params }: { params: { id: string } }) {
|
async function POST(request: Request, { params }: { params: { id: string } }) {
|
||||||
const { id } = params;
|
const { id } = params;
|
||||||
const { data } = await request.json();
|
const { data } = await request.json();
|
||||||
console.log("[ID]", id);
|
|
||||||
console.log("[DATA]", data);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const create = await prisma.donasi_Invoice.create({
|
const create = await prisma.donasi_Invoice.create({
|
||||||
@@ -126,10 +124,6 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
|||||||
const status = searchParams.get("status");
|
const status = searchParams.get("status");
|
||||||
const fixStatus = _.startCase(status as string);
|
const fixStatus = _.startCase(status as string);
|
||||||
|
|
||||||
console.log("[ID]", id);
|
|
||||||
console.log("[DATA]", data);
|
|
||||||
console.log("[STATUS]", fixStatus);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const checkStatus = await prisma.donasiMaster_StatusInvoice.findFirst({
|
const checkStatus = await prisma.donasiMaster_StatusInvoice.findFirst({
|
||||||
where: {
|
where: {
|
||||||
@@ -168,8 +162,6 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("[UPDATE]", update);
|
|
||||||
|
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
status: 200,
|
status: 200,
|
||||||
success: true,
|
success: true,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
|
|||||||
import { prisma } from "@/lib";
|
import { prisma } from "@/lib";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
|
|
||||||
export { POST, GET };
|
export { POST, GET, PUT, DELETE };
|
||||||
|
|
||||||
async function POST(
|
async function POST(
|
||||||
request: NextRequest,
|
request: NextRequest,
|
||||||
@@ -10,8 +10,7 @@ async function POST(
|
|||||||
) {
|
) {
|
||||||
const { id } = params;
|
const { id } = params;
|
||||||
const { data } = await request.json();
|
const { data } = await request.json();
|
||||||
console.log("[ID]", id);
|
|
||||||
console.log("[DATA]", data);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (data && data?.imageId) {
|
if (data && data?.imageId) {
|
||||||
@@ -35,8 +34,6 @@ async function POST(
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("[CREATE]", create);
|
|
||||||
|
|
||||||
if (!create)
|
if (!create)
|
||||||
return NextResponse.json({ status: 400, message: "Gagal disimpan" });
|
return NextResponse.json({ status: 400, message: "Gagal disimpan" });
|
||||||
}
|
}
|
||||||
@@ -66,12 +63,12 @@ async function GET(
|
|||||||
const category = searchParams.get("category");
|
const category = searchParams.get("category");
|
||||||
let fixData;
|
let fixData;
|
||||||
|
|
||||||
console.log("[CATEGORY]", category);
|
|
||||||
console.log("[ID]", id);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (category === "get-all") {
|
if (category === "get-all") {
|
||||||
fixData = await prisma.donasi_Kabar.findMany({
|
fixData = await prisma.donasi_Kabar.findMany({
|
||||||
|
orderBy: {
|
||||||
|
updatedAt: "desc",
|
||||||
|
},
|
||||||
where: {
|
where: {
|
||||||
donasiId: id,
|
donasiId: id,
|
||||||
active: true,
|
active: true,
|
||||||
@@ -121,3 +118,105 @@ async function GET(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||||
|
const { id } = params;
|
||||||
|
const { data } = await request.json();
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (data && data.newImageId) {
|
||||||
|
const updateWithImage = await prisma.donasi_Kabar.update({
|
||||||
|
where: {
|
||||||
|
id: id,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
title: data.title,
|
||||||
|
deskripsi: data.deskripsi,
|
||||||
|
imageId: data.newImageId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!updateWithImage)
|
||||||
|
return NextResponse.json({
|
||||||
|
status: 400,
|
||||||
|
success: false,
|
||||||
|
message: "Gagal Update",
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const updateData = await prisma.donasi_Kabar.update({
|
||||||
|
where: {
|
||||||
|
id: id,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
title: data.title,
|
||||||
|
deskripsi: data.deskripsi,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!updateData)
|
||||||
|
return NextResponse.json({
|
||||||
|
status: 400,
|
||||||
|
success: false,
|
||||||
|
message: "Gagal Update",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return NextResponse.json({
|
||||||
|
status: 200,
|
||||||
|
success: true,
|
||||||
|
message: "Berhasil Update",
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("[ERROR UPDATE NEWS]", error);
|
||||||
|
return NextResponse.json({
|
||||||
|
status: 500,
|
||||||
|
success: false,
|
||||||
|
message: "Error Update Donation News",
|
||||||
|
reason: (error as Error).message,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function DELETE(
|
||||||
|
request: Request,
|
||||||
|
{ params }: { params: { id: string } }
|
||||||
|
) {
|
||||||
|
const { id } = params;
|
||||||
|
try {
|
||||||
|
const deleteData = await prisma.donasi_Kabar.delete({
|
||||||
|
where: {
|
||||||
|
id: id,
|
||||||
|
},
|
||||||
|
select: {
|
||||||
|
imageId: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const deleteImage = await fetch(
|
||||||
|
`https://wibu-storage.wibudev.com/api/files/${deleteData?.imageId}/delete`,
|
||||||
|
{
|
||||||
|
method: "DELETE",
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${process.env.WS_APIKEY}`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!deleteImage) {
|
||||||
|
console.log("[FAILED DELETE IMAGE]", deleteImage);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NextResponse.json({
|
||||||
|
status: 200,
|
||||||
|
success: true,
|
||||||
|
message: "Berhasil Delete",
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("[ERROR DELETE NEWS]", error);
|
||||||
|
return NextResponse.json({
|
||||||
|
status: 500,
|
||||||
|
success: false,
|
||||||
|
message: "Error Delete Donation News",
|
||||||
|
reason: (error as Error).message,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -100,9 +100,6 @@ export async function GET(request: Request) {
|
|||||||
const authorId = searchParams.get("authorId");
|
const authorId = searchParams.get("authorId");
|
||||||
let fixData;
|
let fixData;
|
||||||
|
|
||||||
console.log("[CATEGORY]", category);
|
|
||||||
console.log("[AUTHOR ID]", authorId);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (category === "beranda") {
|
if (category === "beranda") {
|
||||||
const data = await prisma.donasi.findMany({
|
const data = await prisma.donasi.findMany({
|
||||||
|
|||||||
107
src/app/api/mobile/maps/[id]/route.ts
Normal file
107
src/app/api/mobile/maps/[id]/route.ts
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
import { NextResponse } from "next/server";
|
||||||
|
import { prisma } from "@/lib";
|
||||||
|
|
||||||
|
export { GET };
|
||||||
|
|
||||||
|
async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||||
|
const { id } = params;
|
||||||
|
try {
|
||||||
|
const data = await prisma.businessMaps.findUnique({
|
||||||
|
where: {
|
||||||
|
id: id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return NextResponse.json({
|
||||||
|
success: true,
|
||||||
|
message: "Berhasil mendapatkan data pin map",
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("[ERROR]", error);
|
||||||
|
return NextResponse.json({
|
||||||
|
success: false,
|
||||||
|
message: "Gagal mendapatkan data pin map",
|
||||||
|
reason: (error as Error).message,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function PUT(
|
||||||
|
request: Request,
|
||||||
|
{ params }: { params: { id: string } }
|
||||||
|
) {
|
||||||
|
const { id } = params;
|
||||||
|
const { data } = await request.json();
|
||||||
|
|
||||||
|
try {
|
||||||
|
let fixData;
|
||||||
|
|
||||||
|
const ceheckData = await prisma.businessMaps.findUnique({
|
||||||
|
where: {
|
||||||
|
id: id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!ceheckData) {
|
||||||
|
return NextResponse.json({
|
||||||
|
status: 404,
|
||||||
|
success: false,
|
||||||
|
message: "Data tidak ditemukan",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.newImageId) {
|
||||||
|
const updated = await prisma.businessMaps.update({
|
||||||
|
where: {
|
||||||
|
id: id,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
namePin: data.namePin,
|
||||||
|
latitude: data.latitude,
|
||||||
|
longitude: data.longitude,
|
||||||
|
imageId: data.newImageId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (updated) {
|
||||||
|
const deleteImage = await fetch(
|
||||||
|
`https://wibu-storage.wibudev.com/api/files/${ceheckData.imageId}/delete`,
|
||||||
|
{
|
||||||
|
method: "DELETE",
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${process.env.WS_APIKEY}`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
fixData = updated;
|
||||||
|
} else {
|
||||||
|
const updated = await prisma.businessMaps.update({
|
||||||
|
where: {
|
||||||
|
id: id,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
namePin: data.namePin,
|
||||||
|
latitude: data.latitude,
|
||||||
|
longitude: data.longitude,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
fixData = updated;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NextResponse.json({
|
||||||
|
success: true,
|
||||||
|
message: "Berhasil mengupdate data pin map",
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("[ERROR]", error);
|
||||||
|
return NextResponse.json({
|
||||||
|
success: false,
|
||||||
|
message: "Gagal mengupdate data pin map",
|
||||||
|
reason: (error as Error).message,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
73
src/app/api/mobile/maps/route.ts
Normal file
73
src/app/api/mobile/maps/route.ts
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
import { NextResponse } from "next/server";
|
||||||
|
import { prisma } from "@/lib";
|
||||||
|
|
||||||
|
export { POST };
|
||||||
|
|
||||||
|
async function POST(request: Request) {
|
||||||
|
const { data } = await request.json();
|
||||||
|
|
||||||
|
try {
|
||||||
|
const created = await prisma.businessMaps.create({
|
||||||
|
data: {
|
||||||
|
latitude: data.latitude,
|
||||||
|
longitude: data.longitude,
|
||||||
|
namePin: data.namePin,
|
||||||
|
imageId: data.imageId || null,
|
||||||
|
portofolioId: data.portofolioId,
|
||||||
|
authorId: data.authorId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return NextResponse.json({
|
||||||
|
success: true,
|
||||||
|
message: "Berhasil membuat pin map",
|
||||||
|
data: created,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("[ERROR]", error);
|
||||||
|
return NextResponse.json({
|
||||||
|
success: false,
|
||||||
|
message: "Gagal membuat pin map",
|
||||||
|
reason: (error as Error).message,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function GET(request: Request) {
|
||||||
|
try {
|
||||||
|
const data = await prisma.businessMaps.findMany({
|
||||||
|
orderBy: {
|
||||||
|
updatedAt: "desc",
|
||||||
|
},
|
||||||
|
include: {
|
||||||
|
Portofolio: {
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
namaBisnis: true,
|
||||||
|
logoId: true,
|
||||||
|
alamatKantor: true,
|
||||||
|
tlpn: true,
|
||||||
|
MasterBidangBisnis: {
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
name: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return NextResponse.json({
|
||||||
|
success: true,
|
||||||
|
message: "Berhasil mendapatkan data pin map",
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("[ERROR]", error);
|
||||||
|
return NextResponse.json({
|
||||||
|
success: false,
|
||||||
|
message: "Gagal mendapatkan data pin map",
|
||||||
|
reason: (error as Error).message,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -55,6 +55,16 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
BusinessMaps: {
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
namePin: true,
|
||||||
|
latitude: true,
|
||||||
|
longitude: true,
|
||||||
|
imageId: true,
|
||||||
|
pinId: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -98,6 +108,7 @@ async function DELETE(request: Request, context: { params: { id: string } }) {
|
|||||||
include: {
|
include: {
|
||||||
BusinessMaps: {
|
BusinessMaps: {
|
||||||
select: {
|
select: {
|
||||||
|
id: true,
|
||||||
pinId: true,
|
pinId: true,
|
||||||
imageId: true,
|
imageId: true,
|
||||||
},
|
},
|
||||||
@@ -123,61 +134,66 @@ async function DELETE(request: Request, context: { params: { id: string } }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data?.BusinessMaps?.pinId != null) {
|
if (data?.BusinessMaps) {
|
||||||
const pinId = data?.BusinessMaps?.pinId;
|
const pinId = data?.BusinessMaps?.pinId;
|
||||||
const deletePin = await fetch(
|
|
||||||
`https://wibu-storage.wibudev.com/api/files/${pinId}/delete`,
|
|
||||||
{
|
|
||||||
method: "DELETE",
|
|
||||||
headers: {
|
|
||||||
Authorization: `Bearer ${process.env.WS_APIKEY}`,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
if (deletePin.ok) {
|
if (pinId) {
|
||||||
console.log(`Success delete pin`);
|
const deletePin = await fetch(
|
||||||
|
`https://wibu-storage.wibudev.com/api/files/${pinId}/delete`,
|
||||||
|
{
|
||||||
|
method: "DELETE",
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${process.env.WS_APIKEY}`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (deletePin.ok) {
|
||||||
|
console.log(`Success delete business map pin`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const imageId = data?.BusinessMaps?.imageId;
|
const mapImageId = data?.BusinessMaps?.imageId;
|
||||||
const deleteImage = await fetch(
|
|
||||||
`https://wibu-storage.wibudev.com/api/files/${imageId}/delete`,
|
|
||||||
{
|
|
||||||
method: "DELETE",
|
|
||||||
headers: {
|
|
||||||
Authorization: `Bearer ${process.env.WS_APIKEY}`,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
if (deleteImage.ok) {
|
if (mapImageId) {
|
||||||
console.log(`Success delete image`);
|
const deleteImage = await fetch(
|
||||||
|
`https://wibu-storage.wibudev.com/api/files/${mapImageId}/delete`,
|
||||||
|
{
|
||||||
|
method: "DELETE",
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${process.env.WS_APIKEY}`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (deleteImage.ok) {
|
||||||
|
console.log(`Success delete business map image `);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const deletePortoMedsos = await prisma.portofolio_MediaSosial.delete({
|
||||||
|
where: {
|
||||||
|
portofolioId: id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const deleteMap = await prisma.businessMaps.delete({
|
||||||
|
where: {
|
||||||
|
portofolioId: id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const deletePortofolio = await prisma.portofolio.delete({
|
||||||
|
where: {
|
||||||
|
id: id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error delete logo", error);
|
console.error("Error delete logo", error);
|
||||||
}
|
}
|
||||||
|
|
||||||
const deletePortoMedsos = await prisma.portofolio_MediaSosial.delete({
|
|
||||||
where: {
|
|
||||||
portofolioId: id,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// const deleteMap = await prisma.businessMaps.delete({
|
|
||||||
// where: {
|
|
||||||
// portofolioId: id,
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
|
|
||||||
// console.log("DELETE PORTOFOLIO MEDSOS >>", deletePortoMedsos);
|
|
||||||
|
|
||||||
const deletePortofolio = await prisma.portofolio.delete({
|
|
||||||
where: {
|
|
||||||
id: id,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ success: true, message: "Berhasil menghapus data" },
|
{ success: true, message: "Berhasil menghapus data" },
|
||||||
{ status: 200 }
|
{ status: 200 }
|
||||||
@@ -205,9 +221,6 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
|||||||
let message;
|
let message;
|
||||||
|
|
||||||
if (category === "detail") {
|
if (category === "detail") {
|
||||||
console.log("UPDATE PORTOFOLIO DETAIL >>");
|
|
||||||
console.log("DATA >>", data);
|
|
||||||
|
|
||||||
const checkData = await prisma.portofolio.findUnique({
|
const checkData = await prisma.portofolio.findUnique({
|
||||||
where: { id },
|
where: { id },
|
||||||
include: {
|
include: {
|
||||||
@@ -222,8 +235,6 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("CHECK DATA >>", checkData);
|
|
||||||
|
|
||||||
const updateDetail = await prisma.portofolio.update({
|
const updateDetail = await prisma.portofolio.update({
|
||||||
where: { id },
|
where: { id },
|
||||||
data: {
|
data: {
|
||||||
|
|||||||
Reference in New Issue
Block a user