This commit is contained in:
2026-08-13 12:22:41 +08:00
parent 835ac0ad12
commit 8a8c4fa190
26 changed files with 572 additions and 148 deletions
@@ -1,4 +1,13 @@
import { http, unwrapApiResponse, type ApiEnvelope } from '@/shared/api/http'
export interface CustomerContainerTransitSummary {
customerId: string
containerCount: number
totalTeu: number | string
unknownContainerCount: number
asOf: string
definition: string
}
import type {
ContainerBookingResource,
ContainerPage,
@@ -90,6 +99,18 @@ export async function listContainers(query: ContainerQuery): Promise<ContainerPa
return { ...result, records: (result.records || []).map(container), page: numberValue(result.page, query.page), size: numberValue(result.size, query.size), total: numberValue(result.total), pages: numberValue(result.pages) }
}
export async function getCustomerContainerTransitSummary(customerId: string): Promise<CustomerContainerTransitSummary> {
const response = await http.get<ApiEnvelope<Record<string, unknown>>, ApiEnvelope<Record<string, unknown>>>(
`/platform/v1/customers/${encodeURIComponent(customerId)}/container-transit-summary`,
)
const result = unwrapApiResponse(response)
return {
customerId: id(result.customerId), containerCount: numberValue(result.containerCount),
totalTeu: String(result.totalTeu ?? '0'), unknownContainerCount: numberValue(result.unknownContainerCount),
asOf: id(result.asOf), definition: id(result.definition),
}
}
export async function getContainer(containerId: string) {
const response = await http.get<ApiEnvelope<ContainerBookingResource>, ApiEnvelope<ContainerBookingResource>>(`${containerPath}/${encodeURIComponent(containerId)}`)
return container(unwrapApiResponse(response))