Repository URL to install this package:
|
Version:
0.0.15 ▾
|
import { getTyped } from 'composition';
import { errorContainer } from '@skava/packages/core/notifications';
import { toastMessage } from '@skava/packages/core/notifications';
import { state, makeOrderLookupAPI } from './state';
export const isOrderLookupSuccess = (orderLookupData) => {
const { string } = getTyped(orderLookupData);
return string('orderLookupList.state.status').toLowerCase() !== 'failure';
};
export const hasValidOrders = (orderLookupData) => {
const { array } = getTyped(orderLookupData);
return array('orderLookupList.orders').length > 0;
};
export async function setLookupData() {
const orderLookUp = await makeOrderLookupAPI();
const shouldSetLookupData = isOrderLookupSuccess(orderLookUp.data) && hasValidOrders(orderLookUp.data);
if (shouldSetLookupData) {
state.setLookupData(orderLookUp.data.orderLookupList);
}
else {
errorContainer.setMessage(toastMessage.orderTrackError + 'OrderLookupWidget_index');
}
}
//# sourceMappingURL=deps.js.map