mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-06 21:56:27 +00:00
Move auth config and build admin menus
Extract NextAuth configuration into a shared library, load admin sidebar items from role permissions, and update related RBAC types and UI.
This commit is contained in:
@@ -6,7 +6,7 @@ import fetchData from '@/lib/fetchData';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { type IRole } from '../component/type';
|
||||
import RolePermissionRow from "../component/role-permission-row";
|
||||
import { PencilLine } from 'lucide-react';
|
||||
import { PencilLine, ShieldCheck } from 'lucide-react';
|
||||
|
||||
export const dynamic = 'force-dynamic';
|
||||
|
||||
@@ -179,7 +179,7 @@ const UserRoleDetailPage: FC<Props> = async ({ params }) => {
|
||||
<CardHeader className="pb-3 border-b border-zinc-200 dark:border-zinc-800">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-2">
|
||||
<i className="ti ti-checklist text-lg text-his" />
|
||||
<ShieldCheck className='text-his' />
|
||||
<CardTitle className="text-base font-semibold">
|
||||
Authorized Menu Permissions ({orderedDetails.length} Menus Allowed)
|
||||
</CardTitle>
|
||||
|
||||
@@ -81,9 +81,7 @@ export const RoleForm: FC<Props> = ({ isUpdate, roleId, initialData }) => {
|
||||
|
||||
const rawDetails = Array.isArray(initialData.role_detail)
|
||||
? initialData.role_detail
|
||||
: Array.isArray(initialData.privilege)
|
||||
? initialData.privilege
|
||||
: [];
|
||||
: [];
|
||||
|
||||
rawDetails.forEach((item: any) => {
|
||||
// Support both new API format (item.menu.id) and legacy format (item.menu_id)
|
||||
@@ -421,7 +419,7 @@ export const RoleForm: FC<Props> = ({ isUpdate, roleId, initialData }) => {
|
||||
{/* Bottom Action Bar */}
|
||||
<div className="mt-6 flex justify-end items-center gap-3">
|
||||
<Link href="/admin/rbac/user-role">
|
||||
<Button variant="outline" type="button" disabled={isLoading} className='text-zinc-800! dark:text-white'>
|
||||
<Button variant="outline" type="button" disabled={isLoading} >
|
||||
Cancel
|
||||
</Button>
|
||||
</Link>
|
||||
|
||||
@@ -118,9 +118,7 @@ const ComponentRolePage: FC<Props> = ({ data }) => {
|
||||
render: (details: any, record: IRole) => {
|
||||
const count = Array.isArray(details)
|
||||
? details.length
|
||||
: Array.isArray(record.privilege)
|
||||
? record.privilege.length
|
||||
: 0;
|
||||
: 0;
|
||||
return (
|
||||
<span className="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-zinc-100 dark:bg-zinc-800 text-zinc-700 dark:text-zinc-300">
|
||||
{count} menus
|
||||
|
||||
Reference in New Issue
Block a user