mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-07 16:19:01 +00:00
Two sections, Work order and Uplift request, divided by a single rule. Work order shows Service, Vendor / Technician, Assigned Dispatcher and Scheduled from the queue item, so it no longer fetches the work order and no longer degrades to Unavailable for account-scoped staff. Uplift request shows Requested By, Requested At, the justification in a bordered block, the approved-on-WO breakdown and a horizontal attachment row whose chips open the evidence in a new tab. Every field renders data or an explicit placeholder. The footer shows Reject and Approve for pending uplifts, Revoke for approved ones and nothing for read-only records; closing is the header X.
28 lines
1,017 B
TypeScript
28 lines
1,017 B
TypeScript
import { toast } from "react-toastify";
|
|
import type { UpliftQueueItem } from "@/domain/uplifts/types/uplift";
|
|
import { upliftsApi } from "@/domain/uplifts/api/uplifts-api";
|
|
|
|
function reportEvidenceError(error: unknown): void {
|
|
toast.error(error instanceof Error ? error.message : "Unable to download evidence right now.");
|
|
}
|
|
|
|
export function openUpliftEvidence(row: UpliftQueueItem): void {
|
|
void upliftsApi
|
|
.downloadEvidence(row.id, row.evidenceFileName || "uplift-evidence")
|
|
.catch(reportEvidenceError);
|
|
}
|
|
|
|
export function openUpliftEvidenceInNewTab(row: UpliftQueueItem): void {
|
|
// Open the tab inside the click handler; a tab opened after the fetch resolves
|
|
// is treated as an unsolicited popup and blocked.
|
|
const tab = window.open("about:blank", "_blank");
|
|
if (tab != null) {
|
|
tab.opener = null;
|
|
}
|
|
void upliftsApi
|
|
.openEvidence(row.id, tab, row.evidenceFileName || "uplift-evidence")
|
|
.catch((error: unknown) => {
|
|
tab?.close();
|
|
reportEvidenceError(error);
|
|
});
|
|
}
|