Skip to content

Commit

Permalink
fix: Fix actions handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveGT96 committed Nov 13, 2024
1 parent a75b3b5 commit ffd1b5a
Showing 1 changed file with 46 additions and 10 deletions.
56 changes: 46 additions & 10 deletions src/components/accessories/table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,11 @@ const Table: FunctionComponent<IProps> = ({
title={labels?.edit?.tooltip ?? "Edit"}
size="small"
disabled={disableAction(row, "edit")}
onClick={() => onEdit && onEdit(row)}
onClick={
disableAction(row, "edit")
? () => {}
: () => onEdit && onEdit(row)
}
>
<Edit />
</IconButton>
Expand All @@ -137,7 +141,11 @@ const Table: FunctionComponent<IProps> = ({
size="small"
title={labels?.delete?.tooltip ?? "Delete"}
disabled={disableAction(row, "delete")}
onClick={handleOpenConfirmation(row, "delete")}
onClick={
disableAction(row, "delete")
? () => {}
: handleOpenConfirmation(row, "delete")
}
>
<Delete
color={disableAction(row, "delete") ? "inherit" : "primary"}
Expand All @@ -151,7 +159,11 @@ const Table: FunctionComponent<IProps> = ({
size="small"
title={labels?.print?.tooltip ?? "Print"}
disabled={disableAction(row, "print")}
onClick={() => onPrint && onPrint(row)}
onClick={
disableAction(row, "print")
? () => {}
: () => onPrint && onPrint(row)
}
>
<Print color="secondary" />
</IconButton>
Expand All @@ -164,7 +176,11 @@ const Table: FunctionComponent<IProps> = ({
size="small"
title={labels?.view?.tooltip ?? "View details"}
disabled={disableAction(row, "view")}
onClick={() => onView && onView(row)}
onClick={
disableAction(row, "view")
? () => {}
: () => onView && onView(row)
}
>
<InfoOutlined color="primary" titleAccess={"View Details"} />
</IconButton>
Expand All @@ -176,7 +192,9 @@ const Table: FunctionComponent<IProps> = ({
size="small"
title={labels?.pay?.tooltip ?? "Add a payment"}
disabled={disableAction(row, "pay")}
onClick={() => onPay && onPay(row)}
onClick={
disableAction(row, "pay") ? () => {} : () => onPay && onPay(row)
}
>
<MonetizationOn htmlColor="#00912c" />
</IconButton>
Expand All @@ -189,7 +207,11 @@ const Table: FunctionComponent<IProps> = ({
size="small"
title={labels?.close?.tooltip ?? "Close the bill"}
disabled={disableAction(row, "close")}
onClick={() => onClose && onClose(row)}
onClick={
disableAction(row, "close")
? () => {}
: () => onClose && onClose(row)
}
>
<Archive htmlColor="#0373fc" />
</IconButton>
Expand All @@ -202,7 +224,11 @@ const Table: FunctionComponent<IProps> = ({
size="small"
title={labels?.cancel?.tooltip ?? "Cancel"}
disabled={disableAction(row, "cancel")}
onClick={handleOpenConfirmation(row, "cancel")}
onClick={
disableAction(row, "cancel")
? () => {}
: handleOpenConfirmation(row, "cancel")
}
>
<Close color="primary" />
</IconButton>
Expand All @@ -214,7 +240,9 @@ const Table: FunctionComponent<IProps> = ({
size="small"
title={addTitle ?? labels?.add?.tooltip ?? "Add"}
disabled={disableAction(row, "add")}
onClick={() => onAdd && onAdd(row)}
onClick={
disableAction(row, "add") ? () => {} : () => onAdd && onAdd(row)
}
>
<Add />
</IconButton>
Expand All @@ -226,7 +254,11 @@ const Table: FunctionComponent<IProps> = ({
size="small"
disabled={disableAction(row, "restore")}
title={labels?.restore?.tooltip ?? t("common.restore")}
onClick={handleOpenConfirmation(row, "restore")}
onClick={
disableAction(row, "restore")
? () => {}
: handleOpenConfirmation(row, "restore")
}
>
<Restore />
</IconButton>
Expand All @@ -238,7 +270,11 @@ const Table: FunctionComponent<IProps> = ({
size="small"
disabled={disableAction(row, "softDelete")}
title={labels?.softDelete?.tooltip ?? t("common.softDelete")}
onClick={handleOpenConfirmation(row, "softDelete")}
onClick={
disableAction(row, "softDelete")
? () => {}
: handleOpenConfirmation(row, "softDelete")
}
>
<HighlightOff
color={disableAction(row, "softDelete") ? "inherit" : "primary"}
Expand Down

0 comments on commit ffd1b5a

Please sign in to comment.