mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-03 09:13:22 +00:00
fix(work-orders): only block Completed on evidenced pending uplift
Absence of optional uplift fields means no pending, per SH-188.
This commit is contained in:
parent
a3e9a20477
commit
67c4ee8119
2 changed files with 4 additions and 13 deletions
|
|
@ -24,7 +24,6 @@ export type WoClosabilityInput = {
|
|||
};
|
||||
|
||||
export const PENDING_UPLIFT_GAP = "Pending uplift approval";
|
||||
export const UPLIFT_STATUS_UNAVAILABLE_GAP = "Uplift status unavailable";
|
||||
|
||||
/** Design copy when Completed is blocked solely by a pending uplift. */
|
||||
export const UPLIFT_PENDING_COMPLETED_TITLE =
|
||||
|
|
@ -48,12 +47,6 @@ export function hasPendingUplift(
|
|||
return (row.upliftSummary?.pendingCount ?? 0) > 0;
|
||||
}
|
||||
|
||||
function hasKnownUpliftStatus(
|
||||
row: Pick<WoClosabilityInput, "upliftSummary" | "hasPendingUplift">,
|
||||
): boolean {
|
||||
return typeof row.hasPendingUplift === "boolean" || row.upliftSummary != null;
|
||||
}
|
||||
|
||||
function hasDispatcher(row: Pick<WoClosabilityInput, "dispatcherId" | "dispatcherName">): boolean {
|
||||
return Boolean(row.dispatcherId.trim() || row.dispatcherName.trim());
|
||||
}
|
||||
|
|
@ -90,9 +83,8 @@ export function getClosabilityGaps(row: WoClosabilityInput): string[] {
|
|||
gaps.push("Service");
|
||||
}
|
||||
|
||||
if (!hasKnownUpliftStatus(row)) {
|
||||
gaps.push(UPLIFT_STATUS_UNAVAILABLE_GAP);
|
||||
} else if (hasPendingUplift(row)) {
|
||||
// Only an actually pending uplift blocks completion; missing uplift fields mean no pending evidence.
|
||||
if (hasPendingUplift(row)) {
|
||||
gaps.push(PENDING_UPLIFT_GAP);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import { describe, expect, it } from "vitest";
|
|||
import type { WoClosabilityInput } from "@/domain/work-orders/utils/wo-closability";
|
||||
import {
|
||||
PENDING_UPLIFT_GAP,
|
||||
UPLIFT_STATUS_UNAVAILABLE_GAP,
|
||||
UPLIFT_PENDING_COMPLETED_TITLE,
|
||||
canGenerateCompDoc,
|
||||
formatClosabilityMissingTitle,
|
||||
|
|
@ -106,10 +105,10 @@ describe("getClosabilityGaps", () => {
|
|||
expect(getClosabilityGaps(makeInput({ hasPendingUplift: true }))).toEqual([PENDING_UPLIFT_GAP]);
|
||||
});
|
||||
|
||||
it("blocks Completed when the backend does not provide uplift status", () => {
|
||||
it("allows Completed when uplift status fields are absent (no pending evidence)", () => {
|
||||
expect(
|
||||
getClosabilityGaps(makeInput({ hasPendingUplift: undefined, upliftSummary: undefined })),
|
||||
).toEqual([UPLIFT_STATUS_UNAVAILABLE_GAP]);
|
||||
).toEqual([]);
|
||||
});
|
||||
|
||||
it("requires a photo for Emergency / Reactive", () => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue