Skip to content
Open
Changes from 3 commits
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
13 changes: 12 additions & 1 deletion src/pages/Facility/services/inventory/SupplyDeliveryTable.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { formatDate } from "date-fns";
import { formatDate, parseISO } from "date-fns";
import { EllipsisVertical } from "lucide-react";
import { Link } from "raviger";
import { useEffect, useMemo, useRef } from "react";
Expand Down 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(parseISO(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