diff --git a/bun.lockb b/bun.lockb index c59dbad6..31228ed1 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index ca12628a..e0f0d6ae 100644 --- a/package.json +++ b/package.json @@ -57,6 +57,8 @@ "form-data": "^4.0.2", "framer-motion": "^12.23.5", "get-port": "^7.1.0", + "iron-session": "^8.0.4", + "jose": "^6.1.0", "jotai": "^2.12.3", "jsonwebtoken": "^9.0.2", "leaflet": "^1.9.4", @@ -64,7 +66,7 @@ "lodash": "^4.17.21", "motion": "^12.4.1", "nanoid": "^5.1.5", - "next": "15.1.6", + "next": "^15.5.2", "next-view-transitions": "^0.3.4", "node-fetch": "^3.3.2", "p-limit": "^6.2.0", diff --git a/prisma/data/user/roles.json b/prisma/data/user/roles.json index 1543ba66..79da3188 100644 --- a/prisma/data/user/roles.json +++ b/prisma/data/user/roles.json @@ -1,7 +1,7 @@ [ { - "id": "role_admin_desa", - "name": "ADMIN_DESA", + "id": "1", + "name": "ADMIN DESA", "description": "Administrator Desa", "permissions": ["manage_users", "manage_content", "view_reports"], "isActive": true, @@ -9,8 +9,8 @@ "updatedAt": "2025-09-01T00:00:00.000Z" }, { - "id": "role_admin_kesehatan", - "name": "ADMIN_KESEHATAN", + "id": "2", + "name": "ADMIN KESEHATAN", "description": "Administrator Bidang Kesehatan", "permissions": ["manage_health_data", "view_reports"], "isActive": true, @@ -18,8 +18,8 @@ "updatedAt": "2025-09-01T00:00:00.000Z" }, { - "id": "role_admin_sekolah", - "name": "ADMIN_SEKOLAH", + "id": "3", + "name": "ADMIN SEKOLAH", "description": "Administrator Sekolah", "permissions": ["manage_school_data", "view_reports"], "isActive": true, diff --git a/prisma/data/user/users.json b/prisma/data/user/users.json index f3852b2b..2f44c667 100644 --- a/prisma/data/user/users.json +++ b/prisma/data/user/users.json @@ -1,32 +1,29 @@ [ { - "id": "user_admin_desa", + "id": "1", "nama": "Admin Desa", - "email": "admin.desa@example.com", - "password": "$2b$10$XFDWYOJFxQ7ZM5bA0N4Z0O8u0eKYv58wLsaR7h6XK9bqWJ1YQJQ9q", - "roleId": "role_admin_desa", + "nomor": "089647037426", + "roleId": "1", "isActive": true, "lastLogin": "2025-08-31T10:00:00.000Z", "createdAt": "2025-09-01T00:00:00.000Z", "updatedAt": "2025-09-01T00:00:00.000Z" }, { - "id": "user_admin_puskesmas", + "id": "2", "nama": "Admin Kesehatan", - "email": "admin.kesehatan@example.com", - "password": "$2b$10$XFDWYOJFxQ7ZM5bA0N4Z0O8u0eKYv58wLsaR7h6XK9bqWJ1YQJQ9q", - "roleId": "role_admin_kesehatan", + "nomor": "082339004198", + "roleId": "2", "isActive": true, "lastLogin": null, "createdAt": "2025-09-01T00:00:00.000Z", "updatedAt": "2025-09-01T00:00:00.000Z" }, { - "id": "user_admin_sekolah", + "id": "3", "nama": "Admin Sekolah", - "email": "admin.sekolah@example.com", - "password": "$2b$10$XFDWYOJFxQ7ZM5bA0N4Z0O8u0eKYv58wLsaR7h6XK9bqWJ1YQJQ9q", - "roleId": "role_admin_sekolah", + "nomor": "085237157222", + "roleId": "3", "isActive": true, "lastLogin": null, "createdAt": "2025-09-01T00:00:00.000Z", diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 9758e55f..3924e33d 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -2103,14 +2103,16 @@ model KategoriBuku { DataPerpustakaan DataPerpustakaan[] } +// ========================================= USER ========================================= // + model User { id String @id @default(cuid()) - nama String - email String @unique - password String? + username String + nomor String @unique role Role @relation(fields: [roleId], references: [id]) - roleId String - instansi String? // Nama instansi (Puskesmas, Sekolah, dll) + roleId String @default("1") + instansi String? + UserSession UserSession? // Nama instansi (Puskesmas, Sekolah, dll) isActive Boolean @default(true) lastLogin DateTime? createdAt DateTime @default(now()) @@ -2132,6 +2134,15 @@ model Role { @@map("roles") } +model KodeOtp { + id String @id @default(cuid()) + isActive Boolean @default(true) + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + nomor String + otp Int +} + // Tabel untuk menyimpan permission model Permission { id String @id @default(cuid()) @@ -2143,6 +2154,17 @@ model Permission { @@map("permissions") } +model UserSession { + id String @id @default(cuid()) + token String + expires DateTime? + active Boolean @default(true) + createdAt DateTime @default(now()) + updatedAt DateTime @default(now()) @updatedAt + User User @relation(fields: [userId], references: [id]) + userId String @unique +} + // ========================================= DATA PENDIDIKAN ========================================= // model DataPendidikan { id String @id @default(cuid()) diff --git a/prisma/seed.ts b/prisma/seed.ts index 0822c90f..52fb6c61 100644 --- a/prisma/seed.ts +++ b/prisma/seed.ts @@ -57,47 +57,60 @@ import users from "./data/user/users.json"; (async () => { // =========== USER & ROLE =========== - for (const r of roles) { - await prisma.role.upsert({ - where: { id: r.id }, - update: { - name: r.name, - description: r.description, - permissions: r.permissions, - isActive: true, - }, - create: { - id: r.id, - name: r.name, - description: r.description, - permissions: r.permissions, - isActive: true, - }, - }); + // In your seed.ts +// =========== ROLES =========== +console.log("🔄 Seeding roles..."); +for (const r of roles) { + await prisma.role.upsert({ + where: { id: r.id }, + update: { + name: r.name, + description: r.description, + permissions: r.permissions, + isActive: r.isActive, + }, + create: { + id: r.id, + name: r.name, + description: r.description, + permissions: r.permissions, + isActive: r.isActive, + }, + }); +} +console.log("✅ Roles seeded"); + +// =========== USERS =========== +console.log("🔄 Seeding users..."); +for (const u of users) { + // First verify the role exists + const roleExists = await prisma.role.findUnique({ + where: { id: u.roleId } + }); + + if (!roleExists) { + console.error(`❌ Role with id ${u.roleId} not found for user ${u.nama}`); + continue; } - console.log("✅ Roles seeded"); - //users - for (const u of users) { - await prisma.user.upsert({ - where: { id: u.id }, - update: { - nama: u.nama, - email: u.email, - password: u.password, - roleId: u.roleId, - isActive: true, - }, - create: { - id: u.id, - nama: u.nama, - email: u.email, - password: u.password, - roleId: u.roleId, - isActive: true, - }, - }); - } - console.log("✅ Users seeded"); + + await prisma.user.upsert({ + where: { id: u.id }, + update: { + username: u.nama, + nomor: u.nomor, + roleId: u.roleId, + isActive: u.isActive, + }, + create: { + id: u.id, + username: u.nama, + nomor: u.nomor, + roleId: u.roleId, + isActive: u.isActive, + }, + }); +} +console.log("✅ Users seeded"); // =========== LANDING PAGE =========== // =========== SUBMENU PROFILE =========== // =========== PROFILE PEJABAT DESA =========== diff --git a/src/app/admin/(dashboard)/user&role/layout.tsx b/src/app/admin/(dashboard)/user&role/layout.tsx index b5c359ef..5e662e33 100644 --- a/src/app/admin/(dashboard)/user&role/layout.tsx +++ b/src/app/admin/(dashboard)/user&role/layout.tsx @@ -1,5 +1,6 @@ /* eslint-disable react-hooks/exhaustive-deps */ 'use client' +import colors from '@/con/colors'; import { Stack, Tabs, TabsList, TabsPanel, TabsTab, Title, Tooltip } from '@mantine/core'; import { IconForms, IconUser } from '@tabler/icons-react'; import { usePathname, useRouter } from 'next/navigation'; @@ -50,6 +51,7 @@ function LayoutTabs({ children }: { children: React.ReactNode }) { User & Role {item.name} - - - - Belum punya akun? - - - - - - - - - ); -} - -export default Page; diff --git a/src/app/darmasaba/registrasi/page.tsx b/src/app/darmasaba/registrasi/page.tsx deleted file mode 100644 index d12b8557..00000000 --- a/src/app/darmasaba/registrasi/page.tsx +++ /dev/null @@ -1,67 +0,0 @@ -import colors from '@/con/colors'; -import { Box, Button, Center, Checkbox, Group, Image, Paper, Stack, Text, TextInput, Title } from '@mantine/core'; -import Link from 'next/link'; -import BackButton from '../(pages)/desa/layanan/_com/BackButto'; - - -function Page() { - return ( - - - - - -
- -
- - - E-Book Desa Darmasaba - - - Silahkan lengkapi data diri anda untuk mengakses e-book desa - - -
- - - - - - Registrasi - - - - - - - - - - - - - - - - - - -
- ); -} - -export default Page; diff --git a/src/lib/router/router_home.ts b/src/lib/router/router_home.ts new file mode 100644 index 00000000..a7fd6148 --- /dev/null +++ b/src/lib/router/router_home.ts @@ -0,0 +1,5 @@ +export const RouterHome = { + main_home: "/admin", + home_user_non_active: "/admin/admin-not-active", + }; + \ No newline at end of file