From 358ff14efe767ba21a6bfb9c0537872a6ecf7205 Mon Sep 17 00:00:00 2001 From: nico Date: Tue, 3 Feb 2026 16:53:15 +0800 Subject: [PATCH] Seeder Menu Lingkungan dan Pendidikan Fix Jam Operasional Kantor Desa Darmasaba --- QWEN.md | 219 ------- bun.lockb | Bin 427009 -> 427025 bytes .../_seeder_list/inovasi/seed_desa_digital.ts | 21 +- .../inovasi/seed_layanan_online_desa.ts | 21 +- .../lingkungan/seed_data_gotong_royong.ts | 71 +++ .../lingkungan/seed_data_lingkungan_desa.ts | 27 + .../lingkungan/seed_edukasi_lingkungan.ts | 63 ++ .../lingkungan/seed_konservasi_adat_bali.ts | 63 ++ .../lingkungan/seed_pengelolaan_sampah.ts | 51 ++ .../lingkungan/seed_program_penghijauan.ts | 27 + .../pendidikan/seed_bimbingan_belajar.ts | 60 ++ .../pendidikan/seed_data_pendidikan.ts | 23 + .../pendidikan/seed_data_perpustakaan.ts | 62 ++ .../seed_info_program_pendidikan.ts | 36 ++ .../pendidikan/seed_info_sekolah.ts | 74 +++ .../pendidikan/seed_pendidikan_non_formal.ts | 60 ++ .../inovasi/desa-digital/desa-digital.json | 10 +- .../pengaduan-masyarakat.json | 6 +- .../gotong-royong/gotong-royong.json | 6 +- .../perpustakaan-digital.json | 40 +- prisma/schema.prisma | 16 +- prisma/seed.ts | 567 +----------------- prisma/seed_assets.ts | 38 +- .../desa-digital-smart-village/page.tsx | 2 +- .../lingkungan/gotong-royong/semua/page.tsx | 17 +- .../[kategoriBuku]/[id]/page.tsx | 8 +- .../perpustakaan-digital/semua/content.tsx | 8 +- .../_com/main-page/landing-page/index.tsx | 84 ++- 28 files changed, 847 insertions(+), 833 deletions(-) create mode 100644 prisma/_seeder_list/lingkungan/seed_data_gotong_royong.ts create mode 100644 prisma/_seeder_list/lingkungan/seed_data_lingkungan_desa.ts create mode 100644 prisma/_seeder_list/lingkungan/seed_edukasi_lingkungan.ts create mode 100644 prisma/_seeder_list/lingkungan/seed_konservasi_adat_bali.ts create mode 100644 prisma/_seeder_list/lingkungan/seed_pengelolaan_sampah.ts create mode 100644 prisma/_seeder_list/lingkungan/seed_program_penghijauan.ts create mode 100644 prisma/_seeder_list/pendidikan/seed_bimbingan_belajar.ts create mode 100644 prisma/_seeder_list/pendidikan/seed_data_pendidikan.ts create mode 100644 prisma/_seeder_list/pendidikan/seed_data_perpustakaan.ts create mode 100644 prisma/_seeder_list/pendidikan/seed_info_program_pendidikan.ts create mode 100644 prisma/_seeder_list/pendidikan/seed_info_sekolah.ts create mode 100644 prisma/_seeder_list/pendidikan/seed_pendidikan_non_formal.ts diff --git a/QWEN.md b/QWEN.md index 75423026..e69de29b 100644 --- a/QWEN.md +++ b/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 \ No newline at end of file diff --git a/bun.lockb b/bun.lockb index afa73367054fd4c567f7f3ee08d6856f71413675..68d46c85bf283a2e9e48c587044216c81b1b8ca5 100755 GIT binary patch delta 353 zcmZqdkeb*bHNlUuvC+TPpRv`Ssnwr(t3L~`I7bHq0|Pq{Z%+|t`NPP<&&a?qJw=jb z1`9}Hn-oh2qXI};2Z+xB@mU}i0OJ2Z0280SLYl<`ZqW1}(kwC@FuCnAGAuldERsND zx9iBV_;7M00d<3IX;5P+ae!I>1gHRHE{u=Peh!p}$vs0-yWK>c4H0PvYnnE(I) delta 344 zcmbQ(A=TI+HNlUuu+hKOpRv`Ssnwr(t3L~`ILCh|*q$QJ@`sTH#G9TX$ua}X+9t)) z!KeUJa*lz4;Vcjf05MDqtbTP-X zC4d;DZhMM8O8^tZgdK(~GZ-acx}}&I7!rUu9*99=?HR@_K+L*5!Aplikasi digital desa yang dikembangkan oleh Pemerintah Desa Darmasaba pada tahun 2024 untuk mempermudah pelayanan publik dan informasi pemerintahan berbasis digital.

", - "imageId": "cmkksb3jr0005vni4sp3ogr87" + "imageName": "r_gBF0FuFpFPfSENHc4XI-mobile.webp" }, { "id": "cmkkshln8000604l8c9b5b4il", "name": "D’DAMART (Darmasaba Digital Market)", "deskripsi": "

Sistem pasar UMKM digital berbasis website yang dikembangkan untuk meningkatkan akses pasar dan pemasaran produk UMKM Desa Darmasaba melalui platform digital.

", - "imageId": "cmkksoze80008vni4ki2ry81r" + "imageName": "uE2QwpbcXyBWxVYqCWQQT-mobile.webp" }, { "id": "cmkm1a1g80007vnsw8ejmj816", "name": "Media Aspirasi dan Pengaduan Warga", "deskripsi": "

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.

", - "imageId": "cmkm1a14d0005vnsww1tsd92o" + "imageName": "c7xWNyoYp8Cak28NG5NoG-mobile.webp" }, { "id": "cmkm0w0s50003vnswmwpnqsi5", "name": "Website Desa Resmi", "deskripsi": "

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.

", - "imageId": "cmkm0z9hx0004vnswtjd2bk3z" + "imageName": "kN09yF3sahmy-d5EaeGqA-mobile.webp" }, { "id": "cmkm1c8wx000avnswksc56orq", "name": "Publikasi Kegiatan Desa Secara Digital", "deskripsi": "

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.

", - "imageId": "cmkm1c8py0008vnsw0unbxkpq" + "imageName": "h_Gd0SoeIJVTi_5TWUO-P-mobile.webp" } ] diff --git a/prisma/data/inovasi/layanan-online-desa/pengaduan-masyarakat.json b/prisma/data/inovasi/layanan-online-desa/pengaduan-masyarakat.json index 057a2ad4..7c915a85 100644 --- a/prisma/data/inovasi/layanan-online-desa/pengaduan-masyarakat.json +++ b/prisma/data/inovasi/layanan-online-desa/pengaduan-masyarakat.json @@ -9,7 +9,7 @@ "deskripsiPengaduan": "

Permintaan Pemasangan Spanduk Larangan Bagi Hewan

", "lokasiKejadian": "Banjar Darmasaba Tengah", "jenisPengaduanId": "eommt91ma000004lb4dpq7ll1", - "imageId": "cmkkxep9l000evni4xkegbk72" + "imageName": "gyNi4s8TnK2UrViU-gN2C-mobile.webp" }, { "id": "cmkkrxmub0004vni41cwyhid5", @@ -21,7 +21,7 @@ "deskripsiPengaduan": "

Laporan Anjing Liar Sering Menyerang Warga

", "lokasiKejadian": "Jl. Raya Darmasaba", "jenisPengaduanId": "eommt91ma000004lb4dpq8mm2", - "imageId": "cmkkx9e38000bvni4azjd3u53" + "imageName": "SQqSobKRg3ShvgPw_H41h-mobile.webp" }, { "id": "cmkkrxmub0004vni41cwyhid6", @@ -33,6 +33,6 @@ "deskripsiPengaduan": "

Pengelolaan Sampah Rumah Tangga Belum Efektif

", "lokasiKejadian": "Banjar Bucu", "jenisPengaduanId": "eommt91ma000004lb4dpq7ll1", - "imageId": "cmkky60sq0000vnjjc55k84d2" + "imageName": "y78xZ2axTOjz87gRKjVAf-mobile.webp" } ] diff --git a/prisma/data/lingkungan/gotong-royong/gotong-royong.json b/prisma/data/lingkungan/gotong-royong/gotong-royong.json index 8bb48ee3..b03662dc 100644 --- a/prisma/data/lingkungan/gotong-royong/gotong-royong.json +++ b/prisma/data/lingkungan/gotong-royong/gotong-royong.json @@ -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" } ] diff --git a/prisma/data/pendidikan/perpustakaan-digital/perpustakaan-digital.json b/prisma/data/pendidikan/perpustakaan-digital/perpustakaan-digital.json index ff9757df..b49b5298 100644 --- a/prisma/data/pendidikan/perpustakaan-digital/perpustakaan-digital.json +++ b/prisma/data/pendidikan/perpustakaan-digital/perpustakaan-digital.json @@ -4,139 +4,139 @@ "judul": "Laskar Pelangi", "deskripsi": "

Novel inspiratif tentang perjuangan anak-anak di Belitung dalam meraih pendidikan dan mimpi mereka

", "kategoriId": "cmkqb11mc000104jibq76bdzu", - "imageId": "cmkqhbhxi0000vneamj3din9u" + "imageName": "RnAdv7O0QAFrxkFLAXJSa-mobile.webp" }, { "id": "cmkqhedff0005vneas3rtbumi", "judul": "Bumi Manusia", "deskripsi": "

Kisah kehidupan Minke di masa kolonial yang menggambarkan perjuangan, pendidikan, dan identitas bangsa

", "kategoriId": "cmkqb11mc000104jibqc7bdzu", - "imageId": "cmkqhed8x0003vneakx0c7me2" + "imageName": "71eZShq4FYAFLxpLfZB0W-mobile.webp" }, { "id": "cmkqhg1g70008vneajbpz8phh", "judul": "Atomic Habits", "deskripsi": "

Panduan membangun kebiasaan kecil yang konsisten untuk menghasilkan perubahan besar dalam hidup

", "kategoriId": "cmkqb11mc000104jibqf7bdzu", - "imageId": "cmkqhg1cb0006vneagsxa6t4t" + "imageName": "Uxq3GXPqh7HN9fHmRkr3r-mobile.webp" }, { "id": "cmkqhl6sr000bvneampx0svus", "judul": "Clean Code", "deskripsi": "

Buku wajib programmer tentang cara menulis kode yang bersih, mudah dibaca, dan mudah dirawat

", "kategoriId": "cmkqb11mc000104jibqd7bdzu", - "imageId": "cmkqhl6mv0009vneasgix42ud" + "imageName": "W5Fc0uRADNkIY3nZicvQA-mobile.webp" }, { "id": "cmkqhoaa1000evnearppgpyxo", "judul": "Sejarah Indonesia Modern", "deskripsi": "

Membahas perjalanan sejarah Indonesia dari masa kolonial hingga era modern

", "kategoriId": "cmkqb11mc000104jibqc7bdzu", - "imageId": "cmkqhoa5w000cvneah15n28zq" + "imageName": "mp77Op-MwtPQZnH3so4JY-mobile.webp" }, { "id": "cmkqhr9oc000hvnea677ad3kb", "judul": "Ensiklopedia Anak Pintar", "deskripsi": "

Buku referensi bergambar yang membantu anak mengenal ilmu pengetahuan secara menyenangkan

", "kategoriId": "cmkqb11mc000104jibqh7bdzu", - "imageId": "cmkqhr9lg000fvneai3q8qw0s" + "imageName": "V09ZxN1wOwbSFLQiDK0VQ-mobile.webp" }, { "id": "cmkqi5ksf000kvnea9c04n2hy", "judul": "Filosofi Teras", "deskripsi": "

Pengenalan filsafat Stoikisme untuk menghadapi kehidupan modern dengan lebih tenang

", "kategoriId": "cmkqb11mc000104jibq87bdzu", - "imageId": "cmkqi5knc000ivnea8grp7j06" + "imageName": "Wqp4AyVkGjqRMED9Q5XAs-mobile.webp" }, { "id": "cmkqi97hq000nvneaparjbcrm", "judul": "Pemrograman JavaScript Dasar", "deskripsi": "

Panduan dasar belajar JavaScript untuk pemula dalam dunia pengembangan web

", "kategoriId": "cmkqb11mc000104jibqd7bdzu", - "imageId": "cmkqi9799000lvneamskmvpq5" + "imageName": "NH4aLc7cVuutdQBCofTC0-mobile.webp" }, { "id": "cmkqibjt9000qvnea13ox7fmv", "judul": "Pendidikan Karakter", "deskripsi": "

Buku yang membahas pentingnya pendidikan karakter dalam membentuk generasi bangsa

", "kategoriId": "cmkqb11mc000104jibqf7bdzu", - "imageId": "cmkqibjj2000ovnea3zmmvdop" + "imageName": "MLrsPrD6oiHsrNP4Lc8J7-mobile.webp" }, { "id": "cmkqidnar000tvneaohk5v8k6", "judul": "Psikologi Kepribadian", "deskripsi": "

Mengenal teori-teori kepribadian manusia dalam perspektif psikologi

", "kategoriId": "cmkqb11mc000104jibq87bdzu", - "imageId": "cmkqidn7e000rvnea5rl58f2e" + "imageName": "iaIeNdhuxqltqKP7aZncQ-mobile.webp" }, { "id": "cmkqifdiu000wvnea7xd0yi4f", "judul": "Ayat-Ayat Cinta", "deskripsi": "

Novel religi yang mengangkat kisah cinta, iman, dan perjuangan hidup

", "kategoriId": "cmkqb11mc000104jibqe7bdzu", - "imageId": "cmkqifdfs000uvneajss8zswp" + "imageName": "WUDssJ59pTKE_3IuTiZ2s-mobile.webp" }, { "id": "cmkqik7vi000zvneae7d5cq9i", "judul": "Negeri 5 Menara", "deskripsi": "

Cerita persahabatan dan perjuangan santri dalam mengejar mimpi hingga ke mancanegara

", "kategoriId": "cmkqb11mc000104jibq76bdzu", - "imageId": "cmkqik7p5000xvnea6krii3vw" + "imageName": "RJH_-4_R_nlP7GVEQeD1M-mobile.webp" }, { "id": "cmkqinno30012vneac1sgsvis", "judul": "Belajar UI/UX Design", "deskripsi": "

Panduan praktis memahami desain antarmuka dan pengalaman pengguna

", "kategoriId": "cmkqb11mc000104jibqd7bdzu", - "imageId": "cmkqinnih0010vneakpjb9egl" + "imageName": "9MA-Jx_36uoho2Tg40_G9-mobile.webp" }, { "id": "cmkqiqegd0015vneawv5u5tpm", "judul": "Manajemen Waktu Efektif", "deskripsi": "

Teknik mengatur waktu agar lebih produktif dan fokus pada hal penting

", "kategoriId": "cmkqb11mc000104jibqf7bdzu", - "imageId": "cmkqiqeb60013vnea2ygrq5rs" + "imageName": "dkb7ZWFl28TREVcvH8sWd-mobile.webp" }, { "id": "cmkqiurc60018vneavyd3pj9q", "judul": "Dongeng Nusantara", "deskripsi": "

Kumpulan dongeng tradisional Indonesia yang sarat pesan moral

", "kategoriId": "cmkqb11mc000104jibq76bdzu", - "imageId": "cmkqiur960016vnea3werdoey" + "imageName": "nVj3one6CLuWRd04QnsWo-mobile.webp" }, { "id": "cmkqix2kb001bvnea5v81cw7p", "judul": "Ekonomi Makro", "deskripsi": "

Pembahasan konsep ekonomi makro secara sistematis dan mudah dipahami

", "kategoriId": "cmkqb11mc000104jibq87bdzu", - "imageId": "cmkqix2go0019vnea8coousvn" + "imageName": "AnB7JO4_6tlPTX3ypOVLi-mobile.webp" }, { "id": "cmkqiyts2001evneahnk45ry5", "judul": "Seni Berpikir Kritis", "deskripsi": "

Buku yang membantu pembaca menghindari kesalahan berpikir dalam pengambilan keputusan

", "kategoriId": "cmkqb11mc000104jibq87bdzu", - "imageId": "cmkqiytnv001cvnea7o2sv1vt" + "imageName": "sAyoMERxL6JgFfiO22KPb-mobile.webp" }, { "id": "cmkqj0nq0001hvnea06r8m3kj", "judul": "Seni Berpikir Kritis", "deskripsi": "

Buku yang membantu pembaca menghindari kesalahan berpikir dalam pengambilan keputusan

", "kategoriId": "cmkqb11mc000104jibq87bdzu", - "imageId": "cmkqj0nn0001fvneaufur3nke" + "imageName": "WeA-JP2Ks_32fv1k529vj-mobile.webp" }, { "id": "cmkqj37w4001kvnea04n9w2bx", "judul": "Panduan Shalat Lengkap", "deskripsi": "

Panduan praktis dan lengkap tentang tata cara shalat sesuai tuntunan

", "kategoriId": "cmkqb11mc000104jibqe7bdzu", - "imageId": "cmkqj37rg001ivneam29fgayr" + "imageName": "pxlHu2kDmIprQqC2PuXaL-mobile.webp" }, { "id": "cmkqj5qp6001nvnea4xhvluz3", "judul": "Cerita Sains untuk Anak", "deskripsi": "

Cerita edukatif yang mengenalkan sains kepada anak dengan bahasa sederhana

", "kategoriId": "cmkqb11mc000104jibqh7bdzu", - "imageId": "cmkqj5ql6001lvnea6p0afr9f" + "imageName": "G0iELZb2DhQDCCP5OdzJR-desktop.webp" } ] diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 160857b3..ac06a3a0 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -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()) diff --git a/prisma/seed.ts b/prisma/seed.ts index 973c76e6..4b36eebe 100644 --- a/prisma/seed.ts +++ b/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) => { diff --git a/prisma/seed_assets.ts b/prisma/seed_assets.ts index 8a93a59c..3b51b2d0 100644 --- a/prisma/seed_assets.ts +++ b/prisma/seed_assets.ts @@ -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)); } } diff --git a/src/app/darmasaba/(pages)/inovasi/desa-digital-smart-village/page.tsx b/src/app/darmasaba/(pages)/inovasi/desa-digital-smart-village/page.tsx index 4fd1380f..d5ff3418 100644 --- a/src/app/darmasaba/(pages)/inovasi/desa-digital-smart-village/page.tsx +++ b/src/app/darmasaba/(pages)/inovasi/desa-digital-smart-village/page.tsx @@ -99,7 +99,7 @@ function Page() { }} > {v.name} ( - {item.judul} + + {item.judul} + diff --git a/src/app/darmasaba/(pages)/pendidikan/perpustakaan-digital/[kategoriBuku]/[id]/page.tsx b/src/app/darmasaba/(pages)/pendidikan/perpustakaan-digital/[kategoriBuku]/[id]/page.tsx index 319f0d64..2ec30c9d 100644 --- a/src/app/darmasaba/(pages)/pendidikan/perpustakaan-digital/[kategoriBuku]/[id]/page.tsx +++ b/src/app/darmasaba/(pages)/pendidikan/perpustakaan-digital/[kategoriBuku]/[id]/page.tsx @@ -119,7 +119,13 @@ export default function DetailBukuUser() { 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, + }} /> ); diff --git a/src/app/darmasaba/(pages)/pendidikan/perpustakaan-digital/semua/content.tsx b/src/app/darmasaba/(pages)/pendidikan/perpustakaan-digital/semua/content.tsx index 639bbed0..02c00df7 100644 --- a/src/app/darmasaba/(pages)/pendidikan/perpustakaan-digital/semua/content.tsx +++ b/src/app/darmasaba/(pages)/pendidikan/perpustakaan-digital/semua/content.tsx @@ -223,7 +223,13 @@ export default function Content() { fullWidth leftSection={} 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); }} > diff --git a/src/app/darmasaba/_com/main-page/landing-page/index.tsx b/src/app/darmasaba/_com/main-page/landing-page/index.tsx index 8164dbc8..63655d68 100644 --- a/src/app/darmasaba/_com/main-page/landing-page/index.tsx +++ b/src/app/darmasaba/_com/main-page/landing-page/index.tsx @@ -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