diff --git a/src/app/v/[token]/dispatch/_components/uplift-request-card.tsx b/src/app/v/[token]/dispatch/_components/uplift-request-card.tsx index 511cfa08..053ca8d1 100644 --- a/src/app/v/[token]/dispatch/_components/uplift-request-card.tsx +++ b/src/app/v/[token]/dispatch/_components/uplift-request-card.tsx @@ -23,6 +23,15 @@ function statusClassName(status: string): string { return `vp-uplift-status-${String(status).toLowerCase()}`; } +function availableActions(request: VendorPortalUpliftRequest, locked: boolean, canAct: boolean) { + // Requests raised from the work order are visible but read-only to the vendor. + const actionable = !locked && canAct && request.raisedByVendor !== false; + return { + canWithdraw: actionable && WITHDRAWABLE_STATUSES.has(request.status), + canRevise: actionable && request.status === "ChangesRequested", + }; +} + export function UpliftRequestCard({ request, locked, @@ -35,10 +44,7 @@ export function UpliftRequestCard({ onCancelRevise, }: UpliftRequestCardProps) { const [revising, setRevising] = useState(false); - // Requests raised from the work order are visible but read-only to the vendor. - const ownRequest = request.raisedByVendor !== false; - const canWithdraw = !locked && canAct && ownRequest && WITHDRAWABLE_STATUSES.has(request.status); - const canRevise = !locked && canAct && ownRequest && request.status === "ChangesRequested"; + const { canWithdraw, canRevise } = availableActions(request, locked, canAct); return (