Add reject step functionality to contract approval process

- Implemented rejection handling in ContractApprovalStepsCard with a modal for rejection reasons.
- Updated useContractMutations to include rejectStep mutation.
- Added REJECT_STEP URL constant for API integration.
- Enhanced ContractClearanceDetailPage to utilize linkedBookingId for improved booking handling.
This commit is contained in:
Marshal
2026-07-07 08:46:31 +00:00
parent 561d0b2344
commit 75f30e2054
5 changed files with 134 additions and 13 deletions

View File

@@ -181,6 +181,15 @@ export function useContractMutations(contractId: string) {
onError: () => toast.error("Failed to approve step"),
});
// Per-step rejection by an approver (line staff / director / CEO). Terminal:
// the contract goes to REJECTED and the customer must create a new one.
const rejectStep = useMutation({
mutationFn: ({ stepId, reason }: { stepId: string; reason: string }) =>
contractsService.rejectStep({ id: contractId, stepId, reason }),
onSuccess: (data) => onSuccess(data, "Contract rejected"),
onError: () => toast.error("Failed to reject step"),
});
// Manual fallback generate — used only if auto-generation failed.
const generateContract = useMutation({
mutationFn: () => contractsService.generateContract(contractId),
@@ -210,6 +219,7 @@ export function useContractMutations(contractId: string) {
requestChanges.isPending ||
reject.isPending ||
approveStep.isPending ||
rejectStep.isPending ||
generateContract.isPending ||
signContract.isPending ||
createBooking.isPending;
@@ -219,6 +229,7 @@ export function useContractMutations(contractId: string) {
requestChanges,
reject,
approveStep,
rejectStep,
generateContract,
signContract,
createBooking,