From 33f71725988fe1786905315b68379bf100a69cfb Mon Sep 17 00:00:00 2001 From: Alexandre Brandizzi Date: Fri, 25 Sep 2026 03:03:30 -0300 Subject: [PATCH] Move uplift card action gating into a helper Keeps UpliftRequestCard within the changed-file complexity limit. --- .../dispatch/_components/uplift-request-card.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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 (