feat(FE-331): implement permission guard in inventory

This commit is contained in:
ValdiANS
2025-12-23 16:40:32 +07:00
parent a200dac23c
commit de63b6721a
3 changed files with 47 additions and 36 deletions
@@ -4,6 +4,7 @@ import Badge from '@/components/Badge';
import Button from '@/components/Button'; import Button from '@/components/Button';
import SelectInput, { OptionType } from '@/components/input/SelectInput'; import SelectInput, { OptionType } from '@/components/input/SelectInput';
import Table from '@/components/Table'; import Table from '@/components/Table';
import RequirePermission from '@/components/helper/RequirePermission';
import { ROWS_OPTIONS } from '@/config/constant'; import { ROWS_OPTIONS } from '@/config/constant';
import { isResponseSuccess } from '@/lib/api-helper'; import { isResponseSuccess } from '@/lib/api-helper';
import { cn } from '@/lib/helper'; import { cn } from '@/lib/helper';
@@ -175,6 +176,7 @@ const InventoryAdjustmentTable = () => {
<div className='flex flex-col gap-2 mb-4'> <div className='flex flex-col gap-2 mb-4'>
<div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'> <div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'>
<div className='w-full flex flex-row'> <div className='w-full flex flex-row'>
<RequirePermission permissions='lti.inventory.create'>
<Button <Button
href='/inventory/adjustment/add' href='/inventory/adjustment/add'
variant='outline' variant='outline'
@@ -184,6 +186,7 @@ const InventoryAdjustmentTable = () => {
<Icon icon='ic:round-plus' width={24} height={24} /> <Icon icon='ic:round-plus' width={24} height={24} />
Tambah Tambah
</Button> </Button>
</RequirePermission>
{/* <DebouncedTextInput {/* <DebouncedTextInput
name='search' name='search'
@@ -19,6 +19,7 @@ import SelectInput from '@/components/input/SelectInput';
import RowDropdownOptions from '@/components/table/RowDropdownOptions'; import RowDropdownOptions from '@/components/table/RowDropdownOptions';
import RowCollapseOptions from '@/components/table/RowCollapseOptions'; import RowCollapseOptions from '@/components/table/RowCollapseOptions';
import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper'; import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper';
import RequirePermission from '@/components/helper/RequirePermission';
const RowOptionsMenu = ({ const RowOptionsMenu = ({
type = 'dropdown', type = 'dropdown',
@@ -28,6 +29,7 @@ const RowOptionsMenu = ({
props: CellContext<Movement, unknown>; props: CellContext<Movement, unknown>;
}) => ( }) => (
<RowOptionsMenuWrapper type={type}> <RowOptionsMenuWrapper type={type}>
<RequirePermission permissions='lti.inventory.transfer.detail'>
<Button <Button
href={`/inventory/movement/detail/?movementId=${props.row.original.id}`} href={`/inventory/movement/detail/?movementId=${props.row.original.id}`}
variant='ghost' variant='ghost'
@@ -37,6 +39,7 @@ const RowOptionsMenu = ({
<Icon icon='mdi:eye-outline' width={16} height={16} /> <Icon icon='mdi:eye-outline' width={16} height={16} />
Detail Detail
</Button> </Button>
</RequirePermission>
</RowOptionsMenuWrapper> </RowOptionsMenuWrapper>
); );
@@ -145,6 +148,7 @@ const MovementTable = () => {
<div className='flex flex-col gap-2 mb-4'> <div className='flex flex-col gap-2 mb-4'>
<div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'> <div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'>
<div className='w-full flex flex-row gap-2'> <div className='w-full flex flex-row gap-2'>
<RequirePermission permissions='lti.inventory.transfer.create'>
<Button <Button
href='/inventory/movement/add' href='/inventory/movement/add'
variant='outline' variant='outline'
@@ -154,6 +158,7 @@ const MovementTable = () => {
<Icon icon='ic:round-plus' width={24} height={24} /> <Icon icon='ic:round-plus' width={24} height={24} />
Tambah Tambah
</Button> </Button>
</RequirePermission>
</div> </div>
<DebouncedTextInput <DebouncedTextInput
@@ -7,6 +7,7 @@ import Table from '@/components/Table';
import RowCollapseOptions from '@/components/table/RowCollapseOptions'; import RowCollapseOptions from '@/components/table/RowCollapseOptions';
import RowDropdownOptions from '@/components/table/RowDropdownOptions'; import RowDropdownOptions from '@/components/table/RowDropdownOptions';
import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper'; import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper';
import RequirePermission from '@/components/helper/RequirePermission';
import { ROWS_OPTIONS } from '@/config/constant'; import { ROWS_OPTIONS } from '@/config/constant';
import { isResponseSuccess } from '@/lib/api-helper'; import { isResponseSuccess } from '@/lib/api-helper';
import { cn, formatCurrency, formatNumber } from '@/lib/helper'; import { cn, formatCurrency, formatNumber } from '@/lib/helper';
@@ -31,6 +32,7 @@ const RowOptionsMenu = ({
props: CellContext<InventoryProduct, unknown>; props: CellContext<InventoryProduct, unknown>;
}) => ( }) => (
<RowOptionsMenuWrapper type={type}> <RowOptionsMenuWrapper type={type}>
<RequirePermission permissions='lti.inventory.product_stock.detail'>
<Button <Button
href={`/inventory/product/detail?inventoryProductId=${props.row.original.id}`} href={`/inventory/product/detail?inventoryProductId=${props.row.original.id}`}
variant='ghost' variant='ghost'
@@ -40,6 +42,7 @@ const RowOptionsMenu = ({
<Icon icon='mdi:eye-outline' width={16} height={16} /> <Icon icon='mdi:eye-outline' width={16} height={16} />
Detail Detail
</Button> </Button>
</RequirePermission>
</RowOptionsMenuWrapper> </RowOptionsMenuWrapper>
); );