mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
lifecycle
This commit is contained in:
@@ -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 ? (
|
||||
|
||||
Reference in New Issue
Block a user