mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-06 22:16:28 +00:00
Apply RBAC permissions across admin and tasks
Enforce page access and action-level permissions across admin and task views, including exports and record actions. Move user creation to a client component behind server-side permission checks, standardize data fetching, and remove the deprecated user-role route.
This commit is contained in:
@@ -36,12 +36,13 @@ const ClientMilestoneTimeline = dynamic(
|
||||
);
|
||||
|
||||
interface ClientGridProps {
|
||||
actions: string[]
|
||||
clients: IClient[];
|
||||
onEdit: (client: IClient) => void;
|
||||
onDelete: (client: IClient) => void;
|
||||
}
|
||||
|
||||
export default function ClientGrid({ clients, onEdit, onDelete }: ClientGridProps) {
|
||||
export default function ClientGrid({ clients, actions, onEdit, onDelete }: ClientGridProps) {
|
||||
return (
|
||||
<div className="grid gap-6 md:grid-cols-2 lg:grid-cols-3">
|
||||
{clients.map((client, i) => {
|
||||
@@ -245,33 +246,24 @@ export default function ClientGrid({ clients, onEdit, onDelete }: ClientGridProp
|
||||
</div>
|
||||
|
||||
<div className='flex items-center gap-1.5'>
|
||||
<Link href={`/task/client-detail/${client.id}`}>
|
||||
<Button
|
||||
variant='default'
|
||||
size="sm"
|
||||
className="text-xs h-7.5 px-2.5 gap-1 hover:bg-accent"
|
||||
>
|
||||
<span>Detail</span>
|
||||
<ExternalLink className="w-3 h-3" />
|
||||
{actions?.includes('VIEW_CLIENT') &&
|
||||
<Link href={`/task/client-detail/${client.id}`}>
|
||||
<Button variant='default' size="sm" className="text-xs h-7.5 px-2.5 gap-1 hover:bg-accent">
|
||||
<span>Detail</span>
|
||||
<ExternalLink className="w-3 h-3" />
|
||||
</Button>
|
||||
</Link>
|
||||
}
|
||||
{actions?.includes('UPDATE_CLIENT') &&
|
||||
<Button onClick={() => onEdit(client)} title='Update Client' size='icon-sm' variant='outline' className='text-teal-500'>
|
||||
<PencilLine />
|
||||
</Button>
|
||||
</Link>
|
||||
<Button onClick={() => onEdit(client)}
|
||||
title='Update Client'
|
||||
size='icon-sm'
|
||||
variant='outline'
|
||||
className='text-teal-500'
|
||||
>
|
||||
<PencilLine />
|
||||
</Button>
|
||||
|
||||
<Button onClick={() => onDelete(client)}
|
||||
title='Delete Client'
|
||||
size='icon-sm'
|
||||
variant='outline'
|
||||
className='text-rose-500'
|
||||
>
|
||||
<Trash />
|
||||
</Button>
|
||||
}
|
||||
{actions?.includes('DELETE_CLIENT') &&
|
||||
<Button onClick={() => onDelete(client)} title='Delete Client' size='icon-sm' variant='outline' className='text-rose-500'>
|
||||
<Trash />
|
||||
</Button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</Card900>
|
||||
|
||||
Reference in New Issue
Block a user