class CustomProductInquiryList extends ShopbySkin.modules.ProductInquiryList { constructor() { super(...arguments); this.propsAsString.startYmd; this.propsAsString.dateType; } setup() { super.setup() const params = new URLSearchParams(location.search); this.propsParam.startYmd = params.get('startYmd') || this.getDateBefore(7); this.propsParam.dateType = params.get('dateType') || '7d'; } getDateBefore(number) { const today = new Date(); // 7일 전 날짜로 설정 today.setDate(today.getDate() - number); const year = today.getFullYear(); const month = String(today.getMonth() + 1).padStart(2, '0'); // 월은 0부터 시작하므로 +1 const day = String(today.getDate()).padStart(2, '0'); // 일자를 2자리로 맞춤 return `${year}-${month}-${day}`; } } customElements.define('custom-product-inquiry-list', CustomProductInquiryList); class CustomDateTypeSelector extends ShopbySkin.modules.DateTypeSelector { handleDateChange = ({target}) => { const selectedDateType = target.value; const params = new URLSearchParams(location.search); if (!ShopbySkin.utils.validateDateType(selectedDateType)) { const beforeChangedDateType = params.get("dateType"); this.selectedOption(beforeChangedDateType); return; } const startYmd = ShopbySkin.utils.getStartDate(selectedDateType); params.set("startYmd", startYmd); params.set("dateType", selectedDateType); params.set("pageNumber", 1); location.href = `${location.origin}${location.pathname}?${params.toString()}`; } } customElements.define('custom-date-type-selector', CustomDateTypeSelector); (async () => { const { EventManager, pageHelper } = ShopbySkin; const myProductInquiryListHelper = pageHelper.myProductInquiryListHelper(); myProductInquiryListHelper.initialize({ answered: null, searchType: 'ALL', hasTotalCount: true, }); const moduleActionHandler = { REGISTER: () => { EventManager.fire('OPEN_LAYER_MODAL', { name: 'product-inquiry-form', title: '상품문의', data: { isSelectProduct: true, commonData: myProductInquiryListHelper.commonData, }, onClose: ({ reason }) => { if (reason === 'DID_SUBMIT') { EventManager.fire('MODAL_ALERT_OPEN', { noticeType: 'SUCCESS', message: '상품문의가 등록됐습니다.', onClose: () => { location.reload(); }, }); } }, }); }, }; document.querySelector('product-inquiry-total-count')?.addEventListener('click', ({ target }) => { const action = target.getAttribute('shopby-action'); moduleActionHandler[action]?.(); }); document.querySelector('product-inquiry-list')?.addEventListener('click', ({ target }) => { const action = target.getAttribute('shopby-action'); const productNo = target.closest('[shopby-product-no]')?.getAttribute('shopby-product-no'); const inquiryNo = target.closest('[shopby-inquiry-no]')?.getAttribute('shopby-inquiry-no'); moduleActionHandler[action]?.(myProductInquiryListHelper, { productNo, inquiryNo }); }); })();