lifecycle

This commit is contained in:
Nathnael
2026-08-18 13:11:09 +00:00
parent 03b16b4ee8
commit dd6df306f2
3 changed files with 79 additions and 13 deletions

View File

@@ -27,6 +27,7 @@ import {
import type { Freight } from "@edr/types";
import { ClearanceOpsTabs } from "@/components/contracts/ClearanceOpsTabs";
import { BookingChangesRequestedAlert } from "@/components/contracts/BookingChangesRequestedAlert";
import { PageContainer, PageHeader, KpiStrip } from "@/components/page";
import type { KpiItem } from "@/components/page";
import {
@@ -134,6 +135,20 @@ export default function DocumentClearanceDetailPage() {
hasPermission(user, FREIGHT_PERMS.contracts.createBooking) &&
!isDjiboutiGl(user);
// Operations sent this GL-created booking back for changes. Customs bookings
// are never self-booked (see BookingChangesRequestedAlert) — the note and the
// resubmit belong here, on the page GL works from, not the customer's portal.
const bookingNeedsChanges = booking?.status === "OPERATION_CHANGES_REQUESTED";
const isGlBookingOwner =
hasPermission(user, FREIGHT_PERMS.contracts.createBooking) &&
!isDjiboutiGl(user);
const changeRequestNote =
[...(booking?.reviewNotes ?? [])]
.filter((n) => n.type === "CHANGES_REQUESTED")
.sort(
(a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime(),
)[0]?.note ?? null;
const docsPhaseComplete =
clearance?.milestones?.some(
(m) => m.milestoneCode === "DOCUMENTS_APPROVED" && m.status === "COMPLETED",
@@ -279,6 +294,22 @@ export default function DocumentClearanceDetailPage() {
}
/>
{bookingNeedsChanges ? (
<BookingChangesRequestedAlert
bookingId={id!}
reference={booking?.reference}
note={changeRequestNote}
scheduledDate={booking?.scheduledDate}
canResubmit={isGlBookingOwner}
editHref={
booking?.contractId
? `/dashboard/contracts/${booking.contractId}/bookings/${id}/complete?copyFrom=${id}`
: undefined
}
onResubmitted={() => void refetch()}
/>
) : null}
<KpiStrip items={kpis} />
{requestedLines ? (