fix: coalesce PDA warehouse profile requests
This commit is contained in:
+9
-1
@@ -3,9 +3,17 @@ import { normalizeReceivingCandidate, normalizeReceivingSession, normalizeReceiv
|
||||
|
||||
const RECEIVING_BASE = '/pda/v1/last-leg/receiving-containers'
|
||||
const current = (suffix = '') => `${RECEIVING_BASE}/current${suffix}`
|
||||
let warehouseProfileRequest = null
|
||||
|
||||
export const listReceivingCandidates = async () => (await overseasRequest('GET', `${RECEIVING_BASE}/candidates`)).map(normalizeReceivingCandidate)
|
||||
export const getCurrentWarehouseProfile = async () => normalizeReceivingWarehouseProfile(await overseasRequest('GET', `${RECEIVING_BASE}/warehouse-profile`))
|
||||
export const getCurrentWarehouseProfile = () => {
|
||||
if (!warehouseProfileRequest) {
|
||||
warehouseProfileRequest = overseasRequest('GET', `${RECEIVING_BASE}/warehouse-profile`)
|
||||
.then(normalizeReceivingWarehouseProfile)
|
||||
.finally(() => { warehouseProfileRequest = null })
|
||||
}
|
||||
return warehouseProfileRequest
|
||||
}
|
||||
export const getReceivingContainer = async (containerNo) => normalizeReceivingSession(await overseasRequest('GET', `${RECEIVING_BASE}/${encodeURIComponent(containerNo)}`))
|
||||
export const prepareReceivingContainer = async (containerNo, request) => normalizeReceivingSession(await overseasRequest('POST', `${RECEIVING_BASE}/${encodeURIComponent(containerNo)}/prepare`, request))
|
||||
export const uploadCurrentUnloadPhoto = (filePath) => overseasUpload(current('/unload-photos/files'), filePath)
|
||||
|
||||
Reference in New Issue
Block a user