Perbaikan UI & API Menu Ekonomi Pasar Desa
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the `_ProdukToKategori` table. If the table is not empty, all the data it contains will be lost.
|
||||
|
||||
*/
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "_ProdukToKategori" DROP CONSTRAINT "_ProdukToKategori_A_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "_ProdukToKategori" DROP CONSTRAINT "_ProdukToKategori_B_fkey";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "KategoriProduk" ADD COLUMN "deletedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
ADD COLUMN "isActive" BOOLEAN NOT NULL DEFAULT true;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "PasarDesa" ADD COLUMN "deletedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
ADD COLUMN "isActive" BOOLEAN NOT NULL DEFAULT true;
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE "_ProdukToKategori";
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "KategoriToPasar" (
|
||||
"id" TEXT NOT NULL,
|
||||
"kategoriId" TEXT NOT NULL,
|
||||
"pasarDesaId" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
"deletedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"isActive" BOOLEAN NOT NULL DEFAULT true,
|
||||
|
||||
CONSTRAINT "KategoriToPasar_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "KategoriToPasar" ADD CONSTRAINT "KategoriToPasar_kategoriId_fkey" FOREIGN KEY ("kategoriId") REFERENCES "KategoriProduk"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "KategoriToPasar" ADD CONSTRAINT "KategoriToPasar_pasarDesaId_fkey" FOREIGN KEY ("pasarDesaId") REFERENCES "PasarDesa"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
@@ -1057,17 +1057,32 @@ model PasarDesa {
|
||||
harga Int
|
||||
rating Float
|
||||
alamatUsaha String
|
||||
kategori KategoriProduk[] @relation("ProdukToKategori")
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
deletedAt DateTime @default(now())
|
||||
isActive Boolean @default(true)
|
||||
kategoriProduk KategoriProduk @relation(fields: [kategoriProdukId], references: [id])
|
||||
kategoriProdukId String
|
||||
KategoriToPasar KategoriToPasar[]
|
||||
}
|
||||
|
||||
model KategoriProduk {
|
||||
id String @id @default(uuid())
|
||||
nama String
|
||||
produk PasarDesa[] @relation("ProdukToKategori")
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
deletedAt DateTime @default(now())
|
||||
isActive Boolean @default(true)
|
||||
KategoriToPasar KategoriToPasar[]
|
||||
PasarDesa PasarDesa[]
|
||||
}
|
||||
|
||||
model KategoriToPasar {
|
||||
id String @id @default(uuid())
|
||||
kategori KategoriProduk @relation(fields: [kategoriId], references: [id])
|
||||
kategoriId String
|
||||
pasarDesa PasarDesa @relation(fields: [pasarDesaId], references: [id])
|
||||
pasarDesaId String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
deletedAt DateTime @default(now())
|
||||
|
||||
@@ -53,11 +53,18 @@ const pasarDesa = proxy({
|
||||
},
|
||||
},
|
||||
findMany: {
|
||||
data: null as
|
||||
| Prisma.PasarDesaGetPayload<{
|
||||
include: { kategori: true; image: true };
|
||||
}>[]
|
||||
| null,
|
||||
data: null as Array<
|
||||
Prisma.PasarDesaGetPayload<{
|
||||
include: {
|
||||
image: true;
|
||||
KategoriToPasar: {
|
||||
include: {
|
||||
kategori: true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}>
|
||||
> | null,
|
||||
async load() {
|
||||
const res = await ApiFetch.api.ekonomi.pasardesa["find-many"].get();
|
||||
if (res.status === 200) {
|
||||
@@ -67,7 +74,14 @@ const pasarDesa = proxy({
|
||||
},
|
||||
findUnique: {
|
||||
data: null as Prisma.PasarDesaGetPayload<{
|
||||
include: { kategori: true; image: true };
|
||||
include: {
|
||||
image: true;
|
||||
KategoriToPasar: {
|
||||
include: {
|
||||
kategori: true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}> | null,
|
||||
async load(id: string) {
|
||||
try {
|
||||
|
||||
@@ -43,7 +43,8 @@ function EditPasarDesa() {
|
||||
alamatUsaha: data.alamatUsaha || "",
|
||||
imageId: data.imageId || "",
|
||||
rating: data.rating || 0,
|
||||
kategoriId: data.kategori?.map((k: any) => k.nama) || [],
|
||||
// Use the IDs from KategoriToPasar relationship
|
||||
kategoriId: data.KategoriToPasar?.map((k: any) => k.kategoriId) || [],
|
||||
});
|
||||
// Tampilkan preview gambar
|
||||
if (data.image?.link) {
|
||||
@@ -198,17 +199,19 @@ function EditPasarDesa() {
|
||||
/>
|
||||
<MultiSelect
|
||||
value={formData.kategoriId}
|
||||
onChange={(val) => {
|
||||
setFormData({ ...formData, kategoriId: val });
|
||||
}}
|
||||
onChange={(val) => setFormData({ ...formData, kategoriId: val })}
|
||||
label={<Text fw={"bold"} fz={"sm"}>Kategori Produk</Text>}
|
||||
placeholder='Pilih kategori produk'
|
||||
data={
|
||||
pasarState.kategoriProduk.findMany.data?.map((v) => ({
|
||||
value: v.id,
|
||||
value: v.id, // Make sure this is using the ID
|
||||
label: v.nama
|
||||
})) || []
|
||||
}
|
||||
clearable
|
||||
searchable
|
||||
required
|
||||
error={!formData.kategoriId.length ? "Pilih minimal satu kategori" : undefined}
|
||||
/>
|
||||
|
||||
<Group>
|
||||
|
||||
@@ -17,7 +17,6 @@ function DetailPasarDesa() {
|
||||
const router = useRouter();
|
||||
|
||||
useShallowEffect(() => {
|
||||
statePasar.kategoriProduk.findUnique.load(params?.id as string)
|
||||
statePasar.pasarDesa.findUnique.load(params?.id as string)
|
||||
}, [])
|
||||
|
||||
@@ -73,12 +72,17 @@ function DetailPasarDesa() {
|
||||
<Box>
|
||||
<Text fz={"lg"} fw={"bold"}>Kategori</Text>
|
||||
<Stack gap={4}>
|
||||
{statePasar.pasarDesa.findUnique.data?.kategori?.length > 0 ? (
|
||||
statePasar.pasarDesa.findUnique.data.kategori.map((kat) => (
|
||||
<Text fz={"lg"} key={kat.id}>• {kat.nama}</Text>
|
||||
{statePasar.pasarDesa.findUnique.data?.KategoriToPasar &&
|
||||
statePasar.pasarDesa.findUnique.data.KategoriToPasar.length > 0 ? (
|
||||
statePasar.pasarDesa.findUnique.data.KategoriToPasar.map((kategori) => (
|
||||
<Text fz={"lg"} key={kategori.id}>
|
||||
• {kategori.kategori.nama}
|
||||
</Text>
|
||||
))
|
||||
) : (
|
||||
<Text fz={"lg"} c="dimmed">Tidak ada kategori</Text>
|
||||
<Text fz={"lg"} c="dimmed">
|
||||
Tidak ada kategori
|
||||
</Text>
|
||||
)}
|
||||
</Stack>
|
||||
</Box>
|
||||
|
||||
@@ -7,12 +7,20 @@ type FormCreate = {
|
||||
alamatUsaha: string;
|
||||
imageId: string;
|
||||
rating: number;
|
||||
kategoriId: string[]; // Array of KategoriMakanan IDs
|
||||
kategoriId: string[]; // Array of KategoriProduk IDs
|
||||
};
|
||||
|
||||
export default async function pasarDesaCreate(context: Context) {
|
||||
const body = context.body as FormCreate;
|
||||
|
||||
// First, create the PasarDesa record
|
||||
if (!body.kategoriId || body.kategoriId.length === 0) {
|
||||
throw new Error("At least one kategoriId is required");
|
||||
}
|
||||
|
||||
try {
|
||||
// Start a transaction to ensure data consistency
|
||||
const result = await prisma.$transaction(async (prisma) => {
|
||||
// 1. Create PasarDesa with the first kategoriId as the main category
|
||||
const pasarDesa = await prisma.pasarDesa.create({
|
||||
data: {
|
||||
nama: body.nama,
|
||||
@@ -20,19 +28,40 @@ export default async function pasarDesaCreate(context: Context) {
|
||||
alamatUsaha: body.alamatUsaha,
|
||||
imageId: body.imageId,
|
||||
rating: Number(body.rating),
|
||||
kategori: {
|
||||
connect: body.kategoriId.map((id) => ({ id })),
|
||||
},
|
||||
kategoriProdukId: body.kategoriId[0], // Use the first category as the main one
|
||||
},
|
||||
});
|
||||
|
||||
// 2. Create category relationships in KategoriToPasar for all categories
|
||||
await prisma.kategoriToPasar.createMany({
|
||||
data: body.kategoriId.map((kategoriId) => ({
|
||||
pasarDesaId: pasarDesa.id,
|
||||
kategoriId: kategoriId, // Note: The field is 'kategoriId' in the schema, not 'kategoriProdukId'
|
||||
})),
|
||||
});
|
||||
|
||||
// 3. Get the complete data with relationships
|
||||
return await prisma.pasarDesa.findUnique({
|
||||
where: { id: pasarDesa.id },
|
||||
include: {
|
||||
image: true,
|
||||
kategoriProduk: true,
|
||||
KategoriToPasar: {
|
||||
include: {
|
||||
kategori: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: "Success create pasar desa",
|
||||
data: pasarDesa,
|
||||
data: result,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("Error creating PasarDesa:", error);
|
||||
throw new Error("Failed to create PasarDesa: " + (error as Error).message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,54 +1,27 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import { Context } from "elysia";
|
||||
import fs from "fs/promises";
|
||||
import path from "path";
|
||||
|
||||
const pasarDesaDelete = async (context: Context) => {
|
||||
const id = context.params?.id as string;
|
||||
export default async function pasarDesaDelete(context: Context) {
|
||||
const { params } = context;
|
||||
const id = params?.id as string;
|
||||
|
||||
if (!id) {
|
||||
return {
|
||||
status: 400,
|
||||
body: "ID tidak diberikan",
|
||||
};
|
||||
throw new Error("ID tidak ditemukan dalam parameter");
|
||||
}
|
||||
|
||||
const pasarDesa = await prisma.pasarDesa.findUnique({
|
||||
where: { id },
|
||||
include: {
|
||||
image: true,
|
||||
kategori: true,
|
||||
},
|
||||
// 1. Hapus relasi dari pivot
|
||||
await prisma.kategoriToPasar.deleteMany({
|
||||
where: { pasarDesaId: id },
|
||||
});
|
||||
|
||||
if (!pasarDesa) {
|
||||
return {
|
||||
status: 404,
|
||||
body: "Pasar desa tidak ditemukan",
|
||||
};
|
||||
}
|
||||
|
||||
if (pasarDesa.image) {
|
||||
try {
|
||||
const filePath = path.join(pasarDesa.image.path, pasarDesa.image.name);
|
||||
await fs.unlink(filePath);
|
||||
await prisma.fileStorage.delete({
|
||||
where: { id: pasarDesa.image.id },
|
||||
});
|
||||
} catch (err) {
|
||||
console.error("Gagal hapus file image:", err);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
await prisma.pasarDesa.delete({
|
||||
// 2. Hapus pasar desa utama
|
||||
const deleted = await prisma.pasarDesa.delete({
|
||||
where: { id },
|
||||
});
|
||||
|
||||
return {
|
||||
status: 200,
|
||||
success: true,
|
||||
message: "Pasar desa berhasil dihapus",
|
||||
message: "Berhasil menghapus pasar desa",
|
||||
data: deleted,
|
||||
};
|
||||
};
|
||||
export default pasarDesaDelete;
|
||||
}
|
||||
|
||||
@@ -1,25 +1,26 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
|
||||
export default async function pasarDesaFindMany() {
|
||||
try {
|
||||
const data = await prisma.pasarDesa.findMany({
|
||||
where: { isActive: true },
|
||||
where: {
|
||||
isActive: true, // Opsional filter
|
||||
},
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
include: {
|
||||
image: true,
|
||||
KategoriToPasar: {
|
||||
include: {
|
||||
kategori: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: "Success fetch pasar desa",
|
||||
message: "Berhasil mengambil semua data pasar desa",
|
||||
data,
|
||||
};
|
||||
} catch (e) {
|
||||
console.error("Find many error:", e);
|
||||
return {
|
||||
success: false,
|
||||
message: "Failed fetch pasar desa",
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,54 +1,33 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import { Context } from "elysia";
|
||||
|
||||
export default async function pasarDesaFindUnique(request: Request){
|
||||
const url = new URL(request.url);
|
||||
const pathSegments = url.pathname.split('/');
|
||||
const id = pathSegments[pathSegments.length - 1];
|
||||
export default async function pasarDesaFindUnique(context: Context) {
|
||||
const { params } = context;
|
||||
const id = params?.id as string;
|
||||
|
||||
if(!id){
|
||||
return Response.json({
|
||||
success: false,
|
||||
message: "ID tidak boleh kosong",
|
||||
}, { status: 400 });
|
||||
}
|
||||
|
||||
try {
|
||||
if (typeof id !== 'string') {
|
||||
return Response.json({
|
||||
success: false,
|
||||
message: "ID tidak valid",
|
||||
}, { status: 400 });
|
||||
if (!id) {
|
||||
throw new Error("ID tidak ditemukan dalam parameter");
|
||||
}
|
||||
|
||||
const data = await prisma.pasarDesa.findUnique({
|
||||
where: { id },
|
||||
include: {
|
||||
image: true,
|
||||
KategoriToPasar: {
|
||||
include: {
|
||||
kategori: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (!data) {
|
||||
return Response.json({
|
||||
success: false,
|
||||
message: "Pasar desa tidak ditemukan",
|
||||
}, { status: 404 });
|
||||
throw new Error("Pasar desa tidak ditemukan");
|
||||
}
|
||||
|
||||
return Response.json({
|
||||
return {
|
||||
success: true,
|
||||
message: "Success fetch pasar desa by ID",
|
||||
message: "Data pasar desa ditemukan",
|
||||
data,
|
||||
}, {
|
||||
status: 200,
|
||||
});
|
||||
} catch (e) {
|
||||
console.error("Find by ID error:", e);
|
||||
return Response.json({
|
||||
success: false,
|
||||
message: "Gagal mengambil pasar desa: " + (e instanceof Error ? e.message : 'Unknown error'),
|
||||
}, {
|
||||
status: 500,
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -9,28 +9,26 @@ const PasarDesa = new Elysia({
|
||||
prefix: "/pasardesa",
|
||||
tags: ["Ekonomi/Pasar Desa"],
|
||||
})
|
||||
// GET all
|
||||
.get("/find-many", pasarDesaFindMany)
|
||||
.get("/:id", async (context) => {
|
||||
const response = await pasarDesaFindUnique(new Request(context.request));
|
||||
return response;
|
||||
})
|
||||
.post("/create", pasarDesaCreate, {
|
||||
body: t.Object({
|
||||
nama: t.String(),
|
||||
harga: t.Number(),
|
||||
alamatUsaha: t.String(),
|
||||
imageId: t.String(),
|
||||
rating: t.Number(),
|
||||
kategoriId:t.Array(t.String()),
|
||||
}),
|
||||
})
|
||||
.delete("/del/:id", pasarDesaDelete)
|
||||
.put(
|
||||
|
||||
// GET by ID
|
||||
.get(
|
||||
"/:id",
|
||||
async (context) => {
|
||||
const response = await pasarDesaUpdate(context);
|
||||
return response;
|
||||
return await pasarDesaFindUnique(context);
|
||||
},
|
||||
{
|
||||
params: t.Object({
|
||||
id: t.String(),
|
||||
}),
|
||||
}
|
||||
)
|
||||
|
||||
// POST create
|
||||
.post(
|
||||
"/create",
|
||||
pasarDesaCreate,
|
||||
{
|
||||
body: t.Object({
|
||||
nama: t.String(),
|
||||
@@ -38,7 +36,49 @@ const PasarDesa = new Elysia({
|
||||
alamatUsaha: t.String(),
|
||||
imageId: t.String(),
|
||||
rating: t.Number(),
|
||||
kategoriId:t.Array(t.String()),
|
||||
kategoriId: t.Array(t.String()),
|
||||
}),
|
||||
}
|
||||
)
|
||||
|
||||
// DELETE
|
||||
.delete(
|
||||
"/del/:id",
|
||||
pasarDesaDelete,
|
||||
{
|
||||
params: t.Object({
|
||||
id: t.String(),
|
||||
}),
|
||||
}
|
||||
)
|
||||
|
||||
// PUT update
|
||||
.put(
|
||||
"/:id",
|
||||
async (context) => {
|
||||
const body = context.body;
|
||||
const id = context.params.id;
|
||||
|
||||
// Gabungkan id ke body
|
||||
return await pasarDesaUpdate({
|
||||
...context,
|
||||
body: {
|
||||
...body,
|
||||
id,
|
||||
},
|
||||
});
|
||||
},
|
||||
{
|
||||
params: t.Object({
|
||||
id: t.String(),
|
||||
}),
|
||||
body: t.Object({
|
||||
nama: t.String(),
|
||||
harga: t.Number(),
|
||||
alamatUsaha: t.String(),
|
||||
imageId: t.String(),
|
||||
rating: t.Number(),
|
||||
kategoriId: t.Array(t.String()),
|
||||
}),
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,98 +1,68 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import { Context } from "elysia";
|
||||
import fs from "fs/promises";
|
||||
import path from "path";
|
||||
|
||||
type FormUpdate = {
|
||||
id: string;
|
||||
nama: string;
|
||||
harga: number;
|
||||
alamatUsaha: string;
|
||||
imageId: string;
|
||||
rating: number;
|
||||
kategoriId: string[]; // Array of KategoriMakanan IDs
|
||||
};
|
||||
kategoriId: string[]; // Array of KategoriProduk IDs
|
||||
};
|
||||
|
||||
export default async function pasarDesaUpdate(context: Context){
|
||||
try {
|
||||
const id = context.params?.id;
|
||||
export default async function pasarDesaUpdate(context: Context) {
|
||||
const body = context.body as FormUpdate;
|
||||
|
||||
const { nama, harga, alamatUsaha, imageId, rating, kategoriId } = body;
|
||||
|
||||
if (!id) {
|
||||
return Response.json({
|
||||
success: false,
|
||||
message: "ID tidak boleh kosong",
|
||||
}, { status: 400 });
|
||||
if (!body.id) {
|
||||
throw new Error("ID pasar desa tidak boleh kosong");
|
||||
}
|
||||
|
||||
const existing = await prisma.pasarDesa.findUnique({
|
||||
where: { id },
|
||||
include: {
|
||||
image: true,
|
||||
kategori: true,
|
||||
},
|
||||
})
|
||||
|
||||
if (!existing) {
|
||||
return Response.json({
|
||||
success: false,
|
||||
message: "Pasar desa tidak ditemukan",
|
||||
}, { status: 404 });
|
||||
if (!body.kategoriId || body.kategoriId.length === 0) {
|
||||
throw new Error("Minimal 1 kategori harus dipilih");
|
||||
}
|
||||
|
||||
if (existing.imageId && existing.imageId !== imageId) {
|
||||
const oldImage = existing.image;
|
||||
if (oldImage) {
|
||||
try {
|
||||
const filePath = path.join(oldImage.path, oldImage.name);
|
||||
await fs.unlink(filePath);
|
||||
await prisma.fileStorage.delete({
|
||||
where: { id: oldImage.id },
|
||||
});
|
||||
} catch (err) {
|
||||
console.error("Gagal hapus gambar lama:", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// First, update the main PasarDesa record
|
||||
// 1. Update data utama pasar desa
|
||||
await prisma.pasarDesa.update({
|
||||
where: { id },
|
||||
where: { id: body.id },
|
||||
data: {
|
||||
nama,
|
||||
harga,
|
||||
alamatUsaha,
|
||||
imageId,
|
||||
rating,
|
||||
kategori: {
|
||||
connect: kategoriId.map((id) => ({ id })),
|
||||
nama: body.nama,
|
||||
harga: Number(body.harga),
|
||||
alamatUsaha: body.alamatUsaha,
|
||||
imageId: body.imageId,
|
||||
rating: Number(body.rating),
|
||||
},
|
||||
});
|
||||
|
||||
// 2. Hapus semua relasi kategori lama
|
||||
await prisma.kategoriToPasar.deleteMany({
|
||||
where: { pasarDesaId: body.id },
|
||||
});
|
||||
|
||||
// 3. Tambah relasi kategori yang baru
|
||||
await prisma.kategoriToPasar.createMany({
|
||||
data: body.kategoriId.map((kategoriProdukId) => ({
|
||||
pasarDesaId: body.id,
|
||||
kategoriId: kategoriProdukId,
|
||||
})),
|
||||
});
|
||||
|
||||
// 4. Ambil data lengkap setelah update
|
||||
const updated = await prisma.pasarDesa.findUnique({
|
||||
where: { id: body.id },
|
||||
include: {
|
||||
image: true,
|
||||
KategoriToPasar: {
|
||||
include: {
|
||||
kategori: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// Fetch the updated record with all relations
|
||||
const updated = await prisma.pasarDesa.findUnique({
|
||||
where: { id },
|
||||
include: {
|
||||
image: true,
|
||||
kategori: true,
|
||||
}
|
||||
});
|
||||
return Response.json({
|
||||
return {
|
||||
success: true,
|
||||
message: "Success update pasar desa",
|
||||
data: updated,
|
||||
}, {
|
||||
status: 200,
|
||||
});
|
||||
} catch (e) {
|
||||
console.error("Update error:", e);
|
||||
return Response.json({
|
||||
success: false,
|
||||
message: "Gagal mengupdate pasar desa: " + (e instanceof Error ? e.message : 'Unknown error'),
|
||||
}, {
|
||||
status: 500,
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user