mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-09-30 05:43:12 +00:00
Move uplift card action gating into a helper
Keeps UpliftRequestCard within the changed-file complexity limit.
This commit is contained in:
parent
70f8b303b5
commit
33f7172598
1 changed files with 10 additions and 4 deletions
|
|
@ -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">
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue