mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
chore: implement permission guard for edit, approve/reject, and delete button
This commit is contained in:
+25
-20
@@ -36,6 +36,7 @@ import { ColumnDef } from '@tanstack/react-table';
|
|||||||
import { useSelect } from '@/components/input/SelectInput';
|
import { useSelect } from '@/components/input/SelectInput';
|
||||||
import { KandangApi } from '@/services/api/master-data';
|
import { KandangApi } from '@/services/api/master-data';
|
||||||
import DebouncedTextInput from '@/components/input/DebouncedTextInput';
|
import DebouncedTextInput from '@/components/input/DebouncedTextInput';
|
||||||
|
import RequirePermission from '@/components/helper/RequirePermission';
|
||||||
|
|
||||||
interface Kandang {
|
interface Kandang {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -389,19 +390,21 @@ export function ListDailyChecklistContent() {
|
|||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
{row.original.status === 'DRAFT' && (
|
{row.original.status === 'DRAFT' && (
|
||||||
<Button
|
<RequirePermission permissions='lti.daily_checklist.create'>
|
||||||
size='sm'
|
<Button
|
||||||
variant='outline'
|
size='sm'
|
||||||
onClick={() => handleEdit(row.original)}
|
variant='outline'
|
||||||
className='border-gray-200 text-gray-700 hover:bg-gray-50'
|
onClick={() => handleEdit(row.original)}
|
||||||
>
|
className='border-gray-200 text-gray-700 hover:bg-gray-50'
|
||||||
<Edit className='w-4 h-4 mr-1' />
|
>
|
||||||
Edit
|
<Edit className='w-4 h-4 mr-1' />
|
||||||
</Button>
|
Edit
|
||||||
|
</Button>
|
||||||
|
</RequirePermission>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{row.original.status === 'SUBMITTED' && (
|
{row.original.status === 'SUBMITTED' && (
|
||||||
<>
|
<RequirePermission permissions='lti.daily_checklist.create'>
|
||||||
<Button
|
<Button
|
||||||
size='sm'
|
size='sm'
|
||||||
onClick={() => handleApprove(row.original)}
|
onClick={() => handleApprove(row.original)}
|
||||||
@@ -419,19 +422,21 @@ export function ListDailyChecklistContent() {
|
|||||||
<XCircle className='w-4 h-4 mr-1' />
|
<XCircle className='w-4 h-4 mr-1' />
|
||||||
Reject
|
Reject
|
||||||
</Button>
|
</Button>
|
||||||
</>
|
</RequirePermission>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{row.original.status === 'DRAFT' && (
|
{row.original.status === 'DRAFT' && (
|
||||||
<Button
|
<RequirePermission permissions='lti.daily_checklist.create'>
|
||||||
size='sm'
|
<Button
|
||||||
variant='destructive'
|
size='sm'
|
||||||
onClick={() => handleDelete(row.original)}
|
variant='destructive'
|
||||||
className='bg-red-600 hover:bg-red-700 text-white'
|
onClick={() => handleDelete(row.original)}
|
||||||
>
|
className='bg-red-600 hover:bg-red-700 text-white'
|
||||||
<Trash2 className='w-4 h-4 mr-1' />
|
>
|
||||||
Hapus
|
<Trash2 className='w-4 h-4 mr-1' />
|
||||||
</Button>
|
Hapus
|
||||||
|
</Button>
|
||||||
|
</RequirePermission>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user