|
|
|
@@ -10,13 +10,13 @@ import { Title, BtnWrapper, TextInput, SelectInput, Label, InputLabel, DatePicke
|
|
|
|
import IconDelete from '../../assets/img/icon/icon-delete.png';
|
|
|
|
import IconDelete from '../../assets/img/icon/icon-delete.png';
|
|
|
|
import CloseIcon from '../../assets/img/icon/icon-close.png';
|
|
|
|
import CloseIcon from '../../assets/img/icon/icon-close.png';
|
|
|
|
|
|
|
|
|
|
|
|
import { HourList, MinuteList, wellType } from '../../assets/data';
|
|
|
|
import { HourList, MinuteList, modalTypes, wellType } from '../../assets/data';
|
|
|
|
|
|
|
|
|
|
|
|
import { useNavigate } from 'react-router-dom';
|
|
|
|
import { useNavigate } from 'react-router-dom';
|
|
|
|
import MailRegistUploadBtn from '../../components/ServiceManage/MailRegistUploadBtn';
|
|
|
|
import MailRegistUploadBtn from '../../components/ServiceManage/MailRegistUploadBtn';
|
|
|
|
import DatePickerComponent from '../../components/common/Date/DatePickerComponent';
|
|
|
|
import DatePickerComponent from '../../components/common/Date/DatePickerComponent';
|
|
|
|
import Modal from '../../components/common/modal/Modal';
|
|
|
|
import Modal from '../../components/common/modal/Modal';
|
|
|
|
import { MailIsItem, MailMultiRegsit, MailSingleRegist } from '../../apis';
|
|
|
|
import { MailCaliumTotalView, MailIsItem, MailMultiRegsit, MailSingleRegist } from '../../apis';
|
|
|
|
|
|
|
|
|
|
|
|
import { authList } from '../../store/authList';
|
|
|
|
import { authList } from '../../store/authList';
|
|
|
|
import { useRecoilValue } from 'recoil';
|
|
|
|
import { useRecoilValue } from 'recoil';
|
|
|
|
@@ -24,12 +24,17 @@ import { useTranslation } from 'react-i18next';
|
|
|
|
import { MailReceiver, RegistInputRow } from '../../styles/ModuleComponents';
|
|
|
|
import { MailReceiver, RegistInputRow } from '../../styles/ModuleComponents';
|
|
|
|
import AuthModal from '../../components/common/modal/AuthModal';
|
|
|
|
import AuthModal from '../../components/common/modal/AuthModal';
|
|
|
|
import { authType } from '../../assets/data';
|
|
|
|
import { authType } from '../../assets/data';
|
|
|
|
|
|
|
|
import { useDataFetch } from '../../utils/hook';
|
|
|
|
|
|
|
|
import { BattleConfigView } from '../../apis/Battle';
|
|
|
|
|
|
|
|
import { currencyCodeTypes } from '../../assets/data/types';
|
|
|
|
|
|
|
|
import { DynamicModal } from '../../components/common';
|
|
|
|
|
|
|
|
|
|
|
|
const MailRegist = () => {
|
|
|
|
const MailRegist = () => {
|
|
|
|
const navigate = useNavigate();
|
|
|
|
const navigate = useNavigate();
|
|
|
|
const userInfo = useRecoilValue(authList);
|
|
|
|
const userInfo = useRecoilValue(authList);
|
|
|
|
const { t } = useTranslation();
|
|
|
|
const { t } = useTranslation();
|
|
|
|
const environment = process.env.REACT_APP_ENV;
|
|
|
|
const environment = process.env.REACT_APP_ENV;
|
|
|
|
|
|
|
|
const token = sessionStorage.getItem('token');
|
|
|
|
|
|
|
|
|
|
|
|
const [doubleSubmitFlag, setDoubleSubmitFlag] = useState(false);
|
|
|
|
const [doubleSubmitFlag, setDoubleSubmitFlag] = useState(false);
|
|
|
|
|
|
|
|
|
|
|
|
@@ -55,6 +60,11 @@ const MailRegist = () => {
|
|
|
|
const [confirmText, setConfirmText] = useState('');
|
|
|
|
const [confirmText, setConfirmText] = useState('');
|
|
|
|
const [alertMessage, setAlertMessage] = useState('');
|
|
|
|
const [alertMessage, setAlertMessage] = useState('');
|
|
|
|
const [loading, setLoading] = useState(false);
|
|
|
|
const [loading, setLoading] = useState(false);
|
|
|
|
|
|
|
|
const [alertMsg, setAlertMsg] = useState('');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const {
|
|
|
|
|
|
|
|
data: caliumTotalData
|
|
|
|
|
|
|
|
} = useDataFetch(() => MailCaliumTotalView(token), [token]);
|
|
|
|
|
|
|
|
|
|
|
|
const [resultData, setResultData] = useState({
|
|
|
|
const [resultData, setResultData] = useState({
|
|
|
|
is_reserve: false,
|
|
|
|
is_reserve: false,
|
|
|
|
@@ -109,7 +119,7 @@ const MailRegist = () => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
item.length === 0 || itemCount.length === 0 ? setIsItemNullValue(true) : setIsItemNullValue(false);
|
|
|
|
item.length === 0 || itemCount.length === 0 ? setIsItemNullValue(true) : setIsItemNullValue(false);
|
|
|
|
|
|
|
|
|
|
|
|
const token = sessionStorage.getItem('token');
|
|
|
|
// const token = sessionStorage.getItem('token');
|
|
|
|
const result = await MailIsItem(token, {item: item});
|
|
|
|
const result = await MailIsItem(token, {item: item});
|
|
|
|
|
|
|
|
|
|
|
|
if(result.data.result === "ERROR"){
|
|
|
|
if(result.data.result === "ERROR"){
|
|
|
|
@@ -183,8 +193,20 @@ const MailRegist = () => {
|
|
|
|
|
|
|
|
|
|
|
|
if (itemIndex !== -1) {
|
|
|
|
if (itemIndex !== -1) {
|
|
|
|
const item_cnt = resultData.item_list[itemIndex].item_cnt;
|
|
|
|
const item_cnt = resultData.item_list[itemIndex].item_cnt;
|
|
|
|
|
|
|
|
if(resource === currencyCodeTypes.calium){
|
|
|
|
|
|
|
|
if((Number(resourceCount) + Number(item_cnt)) > caliumTotalData){
|
|
|
|
|
|
|
|
setAlertMsg(t('MAIL_ITEM_CALIUM_TOTAL_OVER_WARNING'))
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
resultData.item_list[itemIndex].item_cnt = Number(item_cnt) + Number(resourceCount);
|
|
|
|
resultData.item_list[itemIndex].item_cnt = Number(item_cnt) + Number(resourceCount);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if(resource === currencyCodeTypes.calium){
|
|
|
|
|
|
|
|
if(Number(resourceCount) > caliumTotalData){
|
|
|
|
|
|
|
|
setAlertMsg(t('MAIL_ITEM_CALIUM_TOTAL_OVER_WARNING'))
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
const name = wellType.find(well => well.value === resource).name;
|
|
|
|
const name = wellType.find(well => well.value === resource).name;
|
|
|
|
const newItem = { item: resource, item_cnt: resourceCount, item_name: name };
|
|
|
|
const newItem = { item: resource, item_cnt: resourceCount, item_name: name };
|
|
|
|
resultData.item_list.push(newItem);
|
|
|
|
resultData.item_list.push(newItem);
|
|
|
|
@@ -266,19 +288,33 @@ const MailRegist = () => {
|
|
|
|
|
|
|
|
|
|
|
|
const handleRegistMail = async () => {
|
|
|
|
const handleRegistMail = async () => {
|
|
|
|
setLoading(true);
|
|
|
|
setLoading(true);
|
|
|
|
const token = sessionStorage.getItem('token');
|
|
|
|
await MailSingleRegist(token, resultData).then(data => {
|
|
|
|
const message = await MailSingleRegist(token, resultData);
|
|
|
|
setLoading(false);
|
|
|
|
|
|
|
|
handleSubmitModal();
|
|
|
|
if (message.data.data.message === t('EXCEL_SELECT')) {
|
|
|
|
console.log(data);
|
|
|
|
setConfirmText('파일 내 중복된 유저 정보가 있습니다. \n 파일을 다시 확인 후 이용해주세요.');
|
|
|
|
if(data.result === "ERROR"){
|
|
|
|
} else if (message.data.data.message === '저장 하였습니다.') {
|
|
|
|
if(data.data.message === "ERROR_MAIL_ITEM_CALIUM_OVER"){
|
|
|
|
setConfirmText('우편이 정상 등록되었습니다.');
|
|
|
|
setAlertMsg(t('MAIL_ITEM_CALIUM_TOTAL_OVER_WARNING'));
|
|
|
|
} else {
|
|
|
|
}else if(data.data.message === "NOT_EXIT_EXCEL"){
|
|
|
|
setConfirmText(message.data.data.message);
|
|
|
|
setAlertMsg(t('EXCEL_SELECT'));
|
|
|
|
}
|
|
|
|
}else if(data.data.message === "GUID_CHECK"){
|
|
|
|
setLoading(false);
|
|
|
|
setAlertMsg(t('WARNING_GUID_CHECK'));
|
|
|
|
handleCompleteModal();
|
|
|
|
}else if(data.data.message === "NICKNAME_CHECK"){
|
|
|
|
handleSubmitModal();
|
|
|
|
setAlertMsg(t('WARNING_NICKNAME_CHECK'));
|
|
|
|
|
|
|
|
}else if(data.data.message === "EMAIL_CHECK"){
|
|
|
|
|
|
|
|
setAlertMsg(t('WARNING_EMAIL_CHECK'));
|
|
|
|
|
|
|
|
}else if(data.data.message === "USERTYPE_CHECK_EXCEL") {
|
|
|
|
|
|
|
|
setAlertMsg(t('WARNING_TYPE_CHECK'));
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
setAlertMsg(data.data.message);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
setConfirmText('우편이 정상 등록되었습니다.');
|
|
|
|
|
|
|
|
handleCompleteModal();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}).catch(error => {
|
|
|
|
|
|
|
|
setAlertMsg(t('API_FAIL'));
|
|
|
|
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const handleSingleBtn = () => {
|
|
|
|
const handleSingleBtn = () => {
|
|
|
|
@@ -524,9 +560,11 @@ const MailRegist = () => {
|
|
|
|
<option value="19010001">골드</option>
|
|
|
|
<option value="19010001">골드</option>
|
|
|
|
<option value="19010002">사파이어</option>
|
|
|
|
<option value="19010002">사파이어</option>
|
|
|
|
<option value="19010005">루비</option>
|
|
|
|
<option value="19010005">루비</option>
|
|
|
|
|
|
|
|
<option value="19010003">칼리움</option>
|
|
|
|
</SelectInput>
|
|
|
|
</SelectInput>
|
|
|
|
<TextInput placeholder="수량" type="number" value={resourceCount} onChange={e => handleResourceCount(e)} width="200px" />
|
|
|
|
<TextInput placeholder="수량" type="number" value={resourceCount} onChange={e => handleResourceCount(e)} width="200px" />
|
|
|
|
<Button text="추가" theme={resourceCount.length === 0 || resource.length === 0 ? 'disable' : 'search'} handleClick={handleResourceList} width="100px" height="35px" />
|
|
|
|
<Button text="추가" theme={resourceCount.length === 0 || resource.length === 0 ? 'disable' : 'search'} handleClick={handleResourceList} width="100px" height="35px" />
|
|
|
|
|
|
|
|
{resource === currencyCodeTypes.calium && <Label>(잔여 수량: {caliumTotalData})</Label>}
|
|
|
|
</InputItem>
|
|
|
|
</InputItem>
|
|
|
|
{isItemNullValue && <SearchBarAlert $marginTop="15px">필수값을 입력해주세요.</SearchBarAlert>}
|
|
|
|
{isItemNullValue && <SearchBarAlert $marginTop="15px">필수값을 입력해주세요.</SearchBarAlert>}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -588,10 +626,7 @@ const MailRegist = () => {
|
|
|
|
type="submit"
|
|
|
|
type="submit"
|
|
|
|
size="large"
|
|
|
|
size="large"
|
|
|
|
width="100%"
|
|
|
|
width="100%"
|
|
|
|
handleClick={() => {
|
|
|
|
handleClick={() => {handleRegistMail();}}
|
|
|
|
doubleSubmitFlag || handleRegistMail();
|
|
|
|
|
|
|
|
setDoubleSubmitFlag(true);
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</BtnWrapper>
|
|
|
|
</BtnWrapper>
|
|
|
|
</Modal>
|
|
|
|
</Modal>
|
|
|
|
@@ -630,6 +665,13 @@ const MailRegist = () => {
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</BtnWrapper>
|
|
|
|
</BtnWrapper>
|
|
|
|
</Modal>
|
|
|
|
</Modal>
|
|
|
|
|
|
|
|
{/* 경고 모달 */}
|
|
|
|
|
|
|
|
<DynamicModal
|
|
|
|
|
|
|
|
modalType={modalTypes.completed}
|
|
|
|
|
|
|
|
view={alertMsg ? 'view' : 'hidden'}
|
|
|
|
|
|
|
|
modalText={alertMsg}
|
|
|
|
|
|
|
|
handleSubmit={() => setAlertMsg('')}
|
|
|
|
|
|
|
|
/>
|
|
|
|
{loading && <Loading/>}
|
|
|
|
{loading && <Loading/>}
|
|
|
|
</>
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
|