/*! 2024. 7. 2. 오전 10:10:06 */
/******/ (() => {
// webpackBootstrap
var __webpack_exports__ = {};
(() => {
const { pageHelper, EventManager } = ShopbySkin;
const withdrawalHelper = pageHelper.withdrawalHelper();
const containerEl = document.querySelector(
'[shopby-helper-key="withdrawal"]',
);
withdrawalHelper.initialize({
helperKey: 'withdrawal',
platform: 'MOBILE',
});
const fetchConfirmMessage = (helper) => {
const {
couponCnt,
hasOrder,
accumulationAmount: accumulation,
} = helper.getState().helperState;
const accumulationAmount = Number(accumulation ?? 0).toLocaleString();
if (hasOrder) {
return !!couponCnt || !!accumulationAmount
? `진행중인 주문 건이 있습니다.
탈퇴 시 쇼핑몰에 접속 및 주문내역 확인이 불가하며 보유중인 적립금 및 쿠폰은 모두 삭제됩니다.
탈퇴하시겠습니까?
사용가능한 쿠폰 ${couponCnt}장 / 적립금 ${accumulationAmount}원`
: '진행중인 주문 건이 있습니다.
탈퇴 시 쇼핑몰에 접속 및 주문내역 확인이 불가합니다.
탈퇴하시겠습니까?';
}
return `탈퇴 시 쇼핑몰에 접속 불가하며 보유중인 적립금 및 쿠폰은 모두 삭제됩니다.
탈퇴하시겠습니까?
사용가능한 쿠폰 ${couponCnt}장 / 적립금 ${accumulationAmount}원`;
};
const handleWithdrawal = (helper) => {
const { withdrawalProfileForm } = helper.getState();
if (!withdrawalProfileForm.reason) {
EventManager.fire('MODAL_ALERT_OPEN', {
noticeType: 'CAUTION',
message: '탈퇴 사유를 입력해주세요.',
});
return;
}
if (!withdrawalProfileForm.termAgreed) {
EventManager.fire('MODAL_ALERT_OPEN', {
noticeType: 'CAUTION',
message: '회원탈퇴 동의 후 탈퇴가 가능합니다.',
});
return;
}
EventManager.fire('MODAL_CONFIRM_OPEN', {
noticeType: 'WARNING',
message: `${fetchConfirmMessage(helper)}
회원 탈퇴를 신청하신 경우
탈퇴 처리 후 5일간 해당 계정으로의 생성이
불가능하니, 신중하게 결정해 주시기 바랍니다.`,
onConfirm: async () => {
await helper.withdrawal({
reason: withdrawalProfileForm.reason,
});
EventManager.fire('MODAL_ALERT_OPEN', {
noticeType: 'SUCCESS',
message: '회원 탈퇴가 완료되었습니다.',
onClose: () => {
location.replace('/');
},
});
},
});
};
const clickEventListener = ({ target }) => {
const action = target.getAttribute('shopby-action');
if (action === 'CLICK_WITHDRAWAL') {
handleWithdrawal(withdrawalHelper);
}
};
containerEl.addEventListener('click', clickEventListener);
})();
/******/
})();