All files / src/features/Merchants/MerchantSidePanel/ApprovalFlowPanel/components/TaskItemCard helpers.ts

100% Statements 5/5
100% Branches 2/2
100% Functions 1/1
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18    28x       2782x   1919x             1919x    
import { TTaskStatus } from "@features/Merchants/MerchantSidePanel/ApprovalFlowPanel/types";
 
export const isEnabledTaskAction = (
  action: TTaskStatus,
  taskStatus: TTaskStatus,
) => {
  if (action === taskStatus) return true;
 
  const allowedTransitions: Record<TTaskStatus, TTaskStatus[]> = {
    completed: ["ready_for_underwriting"],
    ready_for_underwriting: ["completed", "in_progress", "open"],
    in_progress: ["open", "ready_for_underwriting"],
    open: ["in_progress", "ready_for_underwriting"],
  };
 
  return allowedTransitions[taskStatus]?.includes(action);
};