(() => { const { EventManager, pageHelper } = ShopbySkin; const myProductReviewListHelper = pageHelper.myProductReviewListHelper(); myProductReviewListHelper.initialize(); const moduleActionHandler = { REGISTER: (_, { productNo, reviewNo, usesAttachment }) => { EventManager.fire('OPEN_LAYER_MODAL', { name: 'product-review-form', title: '상품 후기', modalAddClass: 'product-review-form-modal', isFull: false, data: { productNo, reviewNo, usesAttachment, isSelectProduct: true, }, onClose: ({ reason }) => { if (reason === 'DID_SUBMIT') { EventManager.fire('MODAL_ALERT_OPEN', { noticeType: 'success', message: '상품후기가 등록되었습니다.', onClose: () => { location.reload(); }, }); } }, }); }, }; // 상품후기 운영 정책 안내·혜택 안내는 같은 안내 팝업(product-review-policy-notice)으로 노출한다. // isPlainText: 줄바꿈(\n)으로 구분된 일반 텍스트 안내문구 — 팝업은 HTML 로 렌더하므로
로 바꿔 넘긴다. // (운영 정책 안내는 에디터 HTML 이라 태그 사이 개행을 바꾸지 않는다) const openReviewNotice = ({ title, noticeTextKey, isPlainText = false }) => { // product-review-list 는 게시판 설정을 store 에 두지 않으므로 같은 설정을 보관하는 product-review-total-count 에서 읽는다. const reviewTotalCountEl = document.querySelector('product-review-total-count'); const { reviewConfig } = reviewTotalCountEl?.store.state ?? {}; const noticeText = reviewConfig?.expandedReviewConfig?.[noticeTextKey] ?? ''; EventManager.fire('OPEN_LAYER_MODAL', { name: 'product-review-policy-notice', title, isFull: false, modalAddClass: 'product-review-policy-notice-modal', data: { noticeText: isPlainText ? noticeText.replace(/\r?\n/g, '
') : noticeText, }, }); }; const reviewNoticeActionHandler = { OPEN_REVIEW_POLICY_NOTICE: () => openReviewNotice({ title: '상품후기 운영 정책 안내', noticeTextKey: 'reviewOperationPolicyNoticeText' }), OPEN_REVIEW_BENEFIT_NOTICE: () => openReviewNotice({ title: '상품후기 혜택 안내', noticeTextKey: 'reviewRewardNoticeText', isPlainText: true }), }; document.querySelector('product-review-list')?.addEventListener('click', ({ target }) => { const action = target.closest('[shopby-action]')?.getAttribute('shopby-action'); reviewNoticeActionHandler[action]?.(); }); document.querySelector('product-review-total-count')?.addEventListener('click', ({ target }) => { // 버튼 안 건수(span)를 눌러도 동작하도록 가장 가까운 액션 요소에서 읽는다 (MO와 동일) const action = target.closest('[shopby-action]')?.getAttribute('shopby-action'); const productNo = target.closest('[shopby-product-no]')?.getAttribute('shopby-product-no'); const reviewNo = target.closest('[shopby-review-no]')?.getAttribute('shopby-review-no'); const usesAttachment = target.closest('[shopby-uses-attachment]')?.getAttribute('shopby-uses-attachment'); moduleActionHandler[action]?.(myProductReviewListHelper, { productNo, reviewNo, usesAttachment }); }); })();