Upgrade OFF lookup UX and stock detail identifier editing
This commit is contained in:
@@ -77,6 +77,26 @@ function normalizeIdentifierLookupResponse(payload) {
|
||||
identifierType: payload?.identifier_type || null,
|
||||
item: payload?.item || null,
|
||||
payloadFetchedAt: payload?.payload_fetched_at || null,
|
||||
retryAfterSeconds:
|
||||
Number.isInteger(payload?.retry_after_seconds) ? payload.retry_after_seconds : null,
|
||||
staleCache: Boolean(payload?.stale_cache),
|
||||
};
|
||||
}
|
||||
|
||||
function normalizeItemLookupResponse(payload) {
|
||||
return {
|
||||
status: payload?.status || null,
|
||||
found: Boolean(payload?.found),
|
||||
update: Boolean(payload?.update),
|
||||
identifierCode: payload?.identifier_code || null,
|
||||
identifierType: payload?.identifier_type || null,
|
||||
preview: payload?.preview || null,
|
||||
updatedFields: Array.isArray(payload?.updated_fields) ? payload.updated_fields : [],
|
||||
offPayloadFetchedAt: payload?.off_payload_fetched_at || null,
|
||||
retryAfterSeconds:
|
||||
Number.isInteger(payload?.retry_after_seconds) ? payload.retry_after_seconds : null,
|
||||
staleCache: Boolean(payload?.stale_cache),
|
||||
item: payload?.item || null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -111,6 +131,23 @@ export async function lookupItemByIdentifier(store, identifierCode) {
|
||||
return normalizeIdentifierLookupResponse(payload);
|
||||
}
|
||||
|
||||
export async function lookupItemDetails(store, uuidB64, { update = false } = {}) {
|
||||
const payload = await apiRequest(store, `${getPath('items')}/${uuidB64}/lookup`, {
|
||||
method: 'POST',
|
||||
query: { update: update ? 1 : 0 },
|
||||
});
|
||||
|
||||
return normalizeItemLookupResponse(payload);
|
||||
}
|
||||
|
||||
export async function patchStockItem(store, uuidB64, body) {
|
||||
const payload = await apiRequest(store, `${getPath('items')}/${uuidB64}`, {
|
||||
method: 'PATCH',
|
||||
body,
|
||||
});
|
||||
return unwrapEntryPayload(payload);
|
||||
}
|
||||
|
||||
export async function updateStockItem(store, uuidB64, body) {
|
||||
const payload = await apiRequest(store, `${getPath('items')}/${uuidB64}/stock`, {
|
||||
method: 'POST',
|
||||
|
||||
Reference in New Issue
Block a user