diff --git a/app/admin/components/Breadcrumb.tsx b/app/admin/components/Breadcrumb.tsx index f05f43a..87cd719 100644 --- a/app/admin/components/Breadcrumb.tsx +++ b/app/admin/components/Breadcrumb.tsx @@ -16,6 +16,7 @@ const SEGMENT_LABELS: Record = { 'user': 'User', 'division': 'Division', 'area': 'Area', + 'forbidden': 'Access Restricted', }; export default function AdminBreadcrumb() { diff --git a/app/admin/components/Sidebar.tsx b/app/admin/components/Sidebar.tsx index 7fd886b..77fb04b 100644 --- a/app/admin/components/Sidebar.tsx +++ b/app/admin/components/Sidebar.tsx @@ -3,7 +3,7 @@ import dynamic from 'next/dynamic'; import { FC, FormEvent, useEffect, useRef, useState } from 'react'; import { ArrowBigLeft } from 'lucide-react' -import SIDEBAR_MENU from '@/lib/data-sidebar'; +// import SIDEBAR_MENU from '@/lib/data-sidebar'; import { Input } from '@/components/ui/input'; import { Button } from '@/components/ui/button'; import { ISideMenu } from './SidebarItem'; @@ -12,10 +12,11 @@ import Notification from './Notification'; import Link from 'next/link'; import { useRouter } from 'next/navigation'; import { UserNav } from '@/app/(dashboard)/components/UserNav'; +import { Skeleton } from '@/components/ui/skeleton'; const SidebarItem = dynamic(() => import("./SidebarItem"), { - loading: () =>

loading...

, + loading: () => , ssr: false }) diff --git a/app/admin/components/SidebarItem.tsx b/app/admin/components/SidebarItem.tsx index 866af7d..132f50e 100644 --- a/app/admin/components/SidebarItem.tsx +++ b/app/admin/components/SidebarItem.tsx @@ -43,9 +43,7 @@ const SidebarItem: FC = ({ menu, expand, onChangeExpand }) => { const getActiveBackgroundMenu = () => { const currentPath = pathanme || ''; const fullPath = '/admin' + (menu.path || ''); - const isActive = menu.path === '' - ? currentPath === '/admin' || currentPath === '/admin/' - : currentPath === fullPath || (menu.path && currentPath.startsWith(fullPath + '/')); + const isActive = menu.path === '' ? currentPath === '/admin' || currentPath === '/admin/' : currentPath === fullPath || (menu.path && currentPath.startsWith(fullPath + '/')); if (isActive) { return { diff --git a/app/admin/forbidden.tsx b/app/admin/forbidden.tsx new file mode 100644 index 0000000..c719c30 --- /dev/null +++ b/app/admin/forbidden.tsx @@ -0,0 +1,2 @@ +export { default, metadata } from './forbidden/page'; + diff --git a/app/admin/forbidden/page.tsx b/app/admin/forbidden/page.tsx new file mode 100644 index 0000000..ec7ee60 --- /dev/null +++ b/app/admin/forbidden/page.tsx @@ -0,0 +1,100 @@ +import { Metadata } from 'next'; +import Link from 'next/link'; +import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '@/components/ui/card'; +import { Button } from '@/components/ui/button'; +import { LayoutDashboard, Home, ShieldAlert, KeyRound, ArrowLeft } from 'lucide-react'; + +export const metadata: Metadata = { + title: 'Access Restricted | Admin', + description: 'You do not have permission to access this administrative page.', +}; + +export default function AdminForbiddenPage() { + return ( +
+ + + {/* Security Icon Badge */} +
+ +
+ +
+
+ + Access Restricted + + + HTTP 403 + +
+ + Your account does not have sufficient role permissions to view or manage this administrative resource. + +
+
+ + + {/* Explanation Box */} +
+
+ + Why am I seeing this page? +
+ +

+ Access to this section is protected by Role-Based Access Control (RBAC). Your assigned user role has not been granted the necessary permissions for this menu action or route. +

+ +
+
+ + Policy: Role Permission Required +
+
+ Area: Admin Panel +
+
+
+ + {/* How to Resolve */} +
+

+ Need access to this resource? +

+

+ Please contact HATs system administrator, Manager or Team Leader to request the relevant permission assignment for your account role. +

+
+ + {/* Action Buttons */} +
+
+ + + + + + + +
+ + + + +
+
+
+
+ ); +} + diff --git a/app/admin/layout.tsx b/app/admin/layout.tsx index 6d22ba6..8fd7bea 100644 --- a/app/admin/layout.tsx +++ b/app/admin/layout.tsx @@ -67,18 +67,20 @@ export default async function AdminLayout({ children }: { children: React.ReactN children.sort(sortByOrder) return { title: parent.menu?.name!, - Icon: , + Icon: parent.menu?.icon ? : undefined, + path: cleanPath(parent.menu?.path_url!), submenuId: parent.menu?.id, submenuItems: children.map((child) => ({ title: child.menu?.name, path: cleanPath(child.menu?.path_url!), + Icon: child.menu?.icon ? : undefined, })), } } return { title: parent.menu?.name!, - Icon: , + Icon: parent.menu?.icon ? : undefined, path: cleanPath(parent.menu?.path_url!), } }) diff --git a/app/admin/loading.tsx b/app/admin/loading.tsx index 5687c83..cc3e4bd 100644 --- a/app/admin/loading.tsx +++ b/app/admin/loading.tsx @@ -1,19 +1,93 @@ -import SkeletonTable from "@/components/skeleton/SkeletonTable" -import { Skeleton } from "@/components/ui/skeleton" +import { FC } from 'react'; +import { Card, CardContent, CardHeader } from '@/components/ui/card'; -export default function Loading() { +export default function AdminLoading() { return ( -
-
-
+
+ + {/* Header Skeleton */} +
- - + {/* Title skeleton */} +
+ {/* Description skeleton */} +
- -
- -
+ + {/* Action button skeleton */} +
+ + + + {/* Search & Filter Toolbar Skeleton */} +
+
+
+
+
+
+ + {/* Table Skeleton */} +
+ {/* Table Header Row */} +
+
+
+
+
+
+
+ + {/* Table Body Rows */} +
+ {[1, 2, 3, 4, 5, 6].map((i) => ( +
+ {/* Num / Index */} +
+ + {/* Primary title + subtitle */} +
+
+
+
+ + {/* Badge / Type */} +
+
+
+ + {/* Secondary detail / Description */} +
+
+
+ + {/* Action button */} +
+
+ ))} +
+
+ + {/* Pagination Footer Skeleton */} +
+
+
+
+
+
+
+
+ +
- ) -} \ No newline at end of file + ); +} diff --git a/app/error.tsx b/app/error.tsx index 00fd36c..ed98ad0 100644 --- a/app/error.tsx +++ b/app/error.tsx @@ -1,37 +1,160 @@ -'use client' +'use client'; -import { useEffect } from "react" -import Image from "next/image" -import Link from "next/link" -import { Button } from "@/components/ui/button" -import { clientLogger } from "@/lib/logger-client" +import { useEffect, useState } from 'react'; +import Link from 'next/link'; +import { motion } from 'framer-motion'; +import { Button } from '@/components/ui/button'; +import { clientLogger } from '@/lib/logger-client'; +import { RotateCcw, Home, LayoutDashboard, Copy, Check, ChevronDown, ChevronUp, ArrowLeft, AlertTriangle } from 'lucide-react'; -export default function Error({ - error, - reset, -}: { - error: Error - reset: () => void -}) { +interface ErrorProps { + error: Error & { digest?: string }; + reset: () => void; +} + +export default function RootError({ error, reset }: ErrorProps) { + const [showStack, setShowStack] = useState(false); + const [copied, setCopied] = useState(false); useEffect(() => { - console.log({ name: error.name, cause: error.cause, message: error.message, stack: error.stack }) - clientLogger.error(error.stack!) - }, [error]) + console.error('Root Application Error Boundary caught:', error); + if (error.stack) { + clientLogger.error(error.stack); + } + }, [error]); + + const handleCopyDigest = async () => { + if (!error.digest) return; + try { + await navigator.clipboard.writeText(error.digest); + setCopied(true); + setTimeout(() => setCopied(false), 2000); + } catch { + // ignore clipboard errors + } + }; return ( - <> -
- ilustrations -

Oopps.. something went wrong!

- {error.message || 'Sorry, system error has occurred'} -
- - - - +
+ + {/* Elevated Error Card */} +
+ {/* Header with Crafted Warning Beacon */} +
+
+ + + + + 500 + +
+ +
+
+

+ Unexpected Application Error +

+
+

+ We encountered an issue while processing your request. The system has automatically recorded the incident. +

+
+
+ + {/* Error Summary Box */} +
+
+ + Error Summary + + {error.digest && ( + + )} +
+ +

+ {error.message || 'An unexpected runtime error occurred.'} +

+
+ + {/* Developer Stack Trace Accordion */} + {error.stack && ( +
+ + {showStack && ( +
+
{error.stack}
+
+ )} +
+ )} + + {/* Primary & Secondary Action Controls */} +
+
+ + + + + + + +
+ + + + +
-
- - ) -} \ No newline at end of file + + {/* Footer Brand Note */} +

+ H.A.T.s • HIS Attendance Task System +

+ +
+ ); +} diff --git a/app/forbidden.tsx b/app/forbidden.tsx new file mode 100644 index 0000000..c719c30 --- /dev/null +++ b/app/forbidden.tsx @@ -0,0 +1,2 @@ +export { default, metadata } from './forbidden/page'; + diff --git a/app/forbidden/page.tsx b/app/forbidden/page.tsx new file mode 100644 index 0000000..6948a71 --- /dev/null +++ b/app/forbidden/page.tsx @@ -0,0 +1,75 @@ +import { Metadata } from 'next'; +import Link from 'next/link'; +import { Button } from '@/components/ui/button'; +import { Home, LayoutDashboard, ArrowLeft, ShieldX, Lock } from 'lucide-react'; + +export const metadata: Metadata = { + title: '403 Forbidden | H.A.T.s', + description: 'You do not have permission to access this page.', +}; + +export default function ForbiddenPage() { + return ( +
+
+ {/* Security Emblem */} +
+
+ +
+ + 403 + +
+ + {/* Status & Title */} +

+ Access Restricted +

+

+ You do not have permission to view or manage this resource. This may be due to role restrictions or an unassigned permission set. +

+ + {/* Info Card */} +
+
+ + Permission Required +
+

+ If you need access to this feature, please contact HATs system administrator, Manager or Team Leader to request role privileges. +

+
+ + {/* Actions */} +
+ + + + + + + +
+ + {/* Switch Account Option */} +
+ + + Sign in with a different account + +
+
+
+ ); +} + diff --git a/next.config.ts b/next.config.ts index 5dcf0f0..5ee0e26 100644 --- a/next.config.ts +++ b/next.config.ts @@ -1,30 +1,33 @@ import type { NextConfig } from "next"; const nextConfig: NextConfig = { - /* config options here */ - basePath: process.env.BASE_PATH ?? '', - env: { - 'BASE_PATH': process.env.BASE_PATH ?? '', - 'BASE_URL_API': process.env.BASE_URL_API, - 'BASE_URL_IMG': process.env.BASE_URL_IMG, - 'FIREBASE_API_KEY': process.env.FIREBASE_API_KEY, - 'FIREBASE_APP_ID': process.env.FIREBASE_APP_ID, - 'DEVICE_CODE': process.env.DEVICE_CODE, - }, - images: { - // unoptimized: true, // <--- ADD THIS LINE - remotePatterns: [ - new URL('https://36.66.3.44/**'), - new URL('https://his.nutech-integrasi.com/**'), - new URL('https://hats.hisnutech.my.id/**'), - new URL('https://api-hats.hisnutech.my.id/**'), - { protocol: 'https', hostname: 'avatars.githubusercontent.com', pathname: '/u/**/*' }, - { protocol: 'https', hostname: 'lh3.googleusercontent.com', pathname: '/a/**/*' } - ], - qualities: [50, 65, 70, 75, 80, 85, 90, 100], - }, - reactCompiler: true, - reactStrictMode: false + /* config options here */ + basePath: process.env.BASE_PATH ?? '', + env: { + 'BASE_PATH': process.env.BASE_PATH ?? '', + 'BASE_URL_API': process.env.BASE_URL_API, + 'BASE_URL_IMG': process.env.BASE_URL_IMG, + 'FIREBASE_API_KEY': process.env.FIREBASE_API_KEY, + 'FIREBASE_APP_ID': process.env.FIREBASE_APP_ID, + 'DEVICE_CODE': process.env.DEVICE_CODE, + }, + images: { + // unoptimized: true, // <--- ADD THIS LINE + remotePatterns: [ + new URL('https://36.66.3.44/**'), + new URL('https://his.nutech-integrasi.com/**'), + new URL('https://hats.hisnutech.my.id/**'), + new URL('https://api-hats.hisnutech.my.id/**'), + { protocol: 'https', hostname: 'avatars.githubusercontent.com', pathname: '/u/**/*' }, + { protocol: 'https', hostname: 'lh3.googleusercontent.com', pathname: '/a/**/*' } + ], + qualities: [50, 65, 70, 75, 80, 85, 90, 100], + }, + reactCompiler: true, + reactStrictMode: false, + experimental: { + authInterrupts: true, // for forbidden page + }, }; export default nextConfig;