/*! 2024. 5. 2. 오후 4:59:11 */
/******/ (() => { // webpackBootstrap
var __webpack_exports__ = {};
(() => {
const { EventManager } = ShopbySkin;
const containerEl = document.querySelector('[shopby-helper-key="profile-shipping-address"]');
const addressListComponent = containerEl.querySelector('my-shipping-address-list');
const CLICK_EVENT_HANDLER_MAP = {
REGISTER_SHIPPING_ADDRESS: ({ totalCount }) => {
const afterRegisterForm = ({ reason }) => {
if (reason === 'DID_SUBMIT') {
EventManager.fire('MODAL_ALERT_OPEN', {
noticeType: 'SUCCESS',
label: 'Confirm',
message: 'The shipping address has been registered.',
data: {
totalCount,
},
onClose: () => {
addressListComponent.fetchList({
refresh: true,
});
},
});
}
};
EventManager.fire('OPEN_LAYER_MODAL', {
isFull: false,
modalAddClass: 'address-form',
name: 'shipping-address-form',
title: 'Shipping Address',
onClose: afterRegisterForm,
data: {
totalCount,
},
});
},
DELETE_SHIPPING_ADDRESS: ({ addressNo, isDefault, addressName }) => {
if (!addressNo) {
return;
}
if (isDefault) {
EventManager.fire('MODAL_ALERT_OPEN', {
noticeType: 'CAUTION',
message: 'The default shipping address cannot be deleted.
Please delete it after changing it.',
});
return;
}
EventManager.fire('MODAL_CONFIRM_OPEN', {
noticeType: 'WARNING',
message: `${addressName}${addressName ? ' ' : ''}Do you want to delete the shipping address?`,
onConfirm: async () => {
await addressListComponent.deleteProfileShippingAddress(addressNo);
EventManager.fire('MODAL_ALERT_OPEN', {
noticeType: 'SUCCESS',
message: 'The shipping address has been deleted.',
onClose: () => {
addressListComponent.fetchList({
refresh: true,
});
},
});
},
});
},
MODIFY_SHIPPING_ADDRESS: ({ addressNo, totalCount }) => {
EventManager.fire('OPEN_LAYER_MODAL', {
isFull: false,
modalAddClass: 'address-form',
name: 'shipping-address-form',
data: {
addressNo,
totalCount,
},
onClose: ({ reason }) => {
if (reason === 'DID_MODIFY') {
EventManager.fire('MODAL_ALERT_OPEN', {
noticeType: 'SUCCESS',
message: 'Modification is complete.',
onClose: () => {
addressListComponent.fetchList({
refresh: true,
});
},
});
}
},
});
},
};
const clickEventListener = ({ target }) => {
const actionType = target.getAttribute('shopby-action');
const addressNo = Number(target.closest('[shopby-address-no]')?.getAttribute?.('shopby-address-no') ?? 0);
const addressName = target.closest('[shopby-address-name]')?.getAttribute?.('shopby-address-name');
const isDefault = target.closest('[shopby-default-yn]')?.getAttribute?.('shopby-default-yn') === 'Y';
const totalCount = Number(target.getAttribute('shopby-total-count') || 0);
CLICK_EVENT_HANDLER_MAP[actionType]?.({
addressNo,
isDefault,
totalCount,
addressName,
});
};
containerEl.addEventListener('click', clickEventListener);
EventManager.on('PAGE_LOAD_COMPLETED', () => {
addressListComponent.fetchList();
});
})();
/******/ })()
;