diff --git a/src/app/(protected)/workorders/_components/list/table/cells/status-cell.tsx b/src/app/(protected)/workorders/_components/list/table/cells/status-cell.tsx index 28049593..67d826ee 100644 --- a/src/app/(protected)/workorders/_components/list/table/cells/status-cell.tsx +++ b/src/app/(protected)/workorders/_components/list/table/cells/status-cell.tsx @@ -1,46 +1,28 @@ import { useState } from "react"; - import { AlertTriangle, Check } from "lucide-react"; - import { Popover } from "@mui/material"; import { Text } from "@/components/ui/text"; - import { ALL_WIZARD_STATUSES, type WizardWOStatus, } from "@/domain/work-orders/types/work-order-wizard"; - import type { WorkOrderTableRow } from "@/domain/work-orders/types/work-order-table-row"; import { formatClosabilityMissingTitle, getClosabilityGaps, } from "@/domain/work-orders/utils/wo-closability"; - import { HoverChevron } from "./hover-chevron"; - import { WoTableStatusLabel } from "./wo-table-status-label"; type StatusCellProps = { wo: WorkOrderTableRow; - onChangeStatus: (status: WizardWOStatus) => void; - onOpenSlideOver: () => void; - onPastDueAttempt?: () => void; }; -export function StatusCell({ - wo, - - onChangeStatus, - - onOpenSlideOver, - - onPastDueAttempt, -}: StatusCellProps) { - const [anchorEl, setAnchorEl] = useState(null); - const closabilityGaps = getClosabilityGaps({ +function rowClosabilityGaps(wo: WorkOrderTableRow) { + return getClosabilityGaps({ dispatcherId: wo.dispatcherId, dispatcherName: wo.dispatcherName, tech: wo.tech, @@ -53,73 +35,91 @@ export function StatusCell({ upliftSummary: wo.upliftSummary, hasPendingUplift: wo.hasPendingUplift, }); +} + +function PastDueStatusCell({ + onOpenSlideOver, + onPastDueAttempt, +}: { + onOpenSlideOver: () => void; + onPastDueAttempt?: () => void; +}) { + const [anchorEl, setAnchorEl] = useState(null); + + return ( + <> + + + setAnchorEl(null)} + anchorOrigin={{ vertical: "bottom", horizontal: "left" }} + onClick={(e) => e.stopPropagation()} + slotProps={{ + paper: { className: "w-[264px] overflow-hidden rounded-lg border border-border p-0" }, + }} + > +
+ +
+ + This work order is past due. Update the Due Date before the status can be updated. + + +
+
+
+ + ); +} + +export function StatusCell({ + wo, + onChangeStatus, + onOpenSlideOver, + onPastDueAttempt, +}: StatusCellProps) { + const [anchorEl, setAnchorEl] = useState(null); + const closabilityGaps = rowClosabilityGaps(wo); if (wo.isPastDue) { return ( - <> - - - setAnchorEl(null)} - anchorOrigin={{ vertical: "bottom", horizontal: "left" }} - onClick={(e) => e.stopPropagation()} - slotProps={{ - paper: { className: "w-[264px] overflow-hidden rounded-lg border border-border p-0" }, - }} - > -
- - -
- - This work order is past due. Update the Due Date before the status can be updated. - - - -
-
-
- + ); } @@ -129,7 +129,6 @@ export function StatusCell({ type="button" onClick={(e) => { e.stopPropagation(); - setAnchorEl(e.currentTarget); }} className="group/cell flex w-full items-center gap-1 transition-opacity hover:opacity-80" @@ -139,7 +138,6 @@ export function StatusCell({ ) : ( — )} - @@ -177,8 +175,7 @@ export function StatusCell({ } > - - {wo.status === status && ( + {Boolean(wo.status === status) && ( )}