- Add Prisma models: DataBanjar, DistribusiAgama, DistribusiUmur, MigrasiPenduduk, DinamikaPenduduk - Create seeders for all kependudukan models with year 2026 data - Register Kependudukan API routes in route.ts - Update API findMany endpoints to make tahun parameter optional - Add YearFilter reusable component for admin pages - Update 4 kependudukan admin pages with year filter UI - Fix Mantine color array in AdminThemeProvider (add 10th element) - Fix invalid Mantine color scale in paguTable.tsx (gray.50 -> gray.1) - Add Kependudukan menu to navbar-list-menu.ts - Fix Bun JSON import resolution with loadJsonData helper - Update 74 seeder files to use dynamic JSON loading Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
46 lines
1.0 KiB
TypeScript
46 lines
1.0 KiB
TypeScript
import prisma from "@/lib/prisma";
|
|
import { loadJsonData } from "../../../load-json";
|
|
|
|
const penghargaan = loadJsonData("desa/penghargaan/penghargaan.json");
|
|
|
|
export async function seedPenghargaan() {
|
|
console.log("🔄 Seeding Penghargaan...");
|
|
for (const m of penghargaan) {
|
|
let imageId: string | null = null;
|
|
|
|
if (m.imageName) {
|
|
const image = await prisma.fileStorage.findUnique({
|
|
where: { name: m.imageName },
|
|
select: { id: true },
|
|
});
|
|
|
|
if (!image) {
|
|
console.warn(
|
|
`⚠️ Image not found for penghargaan "${m.name}": ${m.imageName}`,
|
|
);
|
|
} else {
|
|
imageId = image.id;
|
|
}
|
|
}
|
|
|
|
await prisma.penghargaan.upsert({
|
|
where: { id: m.id },
|
|
update: {
|
|
name: m.name,
|
|
juara: m.juara,
|
|
deskripsi: m.deskripsi,
|
|
imageId,
|
|
},
|
|
create: {
|
|
id: m.id,
|
|
name: m.name,
|
|
juara: m.juara,
|
|
deskripsi: m.deskripsi,
|
|
imageId,
|
|
},
|
|
});
|
|
}
|
|
|
|
console.log("penghargaan success ...");
|
|
}
|
|
|