Seeder Menu Lingkungan dan Pendidikan
Fix Jam Operasional Kantor Desa Darmasaba
This commit is contained in:
219
QWEN.md
219
QWEN.md
@@ -1,219 +0,0 @@
|
||||
# Desa Darmasaba - Village Management System
|
||||
|
||||
## Project Overview
|
||||
|
||||
Desa Darmasaba is a comprehensive Next.js 15 application designed for village management services in Badung, Bali. The platform serves as a digital hub for government services, public information, news, and community engagement for the residents of Darmasaba village.
|
||||
|
||||
### Key Technologies
|
||||
- **Framework**: Next.js 15 with App Router
|
||||
- **Language**: TypeScript with strict mode
|
||||
- **Styling**: Mantine UI components with custom CSS
|
||||
- **Backend**: Elysia.js API server integrated with Next.js
|
||||
- **Database**: PostgreSQL with Prisma ORM
|
||||
- **State Management**: Jotai for global state
|
||||
- **Authentication**: JWT with iron-session
|
||||
- **Runtime**: Bun (instead of Node.js)
|
||||
|
||||
### Architecture
|
||||
The application follows a modern full-stack architecture with:
|
||||
- Frontend built with Next.js 15 and TypeScript
|
||||
- Backend API endpoints using Elysia.js
|
||||
- PostgreSQL database managed with Prisma ORM
|
||||
- Mantine UI library for consistent design components
|
||||
- File storage system for managing images and documents
|
||||
- Comprehensive user authentication and authorization system
|
||||
|
||||
## Features
|
||||
|
||||
The application provides extensive functionality across multiple domains:
|
||||
|
||||
### Government Services
|
||||
- Public service information and requests
|
||||
- Administrative online services
|
||||
- Community announcements and news
|
||||
- Village profile and governance information
|
||||
|
||||
### Health Services
|
||||
- Healthcare facility information
|
||||
- Health programs and initiatives
|
||||
- Emergency health contacts
|
||||
- Health articles and education
|
||||
- Posyandu (community health posts) information
|
||||
|
||||
### Economic Development
|
||||
- Local market information
|
||||
- Job listings and employment opportunities
|
||||
- Village economic statistics
|
||||
- Business registration and support
|
||||
|
||||
### Innovation & Technology
|
||||
- Digital village initiatives
|
||||
- Technology adoption programs
|
||||
- Innovation proposal system
|
||||
- Smart village features
|
||||
|
||||
### Education
|
||||
- School information and statistics
|
||||
- Scholarship programs
|
||||
- Educational support services
|
||||
- Library and learning resources
|
||||
|
||||
### Environmental Management
|
||||
- Waste management systems
|
||||
- Green initiatives
|
||||
- Environmental conservation programs
|
||||
- Community participation activities
|
||||
|
||||
### Security & Safety
|
||||
- Emergency contacts
|
||||
- Police station information
|
||||
- Crime prevention measures
|
||||
- Community safety programs
|
||||
|
||||
## Building and Running
|
||||
|
||||
### Prerequisites
|
||||
- Bun runtime (version specified in package.json)
|
||||
- PostgreSQL database
|
||||
- Environment variables configured
|
||||
|
||||
### Setup Commands
|
||||
```bash
|
||||
# Install dependencies
|
||||
bun install
|
||||
|
||||
# Set up environment variables
|
||||
cp .env.example .env.local
|
||||
# Edit .env.local with your configuration
|
||||
|
||||
# Database setup
|
||||
bunx prisma db push
|
||||
bunx prisma generate
|
||||
|
||||
# Seed database (optional)
|
||||
bun run prisma/seed.ts
|
||||
|
||||
# Development mode
|
||||
bun run dev
|
||||
|
||||
# Production build
|
||||
bun run build
|
||||
|
||||
# Start production server
|
||||
bun run start
|
||||
```
|
||||
|
||||
### Additional Commands
|
||||
```bash
|
||||
# Linting (ESLint)
|
||||
bunx eslint .
|
||||
|
||||
# Type checking
|
||||
bunx tsc --noEmit
|
||||
|
||||
# Prisma operations
|
||||
bunx prisma generate
|
||||
bunx prisma db push
|
||||
bunx prisma studio
|
||||
```
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
src/
|
||||
├── app/ # Next.js app router pages
|
||||
│ ├── _com/ # Common components
|
||||
│ ├── admin/ # Admin panel routes
|
||||
│ ├── api/ # API routes
|
||||
│ ├── darmasaba/ # Main application pages
|
||||
│ ├── login/ # Authentication pages
|
||||
│ └── ... # Other feature pages
|
||||
├── con/ # Constants and static data
|
||||
├── hooks/ # Custom React hooks
|
||||
├── lib/ # Utility functions and configurations
|
||||
├── middlewares/ # Middleware functions
|
||||
├── state/ # Global state management
|
||||
├── store/ # Additional state management
|
||||
├── types/ # TypeScript type definitions
|
||||
├── utils/ # Utility functions
|
||||
├── middleware.ts # Application middleware
|
||||
└── schema.ts # Schema definitions
|
||||
```
|
||||
|
||||
## Development Guidelines
|
||||
|
||||
### Code Style
|
||||
- Use absolute imports with `@/` alias (configured in tsconfig.json)
|
||||
- Group imports: external libraries first, then internal modules
|
||||
- Follow consistent naming conventions:
|
||||
- Components: PascalCase (e.g., `UploadImage.tsx`)
|
||||
- Files: kebab-case for utilities (e.g., `api-fetch.ts`)
|
||||
- Variables/Functions: camelCase
|
||||
- Constants: UPPER_SNAKE_CASE
|
||||
|
||||
### TypeScript Configuration
|
||||
- Strict mode enabled (`"strict": true`)
|
||||
- Target: ES2017
|
||||
- Module resolution: bundler
|
||||
- Path alias: `@/*` maps to `./src/*`
|
||||
|
||||
### Error Handling
|
||||
- Use try-catch blocks for async operations
|
||||
- Implement proper error boundaries in React components
|
||||
- Log errors appropriately without exposing sensitive data
|
||||
- Use Zod for runtime validation and type safety
|
||||
|
||||
### Security Practices
|
||||
- Validate all user inputs with Zod schemas
|
||||
- Use JWT tokens for authentication
|
||||
- Implement proper CORS configuration
|
||||
- Never expose database credentials or API keys
|
||||
- Use HTTPS in production
|
||||
- Implement rate limiting for sensitive endpoints
|
||||
|
||||
### Performance Considerations
|
||||
- Use Next.js Image optimization
|
||||
- Implement proper caching strategies
|
||||
- Use React.memo for expensive components
|
||||
- Optimize bundle size with dynamic imports
|
||||
- Use Prisma query optimization
|
||||
|
||||
## Database Schema
|
||||
|
||||
The application uses a comprehensive PostgreSQL database schema with Prisma ORM, featuring:
|
||||
|
||||
- **User Management**: Complete user authentication system with roles and permissions
|
||||
- **Content Management**: News, announcements, and various content types
|
||||
- **Service Management**: Various government and community services
|
||||
- **File Storage**: Centralized file management system
|
||||
- **Health Information**: Healthcare facilities and programs
|
||||
- **Economic Data**: Market information and employment data
|
||||
- **Educational Resources**: Schools, scholarships, and educational programs
|
||||
- **Environmental Data**: Sustainability and environmental management
|
||||
- **Security Information**: Emergency contacts and safety measures
|
||||
|
||||
## API Structure
|
||||
|
||||
- Backend uses Elysia.js with TypeScript
|
||||
- API routes are in `src/app/api/[[...slugs]]/` directory
|
||||
- Use treaty client for type-safe API calls
|
||||
- Follow RESTful conventions for endpoints
|
||||
- Include proper HTTP status codes and error responses
|
||||
|
||||
## Deployment
|
||||
|
||||
The application includes deployment scripts for staging environments, with:
|
||||
- Automated builds using Bun
|
||||
- Database migration handling
|
||||
- Environment-specific configurations
|
||||
- PM2 process management for production
|
||||
|
||||
## Important Notes
|
||||
|
||||
- The application uses a custom Elysia.js server integrated with Next.js API routes
|
||||
- Image uploads are handled through `/api/upl-img-single` endpoint
|
||||
- Database seeding is done with Bun runtime
|
||||
- The app supports Indonesian locale (id_ID) for SEO and content
|
||||
- CORS is configured to allow cross-origin requests during development
|
||||
- Authentication is implemented with JWT tokens and iron-session
|
||||
- The application has both public-facing and admin sections with different access controls
|
||||
@@ -4,6 +4,23 @@ import desaDigital from "../../data/inovasi/desa-digital/desa-digital.json";
|
||||
export async function seedDesaDigital() {
|
||||
console.log("🔄 Seeding Desa Digital...");
|
||||
for (const d of desaDigital) {
|
||||
let imageId: string | null = null;
|
||||
|
||||
if (d.imageName) {
|
||||
const image = await prisma.fileStorage.findUnique({
|
||||
where: { name: d.imageName },
|
||||
select: { id: true },
|
||||
});
|
||||
|
||||
if (!image) {
|
||||
console.warn(
|
||||
`⚠️ Image not found for desa digital "${d.name}": ${d.imageName}`,
|
||||
);
|
||||
} else {
|
||||
imageId = image.id;
|
||||
}
|
||||
}
|
||||
|
||||
await prisma.desaDigital.upsert({
|
||||
where: {
|
||||
id: d.id,
|
||||
@@ -11,13 +28,13 @@ export async function seedDesaDigital() {
|
||||
update: {
|
||||
name: d.name,
|
||||
deskripsi: d.deskripsi,
|
||||
imageId: d.imageId,
|
||||
imageId: imageId,
|
||||
},
|
||||
create: {
|
||||
id: d.id,
|
||||
name: d.name,
|
||||
deskripsi: d.deskripsi,
|
||||
imageId: d.imageId,
|
||||
imageId: imageId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -63,6 +63,23 @@ export async function seedLayananOnlineDesa() {
|
||||
console.log("✅ Jenis Pengaduan Masyarakat seeded successfully");
|
||||
console.log("🔄 Seeding Pengaduan Masyarakat...");
|
||||
for (const d of pengaduanMasyarakat) {
|
||||
let imageId: string | null = null;
|
||||
|
||||
if (d.imageName) {
|
||||
const image = await prisma.fileStorage.findUnique({
|
||||
where: { name: d.imageName },
|
||||
select: { id: true },
|
||||
});
|
||||
|
||||
if (!image) {
|
||||
console.warn(
|
||||
`⚠️ Image not found for pengaduan masyarakat "${d.name}": ${d.imageName}`,
|
||||
);
|
||||
} else {
|
||||
imageId = image.id;
|
||||
}
|
||||
}
|
||||
|
||||
await prisma.pengaduanMasyarakat.upsert({
|
||||
where: {
|
||||
id: d.id,
|
||||
@@ -74,7 +91,7 @@ export async function seedLayananOnlineDesa() {
|
||||
nomorTelepon: d.nomorTelepon,
|
||||
judulPengaduan: d.judulPengaduan,
|
||||
lokasiKejadian: d.lokasiKejadian,
|
||||
imageId: d.imageId,
|
||||
imageId: imageId,
|
||||
deskripsiPengaduan: d.deskripsiPengaduan,
|
||||
jenisPengaduanId: d.jenisPengaduanId,
|
||||
},
|
||||
@@ -86,7 +103,7 @@ export async function seedLayananOnlineDesa() {
|
||||
nomorTelepon: d.nomorTelepon,
|
||||
judulPengaduan: d.judulPengaduan,
|
||||
lokasiKejadian: d.lokasiKejadian,
|
||||
imageId: d.imageId,
|
||||
imageId: imageId,
|
||||
deskripsiPengaduan: d.deskripsiPengaduan,
|
||||
jenisPengaduanId: d.jenisPengaduanId,
|
||||
},
|
||||
|
||||
71
prisma/_seeder_list/lingkungan/seed_data_gotong_royong.ts
Normal file
71
prisma/_seeder_list/lingkungan/seed_data_gotong_royong.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import kategoriGotongRoyong from "../../data/lingkungan/gotong-royong/kategori-gotong-royong.json";
|
||||
import gotongRoyong from "../../data/lingkungan/gotong-royong/gotong-royong.json";
|
||||
|
||||
export async function seedDataGotongRoyong() {
|
||||
console.log("🔄 Seeding Kategori Gotong Royong...");
|
||||
|
||||
for (const k of kategoriGotongRoyong) {
|
||||
await prisma.kategoriKegiatan.upsert({
|
||||
where: {
|
||||
id: k.id,
|
||||
},
|
||||
update: {
|
||||
nama: k.nama,
|
||||
},
|
||||
create: {
|
||||
id: k.id,
|
||||
nama: k.nama,
|
||||
},
|
||||
});
|
||||
}
|
||||
console.log("✅ Kategori Gotong Royong seeded successfully");
|
||||
|
||||
console.log("🔄 Seeding Gotong Royong...");
|
||||
for (const k of gotongRoyong) {
|
||||
let imageId: string | null = null;
|
||||
|
||||
if (k.imageName) {
|
||||
const image = await prisma.fileStorage.findUnique({
|
||||
where: { name: k.imageName },
|
||||
select: { id: true },
|
||||
});
|
||||
|
||||
if (!image) {
|
||||
console.warn(
|
||||
`⚠️ Image not found for gotong royong "${k.judul}": ${k.imageName}`,
|
||||
);
|
||||
} else {
|
||||
imageId = image.id;
|
||||
}
|
||||
}
|
||||
|
||||
await prisma.kegiatanDesa.upsert({
|
||||
where: {
|
||||
id: k.id,
|
||||
},
|
||||
update: {
|
||||
judul: k.judul,
|
||||
deskripsiSingkat: k.deskripsiSingkat,
|
||||
deskripsiLengkap: k.deskripsiLengkap,
|
||||
tanggal: k.tanggal,
|
||||
lokasi: k.lokasi,
|
||||
partisipan: k.partisipan,
|
||||
imageId: imageId,
|
||||
kategoriKegiatanId: k.kategoriKegiatanId,
|
||||
},
|
||||
create: {
|
||||
id: k.id,
|
||||
judul: k.judul,
|
||||
deskripsiSingkat: k.deskripsiSingkat,
|
||||
deskripsiLengkap: k.deskripsiLengkap,
|
||||
tanggal: k.tanggal,
|
||||
lokasi: k.lokasi,
|
||||
partisipan: k.partisipan,
|
||||
imageId: imageId,
|
||||
kategoriKegiatanId: k.kategoriKegiatanId,
|
||||
},
|
||||
});
|
||||
}
|
||||
console.log("✅ Gotong Royong seeded successfully");
|
||||
}
|
||||
27
prisma/_seeder_list/lingkungan/seed_data_lingkungan_desa.ts
Normal file
27
prisma/_seeder_list/lingkungan/seed_data_lingkungan_desa.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import dataLingkunganDesa from "../../data/lingkungan/data-lingkungan-desa/data-lingkungan-desa.json";
|
||||
|
||||
export async function seedDataLingkunganDesa() {
|
||||
console.log("🔄 Seeding Data Lingkungan Desa...");
|
||||
for (const p of dataLingkunganDesa) {
|
||||
await prisma.dataLingkunganDesa.upsert({
|
||||
where: {
|
||||
id: p.id,
|
||||
},
|
||||
update: {
|
||||
name: p.name,
|
||||
jumlah: p.jumlah,
|
||||
deskripsi: p.deskripsi,
|
||||
icon: p.icon,
|
||||
},
|
||||
create: {
|
||||
id: p.id,
|
||||
name: p.name,
|
||||
jumlah: p.jumlah,
|
||||
deskripsi: p.deskripsi,
|
||||
icon: p.icon,
|
||||
},
|
||||
});
|
||||
}
|
||||
console.log("✅ Data Lingkungan Desa seeded successfully");
|
||||
}
|
||||
63
prisma/_seeder_list/lingkungan/seed_edukasi_lingkungan.ts
Normal file
63
prisma/_seeder_list/lingkungan/seed_edukasi_lingkungan.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import tujuanEdukasiLingkungan from "../../data/lingkungan/edukasi-lingkungan/tujuan-edukasi-lingkungan.json";
|
||||
import materiEdukasiLingkungan from "../../data/lingkungan/edukasi-lingkungan/materi-edukasi-yang-diberikan.json";
|
||||
import contohEdukasiLingkungan from "../../data/lingkungan/edukasi-lingkungan/contoh-kegiatan-di-desa-darmasaba.json";
|
||||
|
||||
export async function seedEdukasiLingkungan() {
|
||||
for (const e of tujuanEdukasiLingkungan) {
|
||||
await prisma.tujuanEdukasiLingkungan.upsert({
|
||||
where: {
|
||||
id: e.id,
|
||||
},
|
||||
update: {
|
||||
judul: e.judul,
|
||||
deskripsi: e.deskripsi,
|
||||
},
|
||||
create: {
|
||||
id: e.id,
|
||||
judul: e.judul,
|
||||
deskripsi: e.deskripsi,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
console.log("tujuan edukasi lingkungan success ...");
|
||||
|
||||
for (const m of materiEdukasiLingkungan) {
|
||||
await prisma.materiEdukasiLingkungan.upsert({
|
||||
where: {
|
||||
id: m.id,
|
||||
},
|
||||
update: {
|
||||
judul: m.judul,
|
||||
deskripsi: m.deskripsi,
|
||||
},
|
||||
create: {
|
||||
id: m.id,
|
||||
judul: m.judul,
|
||||
deskripsi: m.deskripsi,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
console.log("materi edukasi lingkungan success ...");
|
||||
|
||||
for (const c of contohEdukasiLingkungan) {
|
||||
await prisma.contohEdukasiLingkungan.upsert({
|
||||
where: {
|
||||
id: c.id,
|
||||
},
|
||||
update: {
|
||||
judul: c.judul,
|
||||
deskripsi: c.deskripsi,
|
||||
},
|
||||
create: {
|
||||
id: c.id,
|
||||
judul: c.judul,
|
||||
deskripsi: c.deskripsi,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
console.log("contoh edukasi lingkungan success ...");
|
||||
}
|
||||
63
prisma/_seeder_list/lingkungan/seed_konservasi_adat_bali.ts
Normal file
63
prisma/_seeder_list/lingkungan/seed_konservasi_adat_bali.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import filosofiTriHita from "../../data/lingkungan/konservasi-adat-bali/filosofi-tri-hita.json";
|
||||
import bentukKonservasiBerdasarkanAdat from "../../data/lingkungan/konservasi-adat-bali/bentuk-konservasi.json";
|
||||
import nilaiKonservasiAdat from "../../data/lingkungan/konservasi-adat-bali/nilai-konservasi-adat.json";
|
||||
|
||||
export async function seedKonservasiAdatBali() {
|
||||
for (const f of filosofiTriHita) {
|
||||
await prisma.filosofiTriHita.upsert({
|
||||
where: {
|
||||
id: f.id,
|
||||
},
|
||||
update: {
|
||||
judul: f.judul,
|
||||
deskripsi: f.deskripsi,
|
||||
},
|
||||
create: {
|
||||
id: f.id,
|
||||
judul: f.judul,
|
||||
deskripsi: f.deskripsi,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
console.log("filosofi tri hita success ...");
|
||||
|
||||
for (const b of bentukKonservasiBerdasarkanAdat) {
|
||||
await prisma.bentukKonservasiBerdasarkanAdat.upsert({
|
||||
where: {
|
||||
id: b.id,
|
||||
},
|
||||
update: {
|
||||
judul: b.judul,
|
||||
deskripsi: b.deskripsi,
|
||||
},
|
||||
create: {
|
||||
id: b.id,
|
||||
judul: b.judul,
|
||||
deskripsi: b.deskripsi,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
console.log("bentuk konservasi berdasarkan adat success ...");
|
||||
|
||||
for (const n of nilaiKonservasiAdat) {
|
||||
await prisma.nilaiKonservasiAdat.upsert({
|
||||
where: {
|
||||
id: n.id,
|
||||
},
|
||||
update: {
|
||||
judul: n.judul,
|
||||
deskripsi: n.deskripsi,
|
||||
},
|
||||
create: {
|
||||
id: n.id,
|
||||
judul: n.judul,
|
||||
deskripsi: n.deskripsi,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
console.log("nilai konservasi adat success ...");
|
||||
}
|
||||
51
prisma/_seeder_list/lingkungan/seed_pengelolaan_sampah.ts
Normal file
51
prisma/_seeder_list/lingkungan/seed_pengelolaan_sampah.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import pengelolaanSampah from "../../data/lingkungan/pengelolaan-sampah/pengelolaan-sampah.json";
|
||||
import keteranganBankSampah from "../../data/lingkungan/pengelolaan-sampah/keterangan-bank-sampah.json";
|
||||
|
||||
export async function seedPengelolaanSampah() {
|
||||
console.log("🔄 Seeding Pengelolaan Sampah...");
|
||||
for (const p of pengelolaanSampah) {
|
||||
await prisma.pengelolaanSampah.upsert({
|
||||
where: {
|
||||
id: p.id,
|
||||
},
|
||||
update: {
|
||||
name: p.name,
|
||||
icon: p.icon,
|
||||
},
|
||||
create: {
|
||||
id: p.id,
|
||||
name: p.name,
|
||||
icon: p.icon,
|
||||
},
|
||||
});
|
||||
}
|
||||
console.log("✅ Pengelolaan Sampah seeded successfully");
|
||||
|
||||
console.log("🔄 Seeding Keterangan Bank Sampah...");
|
||||
for (const p of keteranganBankSampah) {
|
||||
await prisma.keteranganBankSampahTerdekat.upsert({
|
||||
where: {
|
||||
id: p.id,
|
||||
},
|
||||
update: {
|
||||
name: p.name,
|
||||
alamat: p.alamat,
|
||||
namaTempatMaps: p.namaTempatMaps,
|
||||
linkPetunjukArah: p.linkPetunjukArah,
|
||||
lat: p.lat,
|
||||
lng: p.lng,
|
||||
},
|
||||
create: {
|
||||
id: p.id,
|
||||
name: p.name,
|
||||
alamat: p.alamat,
|
||||
namaTempatMaps: p.namaTempatMaps,
|
||||
linkPetunjukArah: p.linkPetunjukArah,
|
||||
lat: p.lat,
|
||||
lng: p.lng,
|
||||
},
|
||||
});
|
||||
}
|
||||
console.log("✅ Keterangan Bank Sampah seeded successfully");
|
||||
}
|
||||
27
prisma/_seeder_list/lingkungan/seed_program_penghijauan.ts
Normal file
27
prisma/_seeder_list/lingkungan/seed_program_penghijauan.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import programPenghijauan from "../../data/lingkungan/program-penghijauan/program-penghijauan.json";
|
||||
|
||||
export async function seedProgramPenghijauan() {
|
||||
console.log("🔄 Seeding Program Penghijauan...");
|
||||
for (const p of programPenghijauan) {
|
||||
await prisma.programPenghijauan.upsert({
|
||||
where: {
|
||||
id: p.id,
|
||||
},
|
||||
update: {
|
||||
name: p.name,
|
||||
judul: p.judul,
|
||||
deskripsi: p.deskripsi,
|
||||
icon: p.icon,
|
||||
},
|
||||
create: {
|
||||
id: p.id,
|
||||
name: p.name,
|
||||
judul: p.judul,
|
||||
deskripsi: p.deskripsi,
|
||||
icon: p.icon,
|
||||
},
|
||||
});
|
||||
}
|
||||
console.log("✅ Program Penghijauan seeded successfully");
|
||||
}
|
||||
60
prisma/_seeder_list/pendidikan/seed_bimbingan_belajar.ts
Normal file
60
prisma/_seeder_list/pendidikan/seed_bimbingan_belajar.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import tujuanBimbinganBelajarDesa from "../../data/pendidikan/bimbingan-belajar-desa/tujuan-bimbingan-belajar-desa.json";
|
||||
import lokasiJadwalBimbinganBelajarDesa from "../../data/pendidikan/bimbingan-belajar-desa/lokasi-dan-jadwal.json";
|
||||
import fasilitasBimbinganBelajarDesa from "../../data/pendidikan/bimbingan-belajar-desa/fasilitas-yang-disediakan.json";
|
||||
|
||||
export async function seedBimbinganBelajar() {
|
||||
for (const t of tujuanBimbinganBelajarDesa) {
|
||||
await prisma.tujuanBimbinganBelajarDesa.upsert({
|
||||
where: { id: t.id },
|
||||
update: {
|
||||
judul: t.judul,
|
||||
deskripsi: t.deskripsi,
|
||||
},
|
||||
create: {
|
||||
id: t.id,
|
||||
judul: t.judul,
|
||||
deskripsi: t.deskripsi,
|
||||
},
|
||||
});
|
||||
}
|
||||
console.log(
|
||||
"✅ tujuan bimbingan belajar desa seeded (editable later via UI)",
|
||||
);
|
||||
|
||||
for (const t of lokasiJadwalBimbinganBelajarDesa) {
|
||||
await prisma.lokasiJadwalBimbinganBelajarDesa.upsert({
|
||||
where: { id: t.id },
|
||||
update: {
|
||||
judul: t.judul,
|
||||
deskripsi: t.deskripsi,
|
||||
},
|
||||
create: {
|
||||
id: t.id,
|
||||
judul: t.judul,
|
||||
deskripsi: t.deskripsi,
|
||||
},
|
||||
});
|
||||
}
|
||||
console.log(
|
||||
"✅ lokasi jadwal bimbingan belajar desa seeded (editable later via UI)",
|
||||
);
|
||||
|
||||
for (const t of fasilitasBimbinganBelajarDesa) {
|
||||
await prisma.fasilitasBimbinganBelajarDesa.upsert({
|
||||
where: { id: t.id },
|
||||
update: {
|
||||
judul: t.judul,
|
||||
deskripsi: t.deskripsi,
|
||||
},
|
||||
create: {
|
||||
id: t.id,
|
||||
judul: t.judul,
|
||||
deskripsi: t.deskripsi,
|
||||
},
|
||||
});
|
||||
}
|
||||
console.log(
|
||||
"✅ fasilitas bimbingan belajar desa seeded (editable later via UI)",
|
||||
);
|
||||
}
|
||||
23
prisma/_seeder_list/pendidikan/seed_data_pendidikan.ts
Normal file
23
prisma/_seeder_list/pendidikan/seed_data_pendidikan.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import dataPendidikan from "../../data/pendidikan/data-pendidikan/data-pendidikan.json";
|
||||
|
||||
export async function seedDataPendidikan() {
|
||||
console.log("🔄 Seeding Data pendidikan...");
|
||||
for (const k of dataPendidikan) {
|
||||
await prisma.dataPendidikan.upsert({
|
||||
where: {
|
||||
id: k.id,
|
||||
},
|
||||
update: {
|
||||
name: k.name,
|
||||
jumlah: k.jumlah,
|
||||
},
|
||||
create: {
|
||||
id: k.id,
|
||||
name: k.name,
|
||||
jumlah: k.jumlah,
|
||||
},
|
||||
});
|
||||
}
|
||||
console.log("✅ Data pendidikan seeded successfully");
|
||||
}
|
||||
62
prisma/_seeder_list/pendidikan/seed_data_perpustakaan.ts
Normal file
62
prisma/_seeder_list/pendidikan/seed_data_perpustakaan.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import dataPerpustakaan from "../../data/pendidikan/perpustakaan-digital/perpustakaan-digital.json";
|
||||
import kategoriBuku from "../../data/pendidikan/perpustakaan-digital/kategori-buku.json";
|
||||
|
||||
export async function seedDataPerpustakaan() {
|
||||
console.log("🔄 Seeding Kategori Buku...");
|
||||
for (const k of kategoriBuku) {
|
||||
await prisma.kategoriBuku.upsert({
|
||||
where: {
|
||||
id: k.id,
|
||||
},
|
||||
update: {
|
||||
name: k.name,
|
||||
},
|
||||
create: {
|
||||
id: k.id,
|
||||
name: k.name,
|
||||
},
|
||||
});
|
||||
}
|
||||
console.log("✅ Kategori Buku seeded successfully");
|
||||
|
||||
console.log("🔄 Seeding Data perpustakaan...");
|
||||
for (const k of dataPerpustakaan) {
|
||||
let imageId: string | null = null;
|
||||
|
||||
if (k.imageName) {
|
||||
const image = await prisma.fileStorage.findUnique({
|
||||
where: { name: k.imageName },
|
||||
select: { id: true },
|
||||
});
|
||||
|
||||
if (!image) {
|
||||
console.warn(
|
||||
`⚠️ Image not found for perpustakaan "${k.judul}": ${k.imageName}`,
|
||||
);
|
||||
} else {
|
||||
imageId = image.id;
|
||||
}
|
||||
}
|
||||
|
||||
await prisma.dataPerpustakaan.upsert({
|
||||
where: {
|
||||
id: k.id,
|
||||
},
|
||||
update: {
|
||||
judul: k.judul,
|
||||
deskripsi: k.deskripsi,
|
||||
kategoriId: k.kategoriId,
|
||||
imageId: imageId
|
||||
},
|
||||
create: {
|
||||
id: k.id,
|
||||
judul: k.judul,
|
||||
deskripsi: k.deskripsi,
|
||||
kategoriId: k.kategoriId,
|
||||
imageId: imageId
|
||||
},
|
||||
});
|
||||
}
|
||||
console.log("✅ Data perpustakaan seeded successfully");
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import tujuanProgram from "../../data/pendidikan/program-pendidikan-anak/tujuan-program.json";
|
||||
import programUnggulan from "../../data/pendidikan/program-pendidikan-anak/program-unggulan.json";
|
||||
|
||||
export async function seedInfoProgramPendidikan() {
|
||||
for (const t of tujuanProgram) {
|
||||
await prisma.tujuanProgram.upsert({
|
||||
where: { id: t.id },
|
||||
update: {
|
||||
judul: t.judul,
|
||||
deskripsi: t.deskripsi,
|
||||
},
|
||||
create: {
|
||||
id: t.id,
|
||||
judul: t.judul,
|
||||
deskripsi: t.deskripsi,
|
||||
},
|
||||
});
|
||||
}
|
||||
console.log("✅ tujuan program seeded (editable later via UI)");
|
||||
for (const t of programUnggulan) {
|
||||
await prisma.programUnggulan.upsert({
|
||||
where: { id: t.id },
|
||||
update: {
|
||||
judul: t.judul,
|
||||
deskripsi: t.deskripsi,
|
||||
},
|
||||
create: {
|
||||
id: t.id,
|
||||
judul: t.judul,
|
||||
deskripsi: t.deskripsi,
|
||||
},
|
||||
});
|
||||
}
|
||||
console.log("✅ program unggulan seeded (editable later via UI)");
|
||||
}
|
||||
74
prisma/_seeder_list/pendidikan/seed_info_sekolah.ts
Normal file
74
prisma/_seeder_list/pendidikan/seed_info_sekolah.ts
Normal file
@@ -0,0 +1,74 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import jenjangPendidikan from "../../data/pendidikan/info-sekolah/jenjang-pendidikan.json";
|
||||
import lembagaPendidikan from "../../data/pendidikan/info-sekolah/lembaga.json";
|
||||
import siswa from "../../data/pendidikan/info-sekolah/siswa.json";
|
||||
import pengajar from "../../data/pendidikan/info-sekolah/pengajar.json";
|
||||
|
||||
export async function seedInfoSekolah() {
|
||||
for (const j of jenjangPendidikan) {
|
||||
await prisma.jenjangPendidikan.upsert({
|
||||
where: {
|
||||
id: j.id,
|
||||
},
|
||||
update: {
|
||||
nama: j.nama,
|
||||
},
|
||||
create: {
|
||||
id: j.id,
|
||||
nama: j.nama,
|
||||
},
|
||||
});
|
||||
}
|
||||
console.log("✅ Jenjang Pendidikan seeded successfully");
|
||||
for (const j of lembagaPendidikan) {
|
||||
await prisma.lembaga.upsert({
|
||||
where: {
|
||||
id: j.id,
|
||||
},
|
||||
update: {
|
||||
nama: j.nama,
|
||||
jenjangId: j.jenjangId,
|
||||
},
|
||||
create: {
|
||||
id: j.id,
|
||||
nama: j.nama,
|
||||
jenjangId: j.jenjangId,
|
||||
},
|
||||
});
|
||||
}
|
||||
console.log("✅ Lembaga Pendidikan seeded successfully");
|
||||
for (const j of siswa) {
|
||||
await prisma.siswa.upsert({
|
||||
where: {
|
||||
id: j.id,
|
||||
},
|
||||
update: {
|
||||
nama: j.nama,
|
||||
lembagaId: j.lembagaId,
|
||||
},
|
||||
create: {
|
||||
id: j.id,
|
||||
nama: j.nama,
|
||||
lembagaId: j.lembagaId,
|
||||
},
|
||||
});
|
||||
}
|
||||
console.log("✅ siswa seeded successfully");
|
||||
for (const j of pengajar) {
|
||||
await prisma.pengajar.upsert({
|
||||
where: {
|
||||
id: j.id,
|
||||
},
|
||||
update: {
|
||||
nama: j.nama,
|
||||
lembagaId: j.lembagaId,
|
||||
},
|
||||
create: {
|
||||
id: j.id,
|
||||
nama: j.nama,
|
||||
lembagaId: j.lembagaId,
|
||||
},
|
||||
});
|
||||
}
|
||||
console.log("✅ pengajar seeded successfully");
|
||||
}
|
||||
60
prisma/_seeder_list/pendidikan/seed_pendidikan_non_formal.ts
Normal file
60
prisma/_seeder_list/pendidikan/seed_pendidikan_non_formal.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import tujuanProgram from "../../data/pendidikan/pendidikan-non-formal/tujuan-program2.json";
|
||||
import tempatKegiatan from "../../data/pendidikan/pendidikan-non-formal/tempat-kegiatan.json";
|
||||
import jenisProgramYangDiselenggarakan from "../../data/pendidikan/pendidikan-non-formal/jenis-program-yang-diselenggarakan.json";
|
||||
|
||||
export async function seedPendidikanNonFormal() {
|
||||
for (const t of tujuanProgram) {
|
||||
await prisma.tujuanPendidikanNonFormal.upsert({
|
||||
where: { id: t.id },
|
||||
update: {
|
||||
judul: t.judul,
|
||||
deskripsi: t.deskripsi,
|
||||
},
|
||||
create: {
|
||||
id: t.id,
|
||||
judul: t.judul,
|
||||
deskripsi: t.deskripsi,
|
||||
},
|
||||
});
|
||||
}
|
||||
console.log(
|
||||
"✅ fasilitas bimbingan belajar desa seeded (editable later via UI)",
|
||||
);
|
||||
|
||||
for (const t of tempatKegiatan) {
|
||||
await prisma.tempatKegiatan.upsert({
|
||||
where: { id: t.id },
|
||||
update: {
|
||||
judul: t.judul,
|
||||
deskripsi: t.deskripsi,
|
||||
},
|
||||
create: {
|
||||
id: t.id,
|
||||
judul: t.judul,
|
||||
deskripsi: t.deskripsi,
|
||||
},
|
||||
});
|
||||
}
|
||||
console.log(
|
||||
"✅ fasilitas bimbingan belajar desa seeded (editable later via UI)",
|
||||
);
|
||||
|
||||
for (const t of jenisProgramYangDiselenggarakan) {
|
||||
await prisma.jenisProgramYangDiselenggarakan.upsert({
|
||||
where: { id: t.id },
|
||||
update: {
|
||||
judul: t.judul,
|
||||
deskripsi: t.deskripsi,
|
||||
},
|
||||
create: {
|
||||
id: t.id,
|
||||
judul: t.judul,
|
||||
deskripsi: t.deskripsi,
|
||||
},
|
||||
});
|
||||
}
|
||||
console.log(
|
||||
"✅ fasilitas bimbingan belajar desa seeded (editable later via UI)",
|
||||
);
|
||||
}
|
||||
@@ -3,30 +3,30 @@
|
||||
"id": "cmkkshcox000504l88lp54coc",
|
||||
"name": "Darmasaba Digital App",
|
||||
"deskripsi": "<p>Aplikasi digital desa yang dikembangkan oleh Pemerintah Desa Darmasaba pada tahun 2024 untuk mempermudah pelayanan publik dan informasi pemerintahan berbasis digital.</p>",
|
||||
"imageId": "cmkksb3jr0005vni4sp3ogr87"
|
||||
"imageName": "r_gBF0FuFpFPfSENHc4XI-mobile.webp"
|
||||
},
|
||||
{
|
||||
"id": "cmkkshln8000604l8c9b5b4il",
|
||||
"name": "D’DAMART (Darmasaba Digital Market)",
|
||||
"deskripsi": "<p>Sistem pasar UMKM digital berbasis website yang dikembangkan untuk meningkatkan akses pasar dan pemasaran produk UMKM Desa Darmasaba melalui platform digital.</p>",
|
||||
"imageId": "cmkksoze80008vni4ki2ry81r"
|
||||
"imageName": "uE2QwpbcXyBWxVYqCWQQT-mobile.webp"
|
||||
},
|
||||
{
|
||||
"id": "cmkm1a1g80007vnsw8ejmj816",
|
||||
"name": "Media Aspirasi dan Pengaduan Warga",
|
||||
"deskripsi": "<p>Media aspirasi dan pengaduan warga disediakan sebagai wadah partisipasi masyarakat dalam menyampaikan saran, masukan, maupun keluhan secara transparan dan terstruktur. Fitur ini memperkuat komunikasi dua arah antara pemerintah desa dan masyarakat, sehingga setiap aspirasi dapat ditindaklanjuti secara lebih cepat dan akuntabel.</p>",
|
||||
"imageId": "cmkm1a14d0005vnsww1tsd92o"
|
||||
"imageName": "c7xWNyoYp8Cak28NG5NoG-mobile.webp"
|
||||
},
|
||||
{
|
||||
"id": "cmkm0w0s50003vnswmwpnqsi5",
|
||||
"name": "Website Desa Resmi",
|
||||
"deskripsi": "<p>Website Desa Darmasaba berfungsi sebagai sarana utama penyampaian informasi resmi kepada masyarakat. Melalui website ini, pemerintah desa menghadirkan keterbukaan informasi publik, mempermudah akses warga terhadap berita, pengumuman, serta agenda kegiatan desa, sekaligus menjadi pusat data dan referensi terkait profil dan struktur pemerintahan desa.</p>",
|
||||
"imageId": "cmkm0z9hx0004vnswtjd2bk3z"
|
||||
"imageName": "kN09yF3sahmy-d5EaeGqA-mobile.webp"
|
||||
},
|
||||
{
|
||||
"id": "cmkm1c8wx000avnswksc56orq",
|
||||
"name": "Publikasi Kegiatan Desa Secara Digital",
|
||||
"deskripsi": "<p>Publikasi kegiatan desa secara digital bertujuan untuk mendokumentasikan dan menyebarluaskan berbagai aktivitas serta program kerja pemerintah desa. Melalui artikel dan dokumentasi foto, masyarakat dapat mengetahui perkembangan kegiatan desa secara terbuka, sekaligus meningkatkan kepercayaan publik terhadap pelaksanaan program desa.</p>",
|
||||
"imageId": "cmkm1c8py0008vnsw0unbxkpq"
|
||||
"imageName": "h_Gd0SoeIJVTi_5TWUO-P-mobile.webp"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"deskripsiPengaduan": "<p>Permintaan Pemasangan Spanduk Larangan Bagi Hewan</p>",
|
||||
"lokasiKejadian": "Banjar Darmasaba Tengah",
|
||||
"jenisPengaduanId": "eommt91ma000004lb4dpq7ll1",
|
||||
"imageId": "cmkkxep9l000evni4xkegbk72"
|
||||
"imageName": "gyNi4s8TnK2UrViU-gN2C-mobile.webp"
|
||||
},
|
||||
{
|
||||
"id": "cmkkrxmub0004vni41cwyhid5",
|
||||
@@ -21,7 +21,7 @@
|
||||
"deskripsiPengaduan": "<p>Laporan Anjing Liar Sering Menyerang Warga</p>",
|
||||
"lokasiKejadian": "Jl. Raya Darmasaba",
|
||||
"jenisPengaduanId": "eommt91ma000004lb4dpq8mm2",
|
||||
"imageId": "cmkkx9e38000bvni4azjd3u53"
|
||||
"imageName": "SQqSobKRg3ShvgPw_H41h-mobile.webp"
|
||||
},
|
||||
{
|
||||
"id": "cmkkrxmub0004vni41cwyhid6",
|
||||
@@ -33,6 +33,6 @@
|
||||
"deskripsiPengaduan": "<p>Pengelolaan Sampah Rumah Tangga Belum Efektif</p>",
|
||||
"lokasiKejadian": "Banjar Bucu",
|
||||
"jenisPengaduanId": "eommt91ma000004lb4dpq7ll1",
|
||||
"imageId": "cmkky60sq0000vnjjc55k84d2"
|
||||
"imageName": "y78xZ2axTOjz87gRKjVAf-mobile.webp"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
"tanggal": "2024-01-28T00:00:00.000Z",
|
||||
"lokasi": "Pura Desa dan Pura Dalem, Desa Adat Tegal, Desa Darmasaba, Badung",
|
||||
"partisipan": 30,
|
||||
"imageId": "cmknb59md0000vnmam828iuzt",
|
||||
"imageName": "YgOX5qAP3O1PHG5XmQXkr-mobile.webp",
|
||||
"kategoriKegiatanId": "cmknan39v000004l8eiql149r"
|
||||
},
|
||||
{
|
||||
@@ -18,7 +18,7 @@
|
||||
"tanggal": "2023-11-17T00:00:00.000Z",
|
||||
"lokasi": "Desa Darmasaba, Badung",
|
||||
"partisipan": 25,
|
||||
"imageId": "cmknbp3vd0001vnmarjz542o7",
|
||||
"imageName": "qxqSDHe-akIRi1EkQFUbG-mobile.webp",
|
||||
"kategoriKegiatanId": "cmknan39v000004l8eiql149r"
|
||||
},
|
||||
{
|
||||
@@ -29,7 +29,7 @@
|
||||
"tanggal": "2022-05-26T00:00:00.000Z",
|
||||
"lokasi": "Pura Dalem Kangin, Desa Adat Tegal, Desa Darmasaba, Badung",
|
||||
"partisipan": 28,
|
||||
"imageId": "cmknbrj4r0002vnmantw9rn0l",
|
||||
"imageName": "iHTVkQZ1VdkMOXLt5qdAd-mobile.webp",
|
||||
"kategoriKegiatanId": "cmknan39v000004l8eiql149r"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -4,139 +4,139 @@
|
||||
"judul": "Laskar Pelangi",
|
||||
"deskripsi": "<p>Novel inspiratif tentang perjuangan anak-anak di Belitung dalam meraih pendidikan dan mimpi mereka</p>",
|
||||
"kategoriId": "cmkqb11mc000104jibq76bdzu",
|
||||
"imageId": "cmkqhbhxi0000vneamj3din9u"
|
||||
"imageName": "RnAdv7O0QAFrxkFLAXJSa-mobile.webp"
|
||||
},
|
||||
{
|
||||
"id": "cmkqhedff0005vneas3rtbumi",
|
||||
"judul": "Bumi Manusia",
|
||||
"deskripsi": "<p>Kisah kehidupan Minke di masa kolonial yang menggambarkan perjuangan, pendidikan, dan identitas bangsa</p>",
|
||||
"kategoriId": "cmkqb11mc000104jibqc7bdzu",
|
||||
"imageId": "cmkqhed8x0003vneakx0c7me2"
|
||||
"imageName": "71eZShq4FYAFLxpLfZB0W-mobile.webp"
|
||||
},
|
||||
{
|
||||
"id": "cmkqhg1g70008vneajbpz8phh",
|
||||
"judul": "Atomic Habits",
|
||||
"deskripsi": "<p>Panduan membangun kebiasaan kecil yang konsisten untuk menghasilkan perubahan besar dalam hidup</p>",
|
||||
"kategoriId": "cmkqb11mc000104jibqf7bdzu",
|
||||
"imageId": "cmkqhg1cb0006vneagsxa6t4t"
|
||||
"imageName": "Uxq3GXPqh7HN9fHmRkr3r-mobile.webp"
|
||||
},
|
||||
{
|
||||
"id": "cmkqhl6sr000bvneampx0svus",
|
||||
"judul": "Clean Code",
|
||||
"deskripsi": "<p>Buku wajib programmer tentang cara menulis kode yang bersih, mudah dibaca, dan mudah dirawat</p>",
|
||||
"kategoriId": "cmkqb11mc000104jibqd7bdzu",
|
||||
"imageId": "cmkqhl6mv0009vneasgix42ud"
|
||||
"imageName": "W5Fc0uRADNkIY3nZicvQA-mobile.webp"
|
||||
},
|
||||
{
|
||||
"id": "cmkqhoaa1000evnearppgpyxo",
|
||||
"judul": "Sejarah Indonesia Modern",
|
||||
"deskripsi": "<p>Membahas perjalanan sejarah Indonesia dari masa kolonial hingga era modern</p>",
|
||||
"kategoriId": "cmkqb11mc000104jibqc7bdzu",
|
||||
"imageId": "cmkqhoa5w000cvneah15n28zq"
|
||||
"imageName": "mp77Op-MwtPQZnH3so4JY-mobile.webp"
|
||||
},
|
||||
{
|
||||
"id": "cmkqhr9oc000hvnea677ad3kb",
|
||||
"judul": "Ensiklopedia Anak Pintar",
|
||||
"deskripsi": "<p>Buku referensi bergambar yang membantu anak mengenal ilmu pengetahuan secara menyenangkan</p>",
|
||||
"kategoriId": "cmkqb11mc000104jibqh7bdzu",
|
||||
"imageId": "cmkqhr9lg000fvneai3q8qw0s"
|
||||
"imageName": "V09ZxN1wOwbSFLQiDK0VQ-mobile.webp"
|
||||
},
|
||||
{
|
||||
"id": "cmkqi5ksf000kvnea9c04n2hy",
|
||||
"judul": "Filosofi Teras",
|
||||
"deskripsi": "<p>Pengenalan filsafat Stoikisme untuk menghadapi kehidupan modern dengan lebih tenang</p>",
|
||||
"kategoriId": "cmkqb11mc000104jibq87bdzu",
|
||||
"imageId": "cmkqi5knc000ivnea8grp7j06"
|
||||
"imageName": "Wqp4AyVkGjqRMED9Q5XAs-mobile.webp"
|
||||
},
|
||||
{
|
||||
"id": "cmkqi97hq000nvneaparjbcrm",
|
||||
"judul": "Pemrograman JavaScript Dasar",
|
||||
"deskripsi": "<p>Panduan dasar belajar JavaScript untuk pemula dalam dunia pengembangan web</p>",
|
||||
"kategoriId": "cmkqb11mc000104jibqd7bdzu",
|
||||
"imageId": "cmkqi9799000lvneamskmvpq5"
|
||||
"imageName": "NH4aLc7cVuutdQBCofTC0-mobile.webp"
|
||||
},
|
||||
{
|
||||
"id": "cmkqibjt9000qvnea13ox7fmv",
|
||||
"judul": "Pendidikan Karakter",
|
||||
"deskripsi": "<p>Buku yang membahas pentingnya pendidikan karakter dalam membentuk generasi bangsa</p>",
|
||||
"kategoriId": "cmkqb11mc000104jibqf7bdzu",
|
||||
"imageId": "cmkqibjj2000ovnea3zmmvdop"
|
||||
"imageName": "MLrsPrD6oiHsrNP4Lc8J7-mobile.webp"
|
||||
},
|
||||
{
|
||||
"id": "cmkqidnar000tvneaohk5v8k6",
|
||||
"judul": "Psikologi Kepribadian",
|
||||
"deskripsi": "<p>Mengenal teori-teori kepribadian manusia dalam perspektif psikologi</p>",
|
||||
"kategoriId": "cmkqb11mc000104jibq87bdzu",
|
||||
"imageId": "cmkqidn7e000rvnea5rl58f2e"
|
||||
"imageName": "iaIeNdhuxqltqKP7aZncQ-mobile.webp"
|
||||
},
|
||||
{
|
||||
"id": "cmkqifdiu000wvnea7xd0yi4f",
|
||||
"judul": "Ayat-Ayat Cinta",
|
||||
"deskripsi": "<p>Novel religi yang mengangkat kisah cinta, iman, dan perjuangan hidup</p>",
|
||||
"kategoriId": "cmkqb11mc000104jibqe7bdzu",
|
||||
"imageId": "cmkqifdfs000uvneajss8zswp"
|
||||
"imageName": "WUDssJ59pTKE_3IuTiZ2s-mobile.webp"
|
||||
},
|
||||
{
|
||||
"id": "cmkqik7vi000zvneae7d5cq9i",
|
||||
"judul": "Negeri 5 Menara",
|
||||
"deskripsi": "<p>Cerita persahabatan dan perjuangan santri dalam mengejar mimpi hingga ke mancanegara</p>",
|
||||
"kategoriId": "cmkqb11mc000104jibq76bdzu",
|
||||
"imageId": "cmkqik7p5000xvnea6krii3vw"
|
||||
"imageName": "RJH_-4_R_nlP7GVEQeD1M-mobile.webp"
|
||||
},
|
||||
{
|
||||
"id": "cmkqinno30012vneac1sgsvis",
|
||||
"judul": "Belajar UI/UX Design",
|
||||
"deskripsi": "<p>Panduan praktis memahami desain antarmuka dan pengalaman pengguna</p>",
|
||||
"kategoriId": "cmkqb11mc000104jibqd7bdzu",
|
||||
"imageId": "cmkqinnih0010vneakpjb9egl"
|
||||
"imageName": "9MA-Jx_36uoho2Tg40_G9-mobile.webp"
|
||||
},
|
||||
{
|
||||
"id": "cmkqiqegd0015vneawv5u5tpm",
|
||||
"judul": "Manajemen Waktu Efektif",
|
||||
"deskripsi": "<p>Teknik mengatur waktu agar lebih produktif dan fokus pada hal penting</p>",
|
||||
"kategoriId": "cmkqb11mc000104jibqf7bdzu",
|
||||
"imageId": "cmkqiqeb60013vnea2ygrq5rs"
|
||||
"imageName": "dkb7ZWFl28TREVcvH8sWd-mobile.webp"
|
||||
},
|
||||
{
|
||||
"id": "cmkqiurc60018vneavyd3pj9q",
|
||||
"judul": "Dongeng Nusantara",
|
||||
"deskripsi": "<p>Kumpulan dongeng tradisional Indonesia yang sarat pesan moral</p>",
|
||||
"kategoriId": "cmkqb11mc000104jibq76bdzu",
|
||||
"imageId": "cmkqiur960016vnea3werdoey"
|
||||
"imageName": "nVj3one6CLuWRd04QnsWo-mobile.webp"
|
||||
},
|
||||
{
|
||||
"id": "cmkqix2kb001bvnea5v81cw7p",
|
||||
"judul": "Ekonomi Makro",
|
||||
"deskripsi": "<p>Pembahasan konsep ekonomi makro secara sistematis dan mudah dipahami</p>",
|
||||
"kategoriId": "cmkqb11mc000104jibq87bdzu",
|
||||
"imageId": "cmkqix2go0019vnea8coousvn"
|
||||
"imageName": "AnB7JO4_6tlPTX3ypOVLi-mobile.webp"
|
||||
},
|
||||
{
|
||||
"id": "cmkqiyts2001evneahnk45ry5",
|
||||
"judul": "Seni Berpikir Kritis",
|
||||
"deskripsi": "<p>Buku yang membantu pembaca menghindari kesalahan berpikir dalam pengambilan keputusan</p>",
|
||||
"kategoriId": "cmkqb11mc000104jibq87bdzu",
|
||||
"imageId": "cmkqiytnv001cvnea7o2sv1vt"
|
||||
"imageName": "sAyoMERxL6JgFfiO22KPb-mobile.webp"
|
||||
},
|
||||
{
|
||||
"id": "cmkqj0nq0001hvnea06r8m3kj",
|
||||
"judul": "Seni Berpikir Kritis",
|
||||
"deskripsi": "<p>Buku yang membantu pembaca menghindari kesalahan berpikir dalam pengambilan keputusan</p>",
|
||||
"kategoriId": "cmkqb11mc000104jibq87bdzu",
|
||||
"imageId": "cmkqj0nn0001fvneaufur3nke"
|
||||
"imageName": "WeA-JP2Ks_32fv1k529vj-mobile.webp"
|
||||
},
|
||||
{
|
||||
"id": "cmkqj37w4001kvnea04n9w2bx",
|
||||
"judul": "Panduan Shalat Lengkap",
|
||||
"deskripsi": "<p>Panduan praktis dan lengkap tentang tata cara shalat sesuai tuntunan</p>",
|
||||
"kategoriId": "cmkqb11mc000104jibqe7bdzu",
|
||||
"imageId": "cmkqj37rg001ivneam29fgayr"
|
||||
"imageName": "pxlHu2kDmIprQqC2PuXaL-mobile.webp"
|
||||
},
|
||||
{
|
||||
"id": "cmkqj5qp6001nvnea4xhvluz3",
|
||||
"judul": "Cerita Sains untuk Anak",
|
||||
"deskripsi": "<p>Cerita edukatif yang mengenalkan sains kepada anak dengan bahasa sederhana</p>",
|
||||
"kategoriId": "cmkqb11mc000104jibqh7bdzu",
|
||||
"imageId": "cmkqj5ql6001lvnea6p0afr9f"
|
||||
"imageName": "G0iELZb2DhQDCCP5OdzJR-desktop.webp"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -1659,8 +1659,8 @@ model DesaDigital {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
deskripsi String @db.Text
|
||||
image FileStorage @relation(fields: [imageId], references: [id])
|
||||
imageId String
|
||||
image FileStorage? @relation(fields: [imageId], references: [id])
|
||||
imageId String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
deletedAt DateTime @default(now())
|
||||
@@ -1766,8 +1766,8 @@ model PengaduanMasyarakat {
|
||||
nik String
|
||||
judulPengaduan String
|
||||
lokasiKejadian String
|
||||
image FileStorage @relation(fields: [imageId], references: [id])
|
||||
imageId String
|
||||
image FileStorage? @relation(fields: [imageId], references: [id])
|
||||
imageId String?
|
||||
deskripsiPengaduan String @db.Text
|
||||
jenisPengaduan JenisPengaduan @relation(fields: [jenisPengaduanId], references: [id])
|
||||
jenisPengaduanId String
|
||||
@@ -1848,8 +1848,8 @@ model KegiatanDesa {
|
||||
tanggal DateTime
|
||||
lokasi String
|
||||
partisipan Int
|
||||
image FileStorage @relation(fields: [imageId], references: [id])
|
||||
imageId String
|
||||
image FileStorage? @relation(fields: [imageId], references: [id])
|
||||
imageId String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
deletedAt DateTime @default(now())
|
||||
@@ -2133,8 +2133,8 @@ model DataPerpustakaan {
|
||||
deskripsi String @db.Text
|
||||
kategori KategoriBuku @relation(fields: [kategoriId], references: [id])
|
||||
kategoriId String
|
||||
image FileStorage @relation(fields: [imageId], references: [id])
|
||||
imageId String
|
||||
image FileStorage? @relation(fields: [imageId], references: [id])
|
||||
imageId String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
deletedAt DateTime @default(now())
|
||||
|
||||
567
prisma/seed.ts
567
prisma/seed.ts
@@ -53,21 +53,23 @@ import { seedLayananOnlineDesa } from "./_seeder_list/inovasi/seed_layanan_onlin
|
||||
import { seedProgramKreatifDesa } from "./_seeder_list/inovasi/seed_program_kreatif_desa";
|
||||
import { seedKolaborasiInovasi } from "./_seeder_list/inovasi/seed_kolaborasi_inovasi";
|
||||
import { seedInfoTeknologi } from "./_seeder_list/inovasi/seed_info_teknologi";
|
||||
import { seedPengelolaanSampah } from "./_seeder_list/lingkungan/seed_pengelolaan_sampah";
|
||||
import { seedProgramPenghijauan } from "./_seeder_list/lingkungan/seed_program_penghijauan";
|
||||
import { seedDataLingkunganDesa } from "./_seeder_list/lingkungan/seed_data_lingkungan_desa";
|
||||
import { seedDataGotongRoyong } from "./_seeder_list/lingkungan/seed_data_gotong_royong";
|
||||
import { seedEdukasiLingkungan } from "./_seeder_list/lingkungan/seed_edukasi_lingkungan";
|
||||
import { seedKonservasiAdatBali } from "./_seeder_list/lingkungan/seed_konservasi_adat_bali";
|
||||
import { seedInfoSekolah } from "./_seeder_list/pendidikan/seed_info_sekolah";
|
||||
import { seedInfoProgramPendidikan } from "./_seeder_list/pendidikan/seed_info_program_pendidikan";
|
||||
import { seedBimbinganBelajar } from "./_seeder_list/pendidikan/seed_bimbingan_belajar";
|
||||
import { seedDataPendidikan } from "./_seeder_list/pendidikan/seed_data_pendidikan";
|
||||
import { seedPendidikanNonFormal } from "./_seeder_list/pendidikan/seed_pendidikan_non_formal";
|
||||
import { seedDataPerpustakaan } from "./_seeder_list/pendidikan/seed_data_perpustakaan";
|
||||
|
||||
(async () => {
|
||||
const totalFiles = await prisma.fileStorage.count();
|
||||
|
||||
const hasImageAsset = await prisma.fileStorage.findFirst({
|
||||
where: { category: "image" },
|
||||
select: { id: true },
|
||||
});
|
||||
|
||||
if (totalFiles === 0 || !hasImageAsset) {
|
||||
console.log("📂 fileStorage not ready, seeding assets...");
|
||||
await seedAssets();
|
||||
} else {
|
||||
console.log("ℹ️ fileStorage already initialized, skipping asset seed");
|
||||
}
|
||||
// Always run seedAssets to handle new images without duplication
|
||||
console.log("📂 Checking for new assets to seed...");
|
||||
await seedAssets();
|
||||
|
||||
// // =========== FILE STORAGE ===========
|
||||
|
||||
@@ -279,7 +281,7 @@ import { seedInfoTeknologi } from "./_seeder_list/inovasi/seed_info_teknologi";
|
||||
await seedProgramKemiskinan();
|
||||
|
||||
// // ==================== SUBMENU SEKTOR UNGGULAN DESA =============
|
||||
await seedSektorUnggulanDesa();
|
||||
await seedSektorUnggulanDesa();
|
||||
|
||||
// // ==================== SUBMENU DEMOGRAFI PEKERJAAN =============
|
||||
await seedDemografiPekerjaan();
|
||||
@@ -303,554 +305,41 @@ import { seedInfoTeknologi } from "./_seeder_list/inovasi/seed_info_teknologi";
|
||||
|
||||
// // ====================== MENU LINGKUNGAN ==========================
|
||||
// // ==================== SUBMENU PENGELOLAAN SAMPAH ==========
|
||||
// console.log("🔄 Seeding Pengelolaan Sampah...");
|
||||
// for (const p of pengelolaanSampah) {
|
||||
// await prisma.pengelolaanSampah.upsert({
|
||||
// where: {
|
||||
// id: p.id,
|
||||
// },
|
||||
// update: {
|
||||
// name: p.name,
|
||||
// icon: p.icon,
|
||||
// },
|
||||
// create: {
|
||||
// id: p.id,
|
||||
// name: p.name,
|
||||
// icon: p.icon,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
// console.log("✅ Pengelolaan Sampah seeded successfully");
|
||||
|
||||
// console.log("🔄 Seeding Keterangan Bank Sampah...");
|
||||
// for (const p of keteranganBankSampah) {
|
||||
// await prisma.keteranganBankSampahTerdekat.upsert({
|
||||
// where: {
|
||||
// id: p.id,
|
||||
// },
|
||||
// update: {
|
||||
// name: p.name,
|
||||
// alamat: p.alamat,
|
||||
// namaTempatMaps: p.namaTempatMaps,
|
||||
// linkPetunjukArah: p.linkPetunjukArah,
|
||||
// lat: p.lat,
|
||||
// lng: p.lng,
|
||||
// },
|
||||
// create: {
|
||||
// id: p.id,
|
||||
// name: p.name,
|
||||
// alamat: p.alamat,
|
||||
// namaTempatMaps: p.namaTempatMaps,
|
||||
// linkPetunjukArah: p.linkPetunjukArah,
|
||||
// lat: p.lat,
|
||||
// lng: p.lng,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
// console.log("✅ Keterangan Bank Sampah seeded successfully");
|
||||
await seedPengelolaanSampah();
|
||||
|
||||
// // ==================== SUBMENU PROGRAM PENGHIJAUAN ==========
|
||||
// console.log("🔄 Seeding Program Penghijauan...");
|
||||
// for (const p of programPenghijauan) {
|
||||
// await prisma.programPenghijauan.upsert({
|
||||
// where: {
|
||||
// id: p.id,
|
||||
// },
|
||||
// update: {
|
||||
// name: p.name,
|
||||
// judul: p.judul,
|
||||
// deskripsi: p.deskripsi,
|
||||
// icon: p.icon,
|
||||
// },
|
||||
// create: {
|
||||
// id: p.id,
|
||||
// name: p.name,
|
||||
// judul: p.judul,
|
||||
// deskripsi: p.deskripsi,
|
||||
// icon: p.icon,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
// console.log("✅ Program Penghijauan seeded successfully");
|
||||
await seedProgramPenghijauan();
|
||||
|
||||
// // ==================== SUBMENU DATA LINGKUNGAN DESA ==========
|
||||
// console.log("🔄 Seeding Data Lingkungan Desa...");
|
||||
// for (const p of dataLingkunganDesa) {
|
||||
// await prisma.dataLingkunganDesa.upsert({
|
||||
// where: {
|
||||
// id: p.id,
|
||||
// },
|
||||
// update: {
|
||||
// name: p.name,
|
||||
// jumlah: p.jumlah,
|
||||
// deskripsi: p.deskripsi,
|
||||
// icon: p.icon,
|
||||
// },
|
||||
// create: {
|
||||
// id: p.id,
|
||||
// name: p.name,
|
||||
// jumlah: p.jumlah,
|
||||
// deskripsi: p.deskripsi,
|
||||
// icon: p.icon,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
// console.log("✅ Data Lingkungan Desa seeded successfully");
|
||||
await seedDataLingkunganDesa();
|
||||
|
||||
// // =========== SUBMENU GOTONG ROYONG ===========
|
||||
// console.log("🔄 Seeding Kategori Gotong Royong...");
|
||||
|
||||
// for (const k of kategoriGotongRoyong) {
|
||||
// await prisma.kategoriKegiatan.upsert({
|
||||
// where: {
|
||||
// id: k.id,
|
||||
// },
|
||||
// update: {
|
||||
// nama: k.nama,
|
||||
// },
|
||||
// create: {
|
||||
// id: k.id,
|
||||
// nama: k.nama,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
|
||||
// console.log("✅ Kategori Gotong Royong seeded successfully");
|
||||
|
||||
// console.log("🔄 Seeding Gotong Royong...");
|
||||
|
||||
// for (const k of gotongRoyong) {
|
||||
// await prisma.kegiatanDesa.upsert({
|
||||
// where: {
|
||||
// id: k.id,
|
||||
// },
|
||||
// update: {
|
||||
// judul: k.judul,
|
||||
// deskripsiSingkat: k.deskripsiSingkat,
|
||||
// deskripsiLengkap: k.deskripsiLengkap,
|
||||
// tanggal: k.tanggal,
|
||||
// lokasi: k.lokasi,
|
||||
// partisipan: k.partisipan,
|
||||
// imageId: k.imageId,
|
||||
// kategoriKegiatanId: k.kategoriKegiatanId,
|
||||
// },
|
||||
// create: {
|
||||
// id: k.id,
|
||||
// judul: k.judul,
|
||||
// deskripsiSingkat: k.deskripsiSingkat,
|
||||
// deskripsiLengkap: k.deskripsiLengkap,
|
||||
// tanggal: k.tanggal,
|
||||
// lokasi: k.lokasi,
|
||||
// partisipan: k.partisipan,
|
||||
// imageId: k.imageId,
|
||||
// kategoriKegiatanId: k.kategoriKegiatanId,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
|
||||
// console.log("✅ Kategori Gotong Royong seeded successfully");
|
||||
await seedDataGotongRoyong();
|
||||
|
||||
// // =========== SUBMENU EDUKASI LINGKUNGAN ===========
|
||||
|
||||
// for (const e of tujuanEdukasiLingkungan) {
|
||||
// await prisma.tujuanEdukasiLingkungan.upsert({
|
||||
// where: {
|
||||
// id: e.id,
|
||||
// },
|
||||
// update: {
|
||||
// judul: e.judul,
|
||||
// deskripsi: e.deskripsi,
|
||||
// },
|
||||
// create: {
|
||||
// id: e.id,
|
||||
// judul: e.judul,
|
||||
// deskripsi: e.deskripsi,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
|
||||
// console.log("tujuan edukasi lingkungan success ...");
|
||||
|
||||
// for (const m of materiEdukasiLingkungan) {
|
||||
// await prisma.materiEdukasiLingkungan.upsert({
|
||||
// where: {
|
||||
// id: m.id,
|
||||
// },
|
||||
// update: {
|
||||
// judul: m.judul,
|
||||
// deskripsi: m.deskripsi,
|
||||
// },
|
||||
// create: {
|
||||
// id: m.id,
|
||||
// judul: m.judul,
|
||||
// deskripsi: m.deskripsi,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
|
||||
// console.log("materi edukasi lingkungan success ...");
|
||||
|
||||
// for (const c of contohEdukasiLingkungan) {
|
||||
// await prisma.contohEdukasiLingkungan.upsert({
|
||||
// where: {
|
||||
// id: c.id,
|
||||
// },
|
||||
// update: {
|
||||
// judul: c.judul,
|
||||
// deskripsi: c.deskripsi,
|
||||
// },
|
||||
// create: {
|
||||
// id: c.id,
|
||||
// judul: c.judul,
|
||||
// deskripsi: c.deskripsi,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
|
||||
// console.log("contoh edukasi lingkungan success ...");
|
||||
await seedEdukasiLingkungan();
|
||||
|
||||
// // =========== SUBMENU KONSERVASI ADAT BALI ===========
|
||||
|
||||
// for (const f of filosofiTriHita) {
|
||||
// await prisma.filosofiTriHita.upsert({
|
||||
// where: {
|
||||
// id: f.id,
|
||||
// },
|
||||
// update: {
|
||||
// judul: f.judul,
|
||||
// deskripsi: f.deskripsi,
|
||||
// },
|
||||
// create: {
|
||||
// id: f.id,
|
||||
// judul: f.judul,
|
||||
// deskripsi: f.deskripsi,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
|
||||
// console.log("filosofi tri hita success ...");
|
||||
|
||||
// for (const b of bentukKonservasiBerdasarkanAdat) {
|
||||
// await prisma.bentukKonservasiBerdasarkanAdat.upsert({
|
||||
// where: {
|
||||
// id: b.id,
|
||||
// },
|
||||
// update: {
|
||||
// judul: b.judul,
|
||||
// deskripsi: b.deskripsi,
|
||||
// },
|
||||
// create: {
|
||||
// id: b.id,
|
||||
// judul: b.judul,
|
||||
// deskripsi: b.deskripsi,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
|
||||
// console.log("bentuk konservasi berdasarkan adat success ...");
|
||||
|
||||
// for (const n of nilaiKonservasiAdat) {
|
||||
// await prisma.nilaiKonservasiAdat.upsert({
|
||||
// where: {
|
||||
// id: n.id,
|
||||
// },
|
||||
// update: {
|
||||
// judul: n.judul,
|
||||
// deskripsi: n.deskripsi,
|
||||
// },
|
||||
// create: {
|
||||
// id: n.id,
|
||||
// judul: n.judul,
|
||||
// deskripsi: n.deskripsi,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
|
||||
// console.log("nilai konservasi adat success ...");
|
||||
await seedKonservasiAdatBali();
|
||||
|
||||
// // ====================== MENU PENDIDIKAN ==========================
|
||||
// // =========== SUBMENU INFO SEKOLAH =====================
|
||||
|
||||
// for (const j of jenjangPendidikan) {
|
||||
// await prisma.jenjangPendidikan.upsert({
|
||||
// where: {
|
||||
// id: j.id,
|
||||
// },
|
||||
// update: {
|
||||
// nama: j.nama,
|
||||
// },
|
||||
// create: {
|
||||
// id: j.id,
|
||||
// nama: j.nama,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
|
||||
// console.log("✅ Jenjang Pendidikan seeded successfully");
|
||||
|
||||
// for (const j of lembagaPendidikan) {
|
||||
// await prisma.lembaga.upsert({
|
||||
// where: {
|
||||
// id: j.id,
|
||||
// },
|
||||
// update: {
|
||||
// nama: j.nama,
|
||||
// jenjangId: j.jenjangId,
|
||||
// },
|
||||
// create: {
|
||||
// id: j.id,
|
||||
// nama: j.nama,
|
||||
// jenjangId: j.jenjangId,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
|
||||
// console.log("✅ Lembaga Pendidikan seeded successfully");
|
||||
|
||||
// for (const j of siswa) {
|
||||
// await prisma.siswa.upsert({
|
||||
// where: {
|
||||
// id: j.id,
|
||||
// },
|
||||
// update: {
|
||||
// nama: j.nama,
|
||||
// lembagaId: j.lembagaId,
|
||||
// },
|
||||
// create: {
|
||||
// id: j.id,
|
||||
// nama: j.nama,
|
||||
// lembagaId: j.lembagaId,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
|
||||
// console.log("✅ siswa seeded successfully");
|
||||
|
||||
// for (const j of pengajar) {
|
||||
// await prisma.pengajar.upsert({
|
||||
// where: {
|
||||
// id: j.id,
|
||||
// },
|
||||
// update: {
|
||||
// nama: j.nama,
|
||||
// lembagaId: j.lembagaId,
|
||||
// },
|
||||
// create: {
|
||||
// id: j.id,
|
||||
// nama: j.nama,
|
||||
// lembagaId: j.lembagaId,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
|
||||
// console.log("✅ pengajar seeded successfully");
|
||||
await seedInfoSekolah();
|
||||
|
||||
// // =========== SUBMENU PROGRAM PENDIDIKAN ANAK =====================
|
||||
|
||||
// for (const t of tujuanProgram) {
|
||||
// await prisma.tujuanProgram.upsert({
|
||||
// where: { id: t.id },
|
||||
// update: {
|
||||
// judul: t.judul,
|
||||
// deskripsi: t.deskripsi,
|
||||
// },
|
||||
// create: {
|
||||
// id: t.id,
|
||||
// judul: t.judul,
|
||||
// deskripsi: t.deskripsi,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
// console.log("✅ tujuan program seeded (editable later via UI)");
|
||||
|
||||
// for (const t of programUnggulan) {
|
||||
// await prisma.programUnggulan.upsert({
|
||||
// where: { id: t.id },
|
||||
// update: {
|
||||
// judul: t.judul,
|
||||
// deskripsi: t.deskripsi,
|
||||
// },
|
||||
// create: {
|
||||
// id: t.id,
|
||||
// judul: t.judul,
|
||||
// deskripsi: t.deskripsi,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
// console.log("✅ program unggulan seeded (editable later via UI)");
|
||||
await seedInfoProgramPendidikan();
|
||||
|
||||
// // =========== SUBMENU BIMBINGAN BELAJAR DESA =====================
|
||||
|
||||
// for (const t of tujuanBimbinganBelajarDesa) {
|
||||
// await prisma.tujuanBimbinganBelajarDesa.upsert({
|
||||
// where: { id: t.id },
|
||||
// update: {
|
||||
// judul: t.judul,
|
||||
// deskripsi: t.deskripsi,
|
||||
// },
|
||||
// create: {
|
||||
// id: t.id,
|
||||
// judul: t.judul,
|
||||
// deskripsi: t.deskripsi,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
// console.log(
|
||||
// "✅ tujuan bimbingan belajar desa seeded (editable later via UI)",
|
||||
// );
|
||||
|
||||
// for (const t of lokasiJadwalBimbinganBelajarDesa) {
|
||||
// await prisma.lokasiJadwalBimbinganBelajarDesa.upsert({
|
||||
// where: { id: t.id },
|
||||
// update: {
|
||||
// judul: t.judul,
|
||||
// deskripsi: t.deskripsi,
|
||||
// },
|
||||
// create: {
|
||||
// id: t.id,
|
||||
// judul: t.judul,
|
||||
// deskripsi: t.deskripsi,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
// console.log(
|
||||
// "✅ lokasi jadwal bimbingan belajar desa seeded (editable later via UI)",
|
||||
// );
|
||||
|
||||
// for (const t of fasilitasBimbinganBelajarDesa) {
|
||||
// await prisma.fasilitasBimbinganBelajarDesa.upsert({
|
||||
// where: { id: t.id },
|
||||
// update: {
|
||||
// judul: t.judul,
|
||||
// deskripsi: t.deskripsi,
|
||||
// },
|
||||
// create: {
|
||||
// id: t.id,
|
||||
// judul: t.judul,
|
||||
// deskripsi: t.deskripsi,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
// console.log(
|
||||
// "✅ fasilitas bimbingan belajar desa seeded (editable later via UI)",
|
||||
// );
|
||||
await seedBimbinganBelajar();
|
||||
|
||||
// // =========== SUBMENU PENDIDIKAN NON FORMAL =====================
|
||||
|
||||
// for (const t of tujuanProgram2) {
|
||||
// await prisma.tujuanPendidikanNonFormal.upsert({
|
||||
// where: { id: t.id },
|
||||
// update: {
|
||||
// judul: t.judul,
|
||||
// deskripsi: t.deskripsi,
|
||||
// },
|
||||
// create: {
|
||||
// id: t.id,
|
||||
// judul: t.judul,
|
||||
// deskripsi: t.deskripsi,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
// console.log(
|
||||
// "✅ fasilitas bimbingan belajar desa seeded (editable later via UI)",
|
||||
// );
|
||||
|
||||
// for (const t of tempatKegiatan) {
|
||||
// await prisma.tempatKegiatan.upsert({
|
||||
// where: { id: t.id },
|
||||
// update: {
|
||||
// judul: t.judul,
|
||||
// deskripsi: t.deskripsi,
|
||||
// },
|
||||
// create: {
|
||||
// id: t.id,
|
||||
// judul: t.judul,
|
||||
// deskripsi: t.deskripsi,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
// console.log(
|
||||
// "✅ fasilitas bimbingan belajar desa seeded (editable later via UI)",
|
||||
// );
|
||||
|
||||
// for (const t of jenisProgramYangDiselenggarakan) {
|
||||
// await prisma.jenisProgramYangDiselenggarakan.upsert({
|
||||
// where: { id: t.id },
|
||||
// update: {
|
||||
// judul: t.judul,
|
||||
// deskripsi: t.deskripsi,
|
||||
// },
|
||||
// create: {
|
||||
// id: t.id,
|
||||
// judul: t.judul,
|
||||
// deskripsi: t.deskripsi,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
// console.log(
|
||||
// "✅ fasilitas bimbingan belajar desa seeded (editable later via UI)",
|
||||
// );
|
||||
|
||||
await seedPendidikanNonFormal();
|
||||
// // =========== SUBMENU PERPUSTAKAAN DIGITAL =====================
|
||||
// console.log("🔄 Seeding Kategori Buku...");
|
||||
// for (const k of kategoriBuku) {
|
||||
// await prisma.kategoriBuku.upsert({
|
||||
// where: {
|
||||
// id: k.id,
|
||||
// },
|
||||
// update: {
|
||||
// name: k.name,
|
||||
// },
|
||||
// create: {
|
||||
// id: k.id,
|
||||
// name: k.name,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
// console.log("✅ Kategori Buku seeded successfully");
|
||||
|
||||
// console.log("🔄 Seeding Data perpustakaan...");
|
||||
// for (const k of dataPerpustakaan) {
|
||||
// await prisma.dataPerpustakaan.upsert({
|
||||
// where: {
|
||||
// id: k.id,
|
||||
// },
|
||||
// update: {
|
||||
// judul: k.judul,
|
||||
// deskripsi: k.deskripsi,
|
||||
// kategoriId: k.kategoriId,
|
||||
// imageId: k.imageId,
|
||||
// },
|
||||
// create: {
|
||||
// id: k.id,
|
||||
// judul: k.judul,
|
||||
// deskripsi: k.deskripsi,
|
||||
// kategoriId: k.kategoriId,
|
||||
// imageId: k.imageId,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
// console.log("✅ Data perpustakaan seeded successfully");
|
||||
await seedDataPerpustakaan();
|
||||
|
||||
// =========== SUBMENU DATA PENDIDIKAN =====================
|
||||
console.log("🔄 Seeding Data pendidikan...");
|
||||
for (const k of dataPendidikan) {
|
||||
await prisma.dataPendidikan.upsert({
|
||||
where: {
|
||||
id: k.id,
|
||||
},
|
||||
update: {
|
||||
name: k.name,
|
||||
jumlah: k.jumlah,
|
||||
},
|
||||
create: {
|
||||
id: k.id,
|
||||
name: k.name,
|
||||
jumlah: k.jumlah,
|
||||
},
|
||||
});
|
||||
}
|
||||
console.log("✅ Data pendidikan seeded successfully");
|
||||
await seedDataPendidikan();
|
||||
})()
|
||||
.then(() => prisma.$disconnect())
|
||||
.catch((e) => {
|
||||
|
||||
@@ -8,24 +8,30 @@ export default async function seedAssets() {
|
||||
|
||||
for (const img of images) {
|
||||
try {
|
||||
await prisma.fileStorage.upsert({
|
||||
where: {
|
||||
id: img.name,
|
||||
},
|
||||
create: {
|
||||
name: img.name,
|
||||
category: "image",
|
||||
mimeType: "image/webp",
|
||||
link: img.downloadUrl,
|
||||
path: "images",
|
||||
realName: img.name,
|
||||
isActive: true,
|
||||
},
|
||||
update: {},
|
||||
// Check if the image already exists by name
|
||||
const existingImage = await prisma.fileStorage.findUnique({
|
||||
where: { name: img.name },
|
||||
});
|
||||
console.log(img.name, ": success")
|
||||
|
||||
if (!existingImage) {
|
||||
// Only create if it doesn't exist
|
||||
await prisma.fileStorage.create({
|
||||
data: {
|
||||
name: img.name,
|
||||
category: "image",
|
||||
mimeType: "image/webp",
|
||||
link: img.downloadUrl,
|
||||
path: "images",
|
||||
realName: img.name,
|
||||
isActive: true,
|
||||
},
|
||||
});
|
||||
console.log(`✅ Created new image: ${img.name}`);
|
||||
} else {
|
||||
console.log(`ℹ️ Image already exists, skipping: ${img.name}`);
|
||||
}
|
||||
} catch (err) {
|
||||
console.log("gagal seed assets", JSON.stringify(err));
|
||||
console.log(`❌ Failed to seed asset ${img.name}:`, JSON.stringify(err));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ function Page() {
|
||||
}}
|
||||
>
|
||||
<Image
|
||||
src={v.image.link}
|
||||
src={v.image?.link || "/no-image.jpg"}
|
||||
alt={v.name}
|
||||
fit="cover"
|
||||
loading="lazy"
|
||||
|
||||
@@ -214,14 +214,15 @@ export default function Page() {
|
||||
{paginatedNews.map((item) => (
|
||||
<Card key={item.id} shadow="sm" p="lg" radius="md" withBorder>
|
||||
<Card.Section>
|
||||
<Image
|
||||
src={item.image?.link || '/images/placeholder-small.jpg'}
|
||||
height={200}
|
||||
alt={item.judul}
|
||||
fit="cover"
|
||||
loading="lazy"
|
||||
radius={"md"}
|
||||
/>
|
||||
<Box h={160} w="100%" style={{ overflow: 'hidden' }}>
|
||||
<Image
|
||||
src={item.image?.link || '/images/placeholder-small.jpg'}
|
||||
alt={item.judul}
|
||||
fit="cover"
|
||||
loading="lazy"
|
||||
radius={"md"}
|
||||
/>
|
||||
</Box>
|
||||
</Card.Section>
|
||||
|
||||
<Badge color="blue" variant="light" mt="md">
|
||||
|
||||
@@ -119,7 +119,13 @@ export default function DetailBukuUser() {
|
||||
<ModalPeminjaman
|
||||
opened={opened}
|
||||
onClose={() => setOpened(false)}
|
||||
buku={data}
|
||||
buku={{
|
||||
id: data.id,
|
||||
judul: data.judul,
|
||||
deskripsi: data.deskripsi,
|
||||
image: data.image ? { link: data.image.link } : undefined,
|
||||
kategori: data.kategori ? { name: data.kategori.name } : undefined,
|
||||
}}
|
||||
/>
|
||||
</Box>
|
||||
);
|
||||
|
||||
@@ -223,7 +223,13 @@ export default function Content() {
|
||||
fullWidth
|
||||
leftSection={<IconBook2 size={20} />}
|
||||
onClick={() => {
|
||||
setSelectedBook(v);
|
||||
setSelectedBook({
|
||||
id: v.id,
|
||||
judul: v.judul,
|
||||
deskripsi: v.deskripsi,
|
||||
image: v.image ? { link: v.image.link } : undefined,
|
||||
kategori: v.kategori ? { name: v.kategori.name } : undefined,
|
||||
});
|
||||
setOpened(true);
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -36,8 +36,67 @@ const getCurrentTime = () => {
|
||||
return `${hours}:${minutes}`;
|
||||
};
|
||||
|
||||
const isWorkingHours = (currentTime: string): boolean => {
|
||||
const [openTime, closeTime] = ["08:00", "17:00"];
|
||||
// Fungsi untuk mendapatkan tanggal hari ini dalam format YYYY-MM-DD
|
||||
const getTodayDate = (): string => {
|
||||
const today = new Date();
|
||||
const year = today.getFullYear();
|
||||
const month = String(today.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(today.getDate()).padStart(2, '0');
|
||||
return `${year}-${month}-${day}`;
|
||||
};
|
||||
|
||||
// Fungsi untuk memeriksa apakah tanggal tertentu adalah hari libur nasional
|
||||
// Daftar hari libur nasional Indonesia (bisa diperbarui sesuai tahun berjalan)
|
||||
const isNationalHoliday = (date: string): boolean => {
|
||||
// Format tanggal harus dalam bentuk YYYY-MM-DD
|
||||
const holidays = [
|
||||
// Tahun 2026
|
||||
'2026-01-01', // Tahun Baru Masehi
|
||||
'2026-02-17', // Isra Mikraj Nabi Muhammad SAW
|
||||
'2026-03-08', // Hari Raya Nyepi Tahun Baru Saka 1948
|
||||
'2026-04-03', // Wafat Isa Almasih
|
||||
'2026-05-01', // Hari Buruh Internasional
|
||||
'2026-05-20', // Kenaikan Isa Almasih
|
||||
'2026-06-01', // Hari Lahir Pancasila
|
||||
'2026-06-05', // Hari Raya Idul Adha
|
||||
'2026-08-17', // Hari Kemerdekaan RI
|
||||
'2026-09-21', // Tahun Baru Islam 1448 H
|
||||
'2026-10-02', // Maulid Nabi Muhammad SAW
|
||||
'2026-12-25', // Hari Raya Natal
|
||||
|
||||
// Hari raya besar lainnya
|
||||
'2026-04-06', // Hari Raya Idul Fitri
|
||||
'2026-04-07', // Hari Raya Idul Fitri
|
||||
|
||||
// Hari libur pengganti
|
||||
'2026-04-08', // Hari Libur Pengganti Idul Fitri
|
||||
'2026-04-09', // Hari Libur Pengganti Idul Fitri
|
||||
];
|
||||
|
||||
return holidays.includes(date);
|
||||
};
|
||||
|
||||
const isWorkingHours = (day: string, currentTime: string): boolean => {
|
||||
// Cek apakah hari ini hari libur nasional
|
||||
if (isNationalHoliday(getTodayDate())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let openTime = "";
|
||||
let closeTime = "";
|
||||
|
||||
// Atur jam kerja berdasarkan hari
|
||||
if (["Senin", "Selasa", "Rabu", "Kamis"].includes(day)) {
|
||||
openTime = "07:30";
|
||||
closeTime = "15:30";
|
||||
} else if (day === "Jumat") {
|
||||
openTime = "07:30";
|
||||
closeTime = "12:00";
|
||||
} else {
|
||||
// Sabtu dan Minggu tutup
|
||||
return false;
|
||||
}
|
||||
|
||||
const compareTimes = (time1: string, time2: string) => {
|
||||
const [hour1, minute1] = time1.split(":").map(Number);
|
||||
const [hour2, minute2] = time2.split(":").map(Number);
|
||||
@@ -45,18 +104,33 @@ const isWorkingHours = (currentTime: string): boolean => {
|
||||
if (hour1 > hour2) return false;
|
||||
return minute1 <= minute2;
|
||||
};
|
||||
|
||||
return compareTimes(currentTime, closeTime) && !compareTimes(currentTime, openTime);
|
||||
};
|
||||
|
||||
const getWorkStatus = (day: string, currentTime: string): { status: string; message: string } => {
|
||||
// Cek apakah hari ini hari libur nasional
|
||||
if (isNationalHoliday(getTodayDate())) {
|
||||
return { status: "Tutup", message: "Hari Libur Nasional" };
|
||||
}
|
||||
|
||||
const workingDays = ["Senin", "Selasa", "Rabu", "Kamis", "Jumat"];
|
||||
if (!workingDays.includes(day)) {
|
||||
return { status: "Tutup", message: "Libur Akhir Pekan" };
|
||||
}
|
||||
const isOpen = isWorkingHours(currentTime);
|
||||
|
||||
const isOpen = isWorkingHours(day, currentTime);
|
||||
|
||||
let workHoursMessage = "";
|
||||
if (["Senin", "Selasa", "Rabu", "Kamis"].includes(day)) {
|
||||
workHoursMessage = "07:30 - 15:10";
|
||||
} else if (day === "Jumat") {
|
||||
workHoursMessage = "07:30 - 12:00";
|
||||
}
|
||||
|
||||
return isOpen
|
||||
? { status: "Buka", message: "08:00 - 17:00" }
|
||||
: { status: "Tutup", message: "08:00 - 17:00" };
|
||||
? { status: "Buka", message: workHoursMessage }
|
||||
: { status: "Tutup", message: workHoursMessage };
|
||||
};
|
||||
|
||||
// 🟦 Skeleton component untuk Social Media
|
||||
|
||||
Reference in New Issue
Block a user