(() => { const { EventManager, pageHelper, actions, utils } = ShopbySkin; const { unescapeHTML } = utils; const myLikeProductListHelper = pageHelper.myLikeProductListHelper(); const searchParams = new URLSearchParams(location.search); const pageNumber = searchParams.get('pageNumber'); const pageSize = searchParams.get('pageSize'); const hasTotalCount = searchParams.get('hasTotalCount'); myLikeProductListHelper.initialize({ pageNumber, pageSize, hasTotalCount, }); const moduleActionHandler = { INQUIRE_PRODUCT: (_, target) => { const productNo = target.closest('[shopby-product-no]')?.getAttribute('shopby-product-no'); const productName = target.closest('[shopby-product-name]')?.getAttribute('shopby-product-name'); const imageUrl = target.closest('[shopby-image-url]')?.getAttribute('shopby-image-url'); const imageType = target.closest('[shopby-image-url]')?.getAttribute('shopby-image-type'); EventManager.fire('OPEN_LAYER_MODAL', { name: 'product-inquiry-form', title: '상품문의', modalAddClass: 'product-inquiry-form-modal', isFull: false, data: { productNo, productName, unescapedProductName: unescapeHTML(productName), imageUrl, imageType, isModify: false, commonData: myLikeProductListHelper.commonData, }, onClose: ({ reason }) => { if (reason === 'DID_SUBMIT') { EventManager.fire('MODAL_ALERT_OPEN', { noticeType: 'SUCCESS', message: '상품문의가 등록됐습니다.', onClose: () => { location.reload(); }, }); } }, }); }, DELETE_LIKE_PRODUCT: (_, target) => { const productNo = target.closest('[shopby-product-no]')?.getAttribute('shopby-product-no'); EventManager.fire('MODAL_CONFIRM_OPEN', { noticeType: 'WARNING', message: `선택하신 상품을 삭제하시겠습니까?`, onConfirm: async () => { await actions.postProfileLikeByProductNos({ productNos: [productNo] }); EventManager.fire('MODAL_ALERT_OPEN', { noticeType: 'SUCCESS', message: '삭제되었습니다.', onClose: () => { location.reload(); }, }); }, }); }, DELETE_SELECTED_LIKE_PRODUCTS: (_, target) => { const selectedCount = target.getAttribute('shopby-selected-count'); const checkedProductNosAsString = target.getAttribute('shopby-checked-product-nos-as-string'); if (!Number(selectedCount)) { EventManager.fire('MODAL_ALERT_OPEN', { noticeType: 'CAUTION', message: '선택하신 상품이 없습니다.', }); return; } const productNos = checkedProductNosAsString.split(','); EventManager.fire('MODAL_CONFIRM_OPEN', { noticeType: 'WARNING', message: `선택하신 ${productNos.length}개의 상품을 삭제하시겠습니까?`, onConfirm: async () => { await actions.postProfileLikeByProductNos({ productNos }); EventManager.fire('MODAL_ALERT_OPEN', { noticeType: 'SUCCESS', message: '삭제되었습니다.', onClose: () => { location.reload(); }, }); }, }); }, }; document.querySelector('like-product-total-count')?.addEventListener('click', ({ target }) => { const action = target.getAttribute('shopby-action'); moduleActionHandler[action]?.(myLikeProductListHelper, target); }); document.querySelector('like-product-list')?.addEventListener('click', ({ target }) => { const action = target.getAttribute('shopby-action'); moduleActionHandler[action]?.(myLikeProductListHelper, target); }); })();