(async () => { const { EventManager, pageHelper, actions } = ShopbySkin; const myLikeProductListHelper = pageHelper.myLikeProductListHelper(); let shopbyCommonData = {}; EventManager.on('PAGE_LOAD_COMPLETED', (commonData) => { shopbyCommonData = commonData; }); // [KR] 도무지 안되서 renderhtml 사용 EventManager.on('QUERY_PROFILE_RECENT_PRODUCTS', (data) => { const html = renderHtml($('custom-recent-product'), { recentProducts: data, totalCount: data.length, }); $('custom-recent-product').html(html); }); 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'); EventManager.fire('OPEN_LAYER_MODAL', { name: 'product-inquiry-form', title: '상품문의', modalAddClass: 'product-inquiry-form-modal', isFull: false, data: { productNo, productName, imageUrl, 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 .productRecentActions() .removeProfileRecentProduct({ productNo: [productNo] }); EventManager.fire('MODAL_ALERT_OPEN', { noticeType: 'SUCCESS', message: '삭제되었습니다.', onClose: () => { location.reload(); }, }); }, }); }, GRADE_BENEFIT: () => { EventManager.fire('OPEN_LAYER_MODAL', { name: 'grade-benefit-guide', title: '등급혜택 안내', isFull: false, data: { commonData: shopbyCommonData, }, }); }, }; document .querySelector('like-product-total-count') ?.addEventListener('click', ({ target }) => { const action = target.getAttribute('shopby-action'); moduleActionHandler[action]?.(myLikeProductListHelper, target); }); document .querySelector('custom-recent-product') ?.addEventListener('click', ({ target }) => { const action = target.getAttribute('shopby-action'); moduleActionHandler[action]?.(myLikeProductListHelper, target); }); document .querySelector('profile-summary') ?.addEventListener('click', ({ target }) => { const actionTarget = target.getAttribute('shopby-action'); if (!actionTarget) { return; } moduleActionHandler[actionTarget]({ target }); }); })();