QC User & Admin Responsive : Menu Kesehatan - Ekonomi

This commit is contained in:
2025-10-03 10:17:06 +08:00
parent 8a6d8ed8db
commit f7fd9be255
55 changed files with 754 additions and 372 deletions

View File

@@ -7,7 +7,9 @@ type FormCreate = {
alamatUsaha: string;
imageId: string;
rating: number;
kategoriId: string[]; // Array of KategoriProduk IDs
kategoriId: string[];
kontak: string;
// Array of KategoriProduk IDs
};
export default async function pasarDesaCreate(context: Context) {
@@ -28,7 +30,9 @@ export default async function pasarDesaCreate(context: Context) {
alamatUsaha: body.alamatUsaha,
imageId: body.imageId,
rating: Number(body.rating),
kategoriProdukId: body.kategoriId[0], // Use the first category as the main one
kategoriProdukId: body.kategoriId[0],
kontak: body.kontak
// Use the first category as the main one
},
});

View File

@@ -37,6 +37,7 @@ const PasarDesa = new Elysia({
imageId: t.String(),
rating: t.Number(),
kategoriId: t.Array(t.String()),
kontak: t.String(),
}),
}
)
@@ -79,6 +80,7 @@ const PasarDesa = new Elysia({
imageId: t.String(),
rating: t.Number(),
kategoriId: t.Array(t.String()),
kontak: t.String(),
}),
}
);

View File

@@ -0,0 +1,49 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
// /api/berita/findManyAll.ts
import prisma from "@/lib/prisma";
import { Context } from "elysia";
async function kategoriProdukFindManyAll(context: Context) {
// Ambil query search (opsional)
const search2 = (context.query.search as string) || "";
// Buat where clause
const where: any = { isActive: true };
if (search2) {
where.OR = [
{ nama: { contains: search2, mode: "insensitive" } },
{
KategoriToPasar: {
some: {
kategori: {
nama: { contains: search2, mode: "insensitive" },
},
},
},
},
];
}
try {
const data = await prisma.kategoriProduk.findMany({
where,
orderBy: { createdAt: "desc" },
});
return {
success: true,
message: "Berhasil ambil semua kategori produk",
data,
total: data.length,
};
} catch (e) {
console.error("Error di findManyAll:", e);
return {
success: false,
message: "Gagal mengambil data kategori produk",
};
}
}
export default kategoriProdukFindManyAll;

View File

@@ -5,12 +5,14 @@ import kategoriProdukDelete from "./del";
import kategoriProdukCreate from "./create";
import kategoriProdukUpdate from "./updt";
import { t } from "elysia";
import kategoriProdukFindManyAll from "./findManyAll";
const KategoriProduk = new Elysia({
prefix: "/kategoriproduk",
tags: ["Ekonomi/Kategori Produk"],
})
.get("/find-many", kategoriProdukFindMany)
.get("/find-many-all", kategoriProdukFindManyAll)
.get("/:id", async (context) => {
const response = await kategoriProdukFindUnique(context);
return response;

View File

@@ -9,6 +9,7 @@ type FormUpdate = {
imageId: string;
rating: number;
kategoriId: string[]; // Array of KategoriProduk IDs
kontak: string;
};
export default async function pasarDesaUpdate(context: Context) {
@@ -31,6 +32,7 @@ export default async function pasarDesaUpdate(context: Context) {
alamatUsaha: body.alamatUsaha,
imageId: body.imageId,
rating: Number(body.rating),
kontak: body.kontak
},
});

View File

@@ -23,6 +23,7 @@ export default async function kontakDaruratKeamananFindMany(context: Context) {
try {
const [data, total] = await Promise.all([
prisma.kontakDaruratKeamanan.findMany({
where,
include: {
kontakItems: {
include: {

View File

@@ -25,6 +25,7 @@ export default async function kontakItemFindMany(context: Context) {
skip,
take: limit,
orderBy: { createdAt: "desc" },
where,
}),
prisma.kontakItem.count({ where }),
]);

View File

@@ -7,6 +7,7 @@ type FormCreate = Prisma.KontakDaruratGetPayload<{
name: true;
deskripsi: true;
imageId: true;
whatsapp: true;
};
}>;
export default async function kontakDaruratCreate(context: Context) {
@@ -17,6 +18,7 @@ export default async function kontakDaruratCreate(context: Context) {
name: body.name,
deskripsi: body.deskripsi,
imageId: body.imageId,
whatsapp: body.whatsapp,
}
})
return {

View File

@@ -14,6 +14,7 @@ const KontakDarurat = new Elysia({
name: t.String(),
deskripsi: t.String(),
imageId: t.String(),
whatsapp: t.String(),
})
})
.get("/find-many", kontakDaruratFindMany)
@@ -33,6 +34,7 @@ const KontakDarurat = new Elysia({
name: t.String(),
deskripsi: t.String(),
imageId: t.String(),
whatsapp: t.String(),
})
}
)

View File

@@ -10,6 +10,7 @@ type FormUpdate = Prisma.KontakDaruratGetPayload<{
name: true;
deskripsi: true;
imageId: true;
whatsapp: true;
}
}>
export default async function kontakDaruratUpdate(context: Context) {
@@ -21,6 +22,7 @@ export default async function kontakDaruratUpdate(context: Context) {
name,
deskripsi,
imageId,
whatsapp,
} = body;
if(!id) {
@@ -75,6 +77,7 @@ export default async function kontakDaruratUpdate(context: Context) {
name,
deskripsi,
imageId,
whatsapp,
}
})