/*! 6/21/2024, 11:42:05 AM */ /******/ (() => { // webpackBootstrap var __webpack_exports__ = {}; (() => { const { pageHelper, EventManager, utils: { changeProfileFormVerifyMap, handleFocusEvent, isSignedIn }, } = ShopbySkin; if (isSignedIn()) { if (!document.referrer || location.href === document.referrer) { history.back(); return; } location.href = document.referrer; } const signUpFormHelper = pageHelper.signUpFormHelper(); const containerEl = document.querySelector(`[shopby-helper-key="sign-up-form"]`); signUpFormHelper.initialize({ helperKey: 'sign-up-form', }); const flattenRequest = (helper) => { const { profileBasicInformation, profileNicknameInformation, profileEmailInformation, profileSmsInformation, profileCertification, profileOptionalInformation, termsInformation, profileExtraInformation, } = helper.getState(); const selectedCustomTerms = termsInformation?.customTerms.filter(({ checked }) => !!checked).map((term) => term.id); return { ...profileBasicInformation, ...profileEmailInformation, ...profileSmsInformation, ...profileCertification, ...profileOptionalInformation, extraInfo: profileExtraInformation?.extraInfoContents, nickname: profileNicknameInformation?.nickname, joinTermsAgreements: termsInformation?.terms, customTermsNos: selectedCustomTerms, }; }; const checkInvalidProfileForm = (request) => { // eslint-disable-next-line complexity const errors = Object.keys(changeProfileFormVerifyMap)?.map((key) => { const value = request?.[key]?.value ?? ''; switch (key) { case 'memberId': return { ...changeProfileFormVerifyMap?.[key]({ value, isDuplicated: request?.memberId?.isDuplicate, isDormantMemberId: !!request?.isRecentlyExitedMember, }), field: key, }; case 'passwordConfirm': return { ...changeProfileFormVerifyMap?.[key]({ value, comparisonValue: request?.password?.value }), field: key, }; case 'memberName': return { ...changeProfileFormVerifyMap?.[key]({ value, isRequired: request?.memberName?.isRequired }), field: key, }; case 'nickname': return { ...changeProfileFormVerifyMap?.[key]({ value, isDuplicated: request?.nickname?.isDuplicate, isRequired: request?.nickname?.isRequired, }), field: key, }; case 'email': return { ...changeProfileFormVerifyMap?.[key]({ value, isDuplicated: request?.email?.isDuplicate, isRequired: request?.email?.isRequired, }), field: key, }; case 'mobileNo': case 'telephoneNo': return { ...changeProfileFormVerifyMap?.[key]({ value, isRequired: request?.[key]?.isRequired }), field: key, }; case 'detailAddress': return { ...changeProfileFormVerifyMap?.[key]({ value, zipCode: request?.zipCd, isRequired: request?.detailAddress?.isRequired, }), field: key, }; case 'birthday': case 'sex': return { ...changeProfileFormVerifyMap?.[key]({ value, isRequired: request?.[key]?.isRequired }), field: key, }; case 'extraInfo': return { ...changeProfileFormVerifyMap?.[key](request.extraInfo), field: key }; case 'joinTermsAgreements': return { ...changeProfileFormVerifyMap?.[key](request.joinTermsAgreements), field: key }; default: return { ...changeProfileFormVerifyMap?.[key]({ value }), field: key }; } }); return errors.filter((error) => !error.isValid); }; // eslint-disable-next-line complexity const checkCertificatedValidation = (request) => { const invalidEmail = request?.emailCertificationStatus === 'INITIAL'; const invalidSmsInternalCertification = request?.smsCertificationStatus === 'INITIAL'; const invalidSmsExternalAuthentication = request?.smsCertificationStatus === 'SMS_AUTHENTICATION' && !request?.ci; if (invalidEmail || invalidSmsInternalCertification || invalidSmsExternalAuthentication) { EventManager.fire('MODAL_ALERT_OPEN', { noticeType: 'CAUTION', message: `${invalidEmail ? '이메일 인증을 진행해 주세요.' : '휴대폰 인증을 진행해 주세요.'}`, onClose: () => { handleFocusEvent({ containerEl, fields: invalidEmail ? 'email' : 'mobileNo' }); }, }); return false; } const message = request.certificatedNumber?.length ? '인증을 진행해주세요.' : '인증번호를 입력해주세요.'; if (request.certificated && (!request.certificated.value || !request.certificated.isValid)) { EventManager.fire('MODAL_ALERT_OPEN', { noticeType: 'CAUTION', message: `${request.certificated.message ?? message}`, onClose: () => { handleFocusEvent({ containerEl, fields: 'certificatedNumber' }); }, }); return false; } return true; }; const CLICK_EVENT_HANDLER_MAP = { // eslint-disable-next-line complexity EMAIL_CERTIFICATION: async (helper) => { const { profileEmailInformation } = helper.getState(); const isInvalidEmail = profileEmailInformation?.email.value === '@' || !profileEmailInformation?.email.isValid; if (isInvalidEmail) { EventManager.fire('MODAL_ALERT_OPEN', { noticeType: 'CAUTION', message: `${profileEmailInformation?.email.message ?? '이메일을 입력해주세요.'}`, }); return; } if (profileEmailInformation?.emailCertificationStatus === 'INITIAL') { await helper.sendCertificationCode(profileEmailInformation.email.value, 'EMAIL'); EventManager.fire('MODAL_ALERT_OPEN', { noticeType: 'SUCCESS', message: '인증번호가 발송되었습니다.', }); } else { EventManager.fire('MODAL_CONFIRM_OPEN', { noticeType: 'WARNING', message: '인증번호를 재발송하시겠습니까?', onConfirm: async () => { await helper.sendCertificationCode(profileEmailInformation.email.value, 'EMAIL'); EventManager.fire('MODAL_ALERT_OPEN', { noticeType: 'SUCCESS', message: '인증번호가 발송되었습니다.', }); }, }); } }, // eslint-disable-next-line complexity SMS_CERTIFICATION: async (helper) => { const { profileSmsInformation } = helper.getState(); const isInvalidMobileNo = !profileSmsInformation?.mobileNo.value || !profileSmsInformation?.mobileNo.isValid; if (isInvalidMobileNo) { EventManager.fire('MODAL_ALERT_OPEN', { noticeType: 'CAUTION', message: `${profileSmsInformation?.mobileNo.message ?? '휴대폰 번호를 입력해주세요.'}`, }); return; } if (profileSmsInformation?.smsCertificationStatus === 'INITIAL') { await helper.sendCertificationCode(profileSmsInformation.mobileNo.value, 'SMS'); EventManager.fire('MODAL_ALERT_OPEN', { noticeType: 'SUCCESS', message: '인증번호가 발송되었습니다.', }); } else { EventManager.fire('MODAL_CONFIRM_OPEN', { noticeType: 'WARNING', message: '인증번호를 재발송하시겠습니까?', onConfirm: async () => { await helper.sendCertificationCode(profileSmsInformation.mobileNo.value, 'SMS'); EventManager.fire('MODAL_ALERT_OPEN', { noticeType: 'SUCCESS', message: '인증번호가 발송되었습니다.', }); }, }); } }, AUTHENTICATION_BY_PHONE: () => { EventManager.fire('OPEN_LAYER_MODAL', { name: 'kcp-sms-authentication', data: { type: 'JOIN_TIME' }, onClose: ({ reason, state }) => { if (reason === 'DID_SUBMIT') { ShopbySkin.EventManager.fire('SUCCESS_AUTHENTICATION_SMS', state); } }, }); }, SEARCH_ZIP_CODE: () => { EventManager.fire('OPEN_LAYER_MODAL', { modalAddClass: 'search-zip-code full-modal', name: 'page-zip-code', onClose: ({ reason, state }) => { if (reason === 'DID_SUBMIT') { ShopbySkin.EventManager.fire('SELECT_ZIP_CODE', { moduleKey: 'profile-optional-information', state, }); } }, }); }, SHOW_MANAGER_VIEW: ({ elTarget, helper }) => { const { termsInformation } = helper.getState(); if (!termsInformation) { return; } const mergedTerms = [...termsInformation.terms, ...termsInformation.customTerms]; const selectedTerm = mergedTerms.find((term) => elTarget.getAttribute('shopby-term-id') === term.id.toString()); EventManager.fire('OPEN_LAYER_MODAL', { name: 'term-detail', data: selectedTerm, }); }, SHOW_TERM_DETAIL: ({ elTarget, helper }) => { const { termsInformation } = helper.getState(); if (!termsInformation) { return; } const mergedTerms = [...termsInformation.terms, ...termsInformation.customTerms]; const selectedTerm = mergedTerms.find((term) => elTarget.getAttribute('shopby-term-id') === term.id.toString()); EventManager.fire('OPEN_LAYER_MODAL', { name: 'term-detail', data: selectedTerm, }); }, // eslint-disable-next-line complexity SUBMIT: async (helper) => { const groupNo = document.querySelector(`[id="groupNo"]`).value; //회원그룹 const gradeNo = document.querySelector(`[id="gradeNo"]`).value; //회원등급 const recommenderId = document.querySelector(`[shopby-extra-info-no="62"]`).value //추천인정보 document.querySelector(`[id="recommenderId"]`).value = recommenderId; const flattedRequest = {...flattenRequest(helper), groupNo, gradeNo, recommenderId}; const invalidRequest = checkInvalidProfileForm(flattedRequest); if (invalidRequest?.length) { const [error] = invalidRequest; EventManager.fire('MODAL_ALERT_OPEN', { noticeType: 'CAUTION', message: `${error.message}`, onClose: () => { handleFocusEvent({ containerEl, fields: error.field }); EventManager.fire('INVALID_PROFILE_FORM', { data: invalidRequest, }); }, }); return; } //추천인(사번) 인증여부 확인 const referrer_confirm = document.querySelector(`[id="referrer_confirm_yn"]`); if (referrer_confirm.value !== 'Ok') { EventManager.fire('MODAL_ALERT_OPEN', { noticeType: 'CAUTION', message: `추천인(사번) 조회해주세요.`, onClose: () => { handleFocusEvent({ containerEl, fields: 'certificatedNumber' }); }, }); return false; } //사용자 아이디에 문자가 포함되어있는지 여부 확인 const target = document.querySelector(`[id="member-id"]`); const containsLetter = /[a-zA-Z]/.test(target.value); let message = ""; if (!containsLetter) { message = "아이디는 반드시 하나 이상의 문자가 포함되어야 합니다."; } if (target.value.length <= 6) { message = "아이디는 6자 이상 가능합니다."; } if (message !== "") { EventManager.fire('MODAL_ALERT_OPEN', { noticeType: 'CAUTION', message: `${message}`, onClose: () => { handleFocusEvent({ containerEl, fields: 'member-id' }); }, }); target.value = ""; return; } if (!checkCertificatedValidation(flattedRequest)) { return; } const { data } = await helper.submit(flattedRequest); EventManager.fire('MODAL_ALERT_OPEN', { noticeType: 'SUCCESS', message: '회원가입이 완료되었습니다.', onClose: () => { if (data.memberStatus === 'PENDING') { location.replace('/pages/sign-up/sign-up-pending.html'); } else { location.replace('/pages/sign-up/sign-up-complete.html'); } }, }); }, }; const clickEventListener = ({ target }) => { const action = target.getAttribute('shopby-action'); if (action === 'SHOW_TERM_DETAIL') { CLICK_EVENT_HANDLER_MAP[action]?.({ helper: signUpFormHelper, elTarget: target, }); } else if (action === 'STAFF_VIEW') { const referrerId = document.querySelector(`[shopby-extra-info-no="62"]`); const referrer_confirm = document.querySelector(`[id="referrer_confirm_yn"]`); // url: `https://shop-api.e-ncp.com/profile/id/exist?memberId=${referrerId}`, // 호출할 API URL // url: `https://server-api.e-ncp.com/profile?memberId=${referrerId}`, // 호출할 API URL // "Authorization": "Bearer tKLJXd_P0nHo8toU7w88xEJLDDQ" // 액세스 토큰을 Authorization 헤더에 포함 // headers: { // "Accept": "application/json", // "Version": "1.0", // "Platform": "PC", // "Clientid": "DW9S/K2hejBxUFjiRDZJkA==", // "Language": "ko", // "Accesstoken": "tKLJXd_P0nHo8toU7w88xEJLDDQ" // } if (referrerId.value === "") { EventManager.fire('MODAL_ALERT_OPEN', { noticeType: 'CAUTION', message: `추천인(사번)을 입력해주세요.`, onClose: () => { handleFocusEvent({ containerEl, fields: 'referrerId' }); }, }); return; } const settings = { async: true, crossDomain: true, url: `https://shop-api.e-ncp.com/profile/id/exist?memberId=${referrerId.value}`, method: "GET", // HTTP 메서드 headers: { "Accept": "application/json", "Version": "1.0", "Platform": "PC", "Language": "ko", "Clientid": "DW9S/K2hejBxUFjiRDZJkA==", } }; // fetch API 호출 fetch(settings.url, { method: settings.method, headers: settings.headers }) .then(response => { // console.log('Response Status:', response.status); // 상태 코드 로그 if (!response.ok) { EventManager.fire('MODAL_ALERT_OPEN', { noticeType: 'CAUTION', message: `회원정보가 없습니다.`, onClose: () => { handleFocusEvent({ containerEl, fields: 'extraInfoContents' }); }, }); return; } return response.json(); }) .then(data => { if (data.exist && referrerId.value.length === 6) { referrer_confirm.value = "Ok"; message = "임직원 인증되었습니다."; } else { referrer_confirm.value = ""; referrerId.value = ""; message = "임직원 사번을 입력해주세요."; } EventManager.fire('MODAL_ALERT_OPEN', { noticeType: 'CAUTION', message: `${message}`, onClose: () => { handleFocusEvent({ containerEl, fields: 'extraInfoContents' }); }, }); // console.log(data.exist); return; }) .catch(error => { // console.error('Error:', error); }); } else { CLICK_EVENT_HANDLER_MAP[action]?.(signUpFormHelper); } }; containerEl.addEventListener('click', clickEventListener); const changeEventListener = ({ target }) => { // alert(target.name); if (target.name === "추천인(사번)") { document.querySelector(`[id="referrer_confirm_yn"]`).value = ""; const value = target.value; if (!/^\d+$/.test(value)) { // alert('숫자만 입력 가능합니다.'); document.querySelector(`[shopby-extra-info-no="62"]`).value = ""; document.querySelector(`[id="referrer_confirm_yn"]`).value = ""; } } }; containerEl.addEventListener('change', changeEventListener); })(); /******/ })() ;