fix(admin): allow manual container nodes without tracking
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import { http, unwrapApiResponse, type ApiEnvelope } from '@/shared/api/http'
|
||||
import type { ContainerManualNodeRequest, ContainerShippingNodeDetail } from '../types'
|
||||
|
||||
const basePath = '/platform/v1/container-shipping-nodes'
|
||||
|
||||
function normalize(raw: ContainerShippingNodeDetail): ContainerShippingNodeDetail {
|
||||
return { ...raw, containerBookingId: String(raw.containerBookingId), nodes: (raw.nodes || []).map((item) => ({ ...item, id: String(item.id), nodeSequence: Number(item.nodeSequence) })) }
|
||||
}
|
||||
|
||||
export async function getContainerShippingNodes(containerBookingId: string): Promise<ContainerShippingNodeDetail> {
|
||||
const response = await http.get<ApiEnvelope<ContainerShippingNodeDetail>, ApiEnvelope<ContainerShippingNodeDetail>>(`${basePath}/${encodeURIComponent(containerBookingId)}`)
|
||||
return normalize(unwrapApiResponse(response))
|
||||
}
|
||||
|
||||
export async function appendContainerShippingNode(containerBookingId: string, idempotencyKey: string, request: ContainerManualNodeRequest): Promise<ContainerShippingNodeDetail> {
|
||||
const response = await http.post<ApiEnvelope<ContainerShippingNodeDetail>, ApiEnvelope<ContainerShippingNodeDetail>>(`${basePath}/${encodeURIComponent(containerBookingId)}`, request, { headers: { 'Idempotency-Key': idempotencyKey } })
|
||||
return normalize(unwrapApiResponse(response))
|
||||
}
|
||||
Reference in New Issue
Block a user