UNPKG

@shopgate/engage

Version:
15 lines 1.49 kB
import{i18n}from'@shopgate/engage/core';import{getEngageOrderStatus,getEngageLineItemStatus}from"../constants";/** * Generates a translated order status. * @param {string} status The status from the API. * @returns {string} */export var getTranslatedOrderStatus=function getTranslatedOrderStatus(status){var path="order.status.order.".concat(getEngageOrderStatus(status));var translated=i18n.text(path);return translated!==path?translated:status;};/** * Generates a translated line item status. * @param {string} status The status from the API. * @param {string} subStatus The sub status from the API. * @returns {string} */export var getTranslatedLineItemStatus=function getTranslatedLineItemStatus(status,subStatus){var _getEngageLineItemSta;var statusText=(_getEngageLineItemSta=getEngageLineItemStatus(status,subStatus))===null||_getEngageLineItemSta===void 0?void 0:_getEngageLineItemSta.status;var path="order.status.line_item.".concat(statusText);var translated=i18n.text(path);return translated!==path?translated:status;};/** * Determines the active status of a line item. * @param {string} status The status from the API. * @param {string} subStatus The sub status from the API. * @returns {boolean} */export var getLineItemActiveStatus=function getLineItemActiveStatus(status,subStatus){var _getEngageLineItemSta2;return(_getEngageLineItemSta2=getEngageLineItemStatus(status,subStatus))===null||_getEngageLineItemSta2===void 0?void 0:_getEngageLineItemSta2.active;};