/*! 2024. 5. 2. 오후 4:59:11 */
/******/ (() => { // webpackBootstrap
var __webpack_exports__ = {};
(() => {
const params = new URLSearchParams( location.search );
let langCode = window.localStorage.getItem('langCode') || 'ko';
if ( false ===params.has('langCode') ) {
}
else
if ( ['ko', 'en'].includes( params.get('langCode') ) ) {
langCode = params.get('langCode');
}
const { EventManager, pageHelper } = ShopbySkin;
const { withdrawClaimByOrderOptionNo, confirmOrder, cancelOrder } = pageHelper.orderDetailHelper();
const { initialize } = pageHelper.myOrdersHelper();
const datePickerOption = {
lang: langCode
}
const datePickerHelper = pageHelper.datePickerHelper();
datePickerHelper.initialize(datePickerOption);
const searchParams = new URLSearchParams(location.search);
const queryParams = Object.fromEntries(searchParams.entries());
initialize(queryParams);
const openNaverPayAlertModal = (nextActionType, orderStatusType) => {
const ACTION_TYPE_LABEL = {
CANCEL: 'Cancellation Application',
EXCHANGE: 'Exchange Application',
RETURN: 'Return Application',
CONFIRM_ORDER: 'Confirm Order',
};
if (
nextActionType === 'WRITE_REVIEW' &&
['DELIVERY_ING', 'DELIVERY_DONE', 'BUY_CONFIRM'].includes(orderStatusType)
) {
EventManager.fire('MODAL_ALERT_OPEN', {
noticeType: 'WARNING',
message: 'Naver Pay orders can be reviewed after purchase confirmation on Naver Pay.',
});
return;
}
EventManager.fire('MODAL_ALERT_OPEN', {
noticeType: 'WARNING',
label: "Confirm",
message: `Naver Page orders can be ${ACTION_TYPE_LABEL[nextActionType]} on Naver Pay.`,
});
};
const openWithdrawClaimModal = (orderOptionNo, claimStatusLabel) => {
EventManager.fire('MODAL_CONFIRM_OPEN', {
noticeType: 'WARNING',
cancelLabel: 'Cancel',
confirmLabel: 'Confirm',
message: ` Do you want to withdraw your ${claimStatusLabel} application?`,
onConfirm: async () => {
const { isSuccess } = await withdrawClaimByOrderOptionNo(orderOptionNo);
if (isSuccess) {
EventManager.fire('MODAL_ALERT_OPEN', {
noticeType: 'SUCCESS',
message: `${claimStatusLabel} application has been withdrawn.`,
onClose: () => location.reload(),
});
}
},
});
};
const validateWithdrawClaim = ({ claimNo, claimNos, claimStatusLabel, orderOptionNo }) => {
const hasAfterClaim = claimNos.split(',').some((no) => Number(no) > Number(claimNo));
if (!hasAfterClaim) {
return true;
}
EventManager.fire('MODAL_CONFIRM_OPEN', {
noticeType: 'WARNING',
cancelLabel: 'Cancel',
confirmLabel: 'Confirm',
message: 'If you withdraw, the payment/refund amount of the subsequent claim will change.
Do you want to withdraw the claim?',
onConfirm: () => openWithdrawClaimModal(orderOptionNo, claimStatusLabel),
});
return false;
};
const MODULE_ACTION_HANDLER = {
SEARCH_ORDERS: () => {
const params = new URLSearchParams(location.search);
location.href = `${location.origin}${location.pathname}?${params.toString()}`;
},
CANCEL: ({ orderOptionNo, orderNo, orderOptionCount, payType, orderStatusType, orderNextActionType }) => {
const canCancelAll = orderNextActionType.split(',').includes('CANCEL_ALL');
if (payType === 'NAVER_PAY') {
openNaverPayAlertModal('CANCEL');
return;
}
if (['VIRTUAL_ACCOUNT', 'ESCROW_VIRTUAL_ACCOUNT', 'ESCROW_REALTIME_ACCOUNT_TRANSFER'].includes(payType)) {
const payTypeLabel = {
VIRTUAL_ACCOUNT: 'Virtual Account',
ESCROW_VIRTUAL_ACCOUNT: 'Escrow',
ESCROW_REALTIME_ACCOUNT_TRANSFER: 'Escrow',
};
if (canCancelAll) {
EventManager.fire('MODAL_CONFIRM_OPEN', {
noticeType: 'WARNING',
cancelLabel: 'Cancel',
confirmLabel: 'Confirm',
message: `${payTypeLabel[payType]} payment transactions can only be canceled in full.
Would you like to cancel all?`,
onConfirm: async () => {
const { isSuccess } = await cancelOrder(orderNo);
if (isSuccess) {
EventManager.fire('MODAL_ALERT_OPEN', {
noticeType: 'SUCCESS',
message: 'All orders have been canceled.',
onClose: () => location.reload(),
});
}
},
});
return;
}
if (
orderStatusType !== 'DEPOSIT_WAIT' &&
['ESCROW_VIRTUAL_ACCOUNT', 'ESCROW_REALTIME_ACCOUNT_TRANSFER'].includes(payType)
) {
EventManager.fire('MODAL_ALERT_OPEN', {
noticeType: 'WARNING',
label: 'Confirm',
message:
'Escrow payment transactions can only be canceled when all products are in the payment complete state.
Please inquire through 1:1 inquiry for cancellation.',
});
return;
}
return;
}
if (canCancelAll && orderOptionCount >= 2) {
EventManager.fire('MODAL_CONFIRM_OPEN', {
hasHeader: true,
noticeType: 'WARNING',
cancelLabel: 'Partial Cancellation',
confirmLabel: 'Immediate Full Cancellation',
message: 'Do you want to cancel all products included in the order immediately?
Do you want to cancel only some of the products?',
onCancel: () => {
location.href = `./claim-form.html?orderOptionNo=${orderOptionNo}&claimType=CANCEL`;
},
onConfirm: async () => {
const { isSuccess } = await cancelOrder(orderNo);
if (isSuccess) {
EventManager.fire('MODAL_ALERT_OPEN', {
noticeType: 'SUCCESS',
message: 'All orders have been canceled.',
onClose: () => location.reload(),
});
}
},
});
} else {
location.href = `./claim-form.html?orderOptionNo=${orderOptionNo}&claimType=CANCEL`;
}
},
EXCHANGE: ({ orderOptionNo, deliverable, payType }) => {
if (payType === 'NAVER_PAY') {
openNaverPayAlertModal('EXCHANGE');
return;
}
if (['ESCROW_VIRTUAL_ACCOUNT', 'ESCROW_REALTIME_ACCOUNT_TRANSFER'].includes(payType)) {
EventManager.fire('MODAL_ALERT_OPEN', {
noticeType: 'WARNING',
label: 'Confirm',
message: 'Escrow payment transactions cannot be exchanged.
Please cancel/return and reorder.',
});
return;
}
location.href = `./claim-form.html?orderOptionNo=${orderOptionNo}&claimType=EXCHANGE&deliverable=${deliverable}`;
},
RETURN: ({ orderOptionNo, deliverable, payType }) => {
if (payType === 'NAVER_PAY') {
openNaverPayAlertModal('RETURN');
return;
}
if (['ESCROW_VIRTUAL_ACCOUNT', 'ESCROW_REALTIME_ACCOUNT_TRANSFER'].includes(payType)) {
EventManager.fire('MODAL_ALERT_OPEN', {
noticeType: 'WARNING',
label: 'Confirm',
message:
'For escrow payment, return requests can only be made from the email sent by the payment company.
Please check your email inbox.',
});
return;
}
location.href = `./claim-form.html?orderOptionNo=${orderOptionNo}&claimType=RETURN&deliverable=${deliverable}`;
},
WITHDRAW_CANCEL: ({ orderOptionNo, claimNo, claimNos }) => {
const claimStatusLabel = 'Cancellation';
if (!validateWithdrawClaim({ claimNo, claimNos, claimStatusLabel, orderOptionNo })) {
return;
}
openWithdrawClaimModal(orderOptionNo, claimStatusLabel);
},
WITHDRAW_EXCHANGE: ({ orderOptionNo, claimNo, claimNos }) => {
const claimStatusLabel = 'Exchange';
if (!validateWithdrawClaim({ claimNo, claimNos, claimStatusLabel, orderOptionNo })) {
return;
}
openWithdrawClaimModal(orderOptionNo, claimStatusLabel);
},
WITHDRAW_RETURN: ({ orderOptionNo, claimNo, claimNos }) => {
const claimStatusLabel = 'Return';
if (!validateWithdrawClaim({ claimNo, claimNos, claimStatusLabel, orderOptionNo })) {
return;
}
openWithdrawClaimModal(orderOptionNo, claimStatusLabel);
},
VIEW_DELIVERY: ({ deliveryUri, deliveryType }) => {
if (deliveryType === 'DIRECT_DELIVERY') {
EventManager.fire('MODAL_ALERT_OPEN', {
noticeType: 'WARNING',
label: 'Cancel',
message: 'Delivery tracking is not supported for direct delivery.
Please contact the seller.',
});
return;
}
window.open(deliveryUri);
},
CONFIRM_ORDER: async ({ orderOptionNo, payType, orderStatusType }) => {
if (payType === 'NAVER_PAY') {
openNaverPayAlertModal('CONFIRM_ORDER', orderStatusType);
return;
}
const { isSuccess } = await confirmOrder(orderOptionNo);
if (isSuccess) {
EventManager.fire('MODAL_ALERT_OPEN', {
noticeType: 'SUCCESS',
label: 'Confirm',
message: 'Purchase confirmation has been processed.',
onClose: () => location.reload(),
});
}
},
WRITE_REVIEW: ({ payType, productNo, orderStatusType }) => {
if (payType === 'NAVER_PAY') {
openNaverPayAlertModal('WRITE_REVIEW', orderStatusType);
return;
}
EventManager.fire('OPEN_LAYER_MODAL', {
name: 'product-review-form',
title: 'Product Review',
modalAddClass: 'product-review-form-modal',
isFull: false,
data: {
productNo,
isModify: false,
},
onClose: ({ reason }) => {
if (reason === 'DID_SUBMIT') {
EventManager.fire('MODAL_ALERT_OPEN', {
noticeType: 'success',
cancelLabel: 'Cancel',
confirmLabel: 'Confirm',
message: 'The product review has been registered.',
onClose: () => {
location.reload();
},
});
}
},
});
},
VIEW_CLAIM_DETAIL: ({ claimNo, modalTitlePrefix }) => {
EventManager.fire('OPEN_LAYER_MODAL', {
name: 'claim-detail',
title: `${modalTitlePrefix ?? 'Claim'} Detail History`,
isFull: false,
data: {
claimNo,
},
});
},
};
const dateSearchModule = document.querySelector('date-search');
const dateSearchClickEventListener = ({ target }) => {
const actionTarget = target.getAttribute('shopby-action');
if (!actionTarget) {
return;
}
MODULE_ACTION_HANDLER[actionTarget]();
};
dateSearchModule?.addEventListener('click', dateSearchClickEventListener);
const orderProductOptionsModule = document.querySelector('my-orders');
const orderProductOptionsClickEventListener = ({ target }) => {
const actionTarget = target.getAttribute('shopby-action');
if (!actionTarget) {
return;
}
const orderOptionCount = target.closest('[shopby-order-option-count]')?.getAttribute('shopby-order-option-count');
const orderOptionNo = target.closest('[shopby-order-option-no]')?.getAttribute('shopby-order-option-no');
const payType = target.closest('[shopby-pay-type]')?.getAttribute('shopby-pay-type');
const orderStatusType = target.closest('[shopby-order-status]')?.getAttribute('shopby-order-status');
const deliverable = target.getAttribute('shopby-deliverable');
const deliveryUri = target.getAttribute('shopby-delivery-uri');
const claimNo = target.getAttribute('shopby-claim-no');
const modalTitlePrefix = target.getAttribute('shopby-modal-title-prefix');
const productNo = target.getAttribute('shopby-product-no');
const orderNo = target.getAttribute('shopby-order-no');
const deliveryType = target.getAttribute('shopby-delivery-type');
const claimNos = target.closest('[shopby-claim-nos]')?.getAttribute('shopby-claim-nos');
const orderNextActionType = target
.closest('[shopby-order-next-action-type]')
?.getAttribute('shopby-order-next-action-type');
MODULE_ACTION_HANDLER[actionTarget]({
orderOptionCount,
orderOptionNo,
deliverable,
deliveryUri,
claimNo,
modalTitlePrefix,
productNo,
orderNo,
payType,
orderStatusType,
deliveryType,
claimNos,
orderNextActionType,
});
};
orderProductOptionsModule.addEventListener('click', orderProductOptionsClickEventListener);
})();
/******/ })()
;