Files
Alberto-Audrix 32a36cceff
CI / lint-and-test (push) Canceled after 0s
first commit
2026-07-28 08:55:05 +07:00

52 lines
1.9 KiB
TypeScript

import React, { useState } from 'react';
import { useAppContext } from '../../context/AppContext';
import PermissionManager from './PermissionManager';
const RoleTab: React.FC = () => {
const { roles } = useAppContext();
const [selectedRoleId, setSelectedRoleId] = useState<string | null>(roles[0]?.id || null);
return (
<div className="grid grid-cols-1 lg:grid-cols-3 gap-6">
<div className="lg:col-span-1 bg-white p-4 rounded-xl shadow-sm border">
<h2 className="text-xl font-bold text-gray-800 mb-4 px-2">Daftar Peran</h2>
<ul className="space-y-1">
{roles.map((role) => (
<li key={role.id}>
<button
onClick={() => setSelectedRoleId(role.id)}
className={`w-full text-left p-3 rounded-lg transition-colors ${
selectedRoleId === role.id
? 'bg-red-100 text-red-800'
: 'hover:bg-gray-100 text-gray-700'
}`}
>
<p className="font-semibold">{role.name}</p>
<p
className={`text-xs ${selectedRoleId === role.id ? 'text-red-700' : 'text-gray-500'}`}
>
{role.description}
</p>
</button>
</li>
))}
</ul>
</div>
<div className="lg:col-span-2 bg-white p-6 rounded-xl shadow-sm border">
{selectedRoleId ? (
<PermissionManager selectedRoleId={selectedRoleId} />
) : (
<div className="flex items-center justify-center h-full text-center text-gray-500">
<div>
<i className="fa-solid fa-key text-5xl text-gray-300"></i>
<p className="mt-4 font-semibold">Pilih peran untuk mengelola hak akses.</p>
</div>
</div>
)}
</div>
</div>
);
};
export default RoleTab;