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' type='dropdown'
recordId={props.row.original.id} recordId={props.row.original.id}
basePath='/inventory/movement' basePath='/inventory/movement'
onDelete={deleteClickHandler}
queryParam='movementId' queryParam='movementId'
showEdit={false}
showDelete={false}
/> />
</RowDropdownOptions> </RowDropdownOptions>
)} )}
@@ -169,8 +170,9 @@ const MovementTable = () => {
type='collapse' type='collapse'
recordId={props.row.original.id} recordId={props.row.original.id}
basePath='/inventory/movement' basePath='/inventory/movement'
onDelete={deleteClickHandler}
queryParam='movementId' queryParam='movementId'
showEdit={false}
showDelete={false}
/> />
</RowCollapseOptions> </RowCollapseOptions>
)} )}
+16 -10
View File
@@ -8,6 +8,8 @@ interface TableRowOptionsProps {
basePath: string; basePath: string;
onDelete?: () => void; onDelete?: () => void;
queryParam?: string; queryParam?: string;
showEdit?: boolean;
showDelete?: boolean;
} }
export const TableRowOptions = ({ export const TableRowOptions = ({
@@ -16,6 +18,8 @@ export const TableRowOptions = ({
basePath, basePath,
onDelete, onDelete,
queryParam = 'id', queryParam = 'id',
showEdit = true,
showDelete = true,
}: TableRowOptionsProps) => ( }: TableRowOptionsProps) => (
<div <div
tabIndex={type === 'dropdown' ? 0 : undefined} tabIndex={type === 'dropdown' ? 0 : undefined}
@@ -36,16 +40,18 @@ export const TableRowOptions = ({
<Icon icon='mdi:eye-outline' width={16} height={16} /> <Icon icon='mdi:eye-outline' width={16} height={16} />
Detail Detail
</Button> </Button>
<Button {showEdit && (
href={`${basePath}/detail/edit/?${queryParam}=${recordId}`} <Button
variant='ghost' href={`${basePath}/detail/edit/?${queryParam}=${recordId}`}
color='warning' variant='ghost'
className='justify-start text-sm' color='warning'
> className='justify-start text-sm'
<Icon icon='mdi:pencil-outline' width={16} height={16} /> >
Edit <Icon icon='mdi:pencil-outline' width={16} height={16} />
</Button> Edit
{onDelete && ( </Button>
)}
{showDelete && onDelete && (
<Button <Button
onClick={onDelete} onClick={onDelete}
variant='ghost' variant='ghost'