Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/pages/Facility/services/inventory/SupplyDeliveryTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ export function SupplyDeliveryTable({
<TableHead rowSpan={2}>{t("#")}</TableHead>
<TableHead rowSpan={2}>{t("item")}</TableHead>
<TableHead rowSpan={2}>{t("batch")}</TableHead>
<TableHead rowSpan={2}>{t("expiry")}</TableHead>
<TableHead rowSpan={2}>{t("requested_qty")}</TableHead>
{!internal && <TableHead rowSpan={2}>{t("pack_size")}</TableHead>}
{!internal && <TableHead rowSpan={2}>{t("pack_qty")}</TableHead>}
Expand Down Expand Up @@ -286,6 +287,16 @@ export function SupplyDeliveryTable({
{delivery.supplied_inventory_item?.product?.batch?.lot_number ||
"-"}
</TableCell>
<TableCell>
{(() => {
const expiry =
delivery.supplied_inventory_item?.product?.expiration_date ||
delivery.supplied_item?.expiration_date;
return expiry
? formatDate(new Date(expiry), "dd/MM/yyyy")
: "-";
})()}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An IIFE inside JSX? Really? In 2026? Just extract expiry to a const before the return statement — you know, like a normal human. The entire IIFE exists to derive one variable; that's what const is for.

const expiry =
  delivery.supplied_inventory_item?.product?.expiration_date ||
  delivery.supplied_item?.expiration_date;
// ...
<TableCell>
  {expiry ? formatDate(parseISO(expiry), "dd/MM/yyyy") : "-"}
</TableCell>

Cleaner, readable, no gymnastics required.

</TableCell>
Comment thread
coderabbitai[bot] marked this conversation as resolved.
<TableCell>
{delivery.supply_request
? round(delivery.supply_request.quantity)
Expand Down
Loading