refactor(FE-64): update MovementTable and TableRowOptions to conditionally show edit and delete options

This commit is contained in:
rstubryan
2025-10-17 09:46:07 +07:00
parent 8c662a5152
commit 8bf7603f66
2 changed files with 20 additions and 12 deletions
@@ -157,8 +157,9 @@ const MovementTable = () => {
type='dropdown'
recordId={props.row.original.id}
basePath='/inventory/movement'
onDelete={deleteClickHandler}
queryParam='movementId'
showEdit={false}
showDelete={false}
/>
</RowDropdownOptions>
)}
@@ -169,8 +170,9 @@ const MovementTable = () => {
type='collapse'
recordId={props.row.original.id}
basePath='/inventory/movement'
onDelete={deleteClickHandler}
queryParam='movementId'
showEdit={false}
showDelete={false}
/>
</RowCollapseOptions>
)}
+16 -10
View File
@@ -8,6 +8,8 @@ interface TableRowOptionsProps {
basePath: string;
onDelete?: () => void;
queryParam?: string;
showEdit?: boolean;
showDelete?: boolean;
}
export const TableRowOptions = ({
@@ -16,6 +18,8 @@ export const TableRowOptions = ({
basePath,
onDelete,
queryParam = 'id',
showEdit = true,
showDelete = true,
}: TableRowOptionsProps) => (
<div
tabIndex={type === 'dropdown' ? 0 : undefined}
@@ -36,16 +40,18 @@ export const TableRowOptions = ({
<Icon icon='mdi:eye-outline' width={16} height={16} />
Detail
</Button>
<Button
href={`${basePath}/detail/edit/?${queryParam}=${recordId}`}
variant='ghost'
color='warning'
className='justify-start text-sm'
>
<Icon icon='mdi:pencil-outline' width={16} height={16} />
Edit
</Button>
{onDelete && (
{showEdit && (
<Button
href={`${basePath}/detail/edit/?${queryParam}=${recordId}`}
variant='ghost'
color='warning'
className='justify-start text-sm'
>
<Icon icon='mdi:pencil-outline' width={16} height={16} />
Edit
</Button>
)}
{showDelete && onDelete && (
<Button
onClick={onDelete}
variant='ghost'