32 lines
877 B
TypeScript
32 lines
877 B
TypeScript
import { ShopUtils } from '@assets/js-shop/ShopUtils';
|
|
import { Shop } from '@assets/js-shop/Shop';
|
|
import {
|
|
JsShopRefreshEventDetail,
|
|
JsShopRefreshEventName,
|
|
RefreshScopeEnum,
|
|
ToastStatus,
|
|
ToastType,
|
|
} from '@assets/js-shop/Interfaces';
|
|
|
|
const initExternal = (shop: Shop) => {
|
|
window.wpj.jsShop.ignoreRefreshCookie = () => ShopUtils.ignoreRefreshCookie();
|
|
|
|
window.wpj.jsShop.addToast = (message: string) => {
|
|
shop.addToast({ content: message, type: ToastType.Classic, status: ToastStatus.Error})
|
|
}
|
|
|
|
window.wpj.jsShop.clearCache = () => {
|
|
ShopUtils.clearCache();
|
|
};
|
|
|
|
window.wpj.jsShop.refresh = (scope: RefreshScopeEnum = RefreshScopeEnum.All) => {
|
|
document.dispatchEvent(new CustomEvent<JsShopRefreshEventDetail>(JsShopRefreshEventName, { detail: { scope } }));
|
|
};
|
|
|
|
}
|
|
|
|
export const JsShopWindowApi = {
|
|
initExternal,
|
|
|
|
}
|