Move uplift card action gating into a helper

Keeps UpliftRequestCard within the changed-file complexity limit.
This commit is contained in:
Alexandre Brandizzi 2026-09-25 03:03:30 -03:00
parent 70f8b303b5
commit 33f7172598

View file

@ -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 (
<div className="vp-uplift-row">