优化
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user