51 lines
2.2 KiB
TypeScript
51 lines
2.2 KiB
TypeScript
import { http, unwrapApiResponse, type ApiEnvelope } from '@/shared/api/http'
|
|
|
|
export interface CalendarContainer {
|
|
containerBookingId: string
|
|
cabinetNo: string | null
|
|
containerNo: string | null
|
|
vesselName: string | null
|
|
voyageNo: string | null
|
|
destinationPortName: string | null
|
|
destinationWarehouseCode: string | null
|
|
arrivalAt: string | null
|
|
arrivalType: 'ACTUAL' | 'ESTIMATED'
|
|
}
|
|
export interface CalendarReturn {
|
|
containerBookingId: string
|
|
containerNo: string | null
|
|
fleetSupplierName: string | null
|
|
actualEmptyReturnAt: string | null
|
|
emptyReturnWarning: { status: string; deadlineAt: string | null }
|
|
}
|
|
export interface CalendarSources { containers: CalendarContainer[]; emptyReturns: CalendarReturn[]; emptyReturnsReadable: boolean }
|
|
export interface WarehouseArrival {
|
|
sourceContainerBookingId: string
|
|
containerNo: string | null
|
|
warehouseName: string | null
|
|
warehouseCode: string | null
|
|
plannedAt: string | null
|
|
actualAt: string | null
|
|
version: number
|
|
planCount: number
|
|
canEdit: boolean
|
|
}
|
|
export interface ScheduleRange { from: string; to: string }
|
|
export async function getCalendarSources(range: ScheduleRange, signal?: AbortSignal) {
|
|
return unwrapApiResponse(await http.get<ApiEnvelope<CalendarSources>, ApiEnvelope<CalendarSources>>(
|
|
'/platform/v1/terminal-drayages/calendar-sources', { params: range, signal },
|
|
))
|
|
}
|
|
export async function getWarehouseArrivals(range: ScheduleRange, sourceContainerBookingIds: string[], signal?: AbortSignal) {
|
|
return unwrapApiResponse(await http.post<ApiEnvelope<WarehouseArrival[]>, ApiEnvelope<WarehouseArrival[]>>(
|
|
'/platform/v1/last-leg/appointment-calendar/warehouse-arrivals/query', { ...range, sourceContainerBookingIds }, { signal },
|
|
))
|
|
}
|
|
export interface WarehouseArrivalChange { estimatedWarehouseArrivalAt: string; expectedVersion: number }
|
|
export async function saveWarehouseArrival(containerId: string, body: WarehouseArrivalChange, key: string) {
|
|
return unwrapApiResponse(await http.put<ApiEnvelope<unknown>, ApiEnvelope<unknown>>(
|
|
`/platform/v1/last-leg/orders/container-summaries/${encodeURIComponent(containerId)}/expected-arrival`, body,
|
|
{ headers: { 'Idempotency-Key': key } },
|
|
))
|
|
}
|