refactor(admin): scope truck orders to bookings
This commit is contained in:
@@ -41,7 +41,7 @@ function normalizePage(payload: PagePayload): TruckAppointmentPage {
|
||||
}
|
||||
|
||||
function normalizeResource(resource: TruckAppointmentResource): TruckAppointmentResource {
|
||||
const idKeys = ['id', 'outboundOrderId', 'oceanBookingId', 'containerBookingId', 'loadingPlanId', 'warehouseId', 'shippingCompanyId', 'bookingAgentId', 'carrierId']
|
||||
const idKeys = ['id', 'outboundOrderId', 'oceanBookingId', 'warehouseId', 'shippingCompanyId', 'bookingAgentId', 'carrierId']
|
||||
const normalized = { ...resource } as Record<string, unknown>
|
||||
for (const key of idKeys) {
|
||||
if (normalized[key] !== null && normalized[key] !== undefined) normalized[key] = String(normalized[key])
|
||||
@@ -56,8 +56,7 @@ export async function listTruckAppointments(query: TruckAppointmentQuery = {}) {
|
||||
...query,
|
||||
keyword: query.keyword?.trim() || undefined,
|
||||
status: query.status || undefined,
|
||||
containerBookingId: query.containerBookingId || undefined,
|
||||
containerType: query.containerType || undefined,
|
||||
oceanBookingId: query.oceanBookingId || undefined,
|
||||
},
|
||||
})
|
||||
return normalizePage(unwrapApiResponse(response))
|
||||
@@ -73,10 +72,9 @@ type CandidatePagePayload = Omit<TruckAppointmentCandidatePage, 'records' | 'pag
|
||||
|
||||
function normalizeCandidate(candidate: TruckAppointmentCandidate & Record<string, unknown>): TruckAppointmentCandidate {
|
||||
const normalized = { ...candidate } as Record<string, unknown>
|
||||
for (const key of ['oceanBookingId', 'warehouseId', 'requirementId', 'containerBookingId', 'loadingPlanId']) {
|
||||
for (const key of ['oceanBookingId', 'warehouseId']) {
|
||||
if (normalized[key] !== null && normalized[key] !== undefined) normalized[key] = String(normalized[key])
|
||||
}
|
||||
normalized.requirementQuantity = Number(normalized.requirementQuantity || 0)
|
||||
normalized.bookingDocumentReady = normalized.bookingDocumentReady === true
|
||||
return normalized as unknown as TruckAppointmentCandidate
|
||||
}
|
||||
@@ -157,7 +155,6 @@ export async function performTruckAppointmentAction(
|
||||
const body = {
|
||||
expectedVersion: payload.expectedVersion,
|
||||
reason: payload.reason || null,
|
||||
...(payload.containerNo ? { containerNo: payload.containerNo } : {}),
|
||||
}
|
||||
const response = await http.post<ApiEnvelope<TruckAppointmentResource>, ApiEnvelope<TruckAppointmentResource>>(`${basePath}/${id}/${action.toLowerCase()}`, body, {
|
||||
headers: { 'Idempotency-Key': operationKey, ...(requestHash ? { 'X-Request-Hash': requestHash } : {}) },
|
||||
|
||||
Reference in New Issue
Block a user