- 링크결제 API 수정
- 지급대행 수정
This commit is contained in:
@@ -8,20 +8,22 @@ import {useNavigate} from '@/shared/lib/hooks/use-navigate';
|
||||
import {PATHS} from "@/shared/constants/paths";
|
||||
import { IdentityType, Language } from '@/entities/additional-service/model/types';
|
||||
import { LinkContentType, LinkPaymentFormData, LinkPaymentSendMethod } from '@/entities/additional-service/model/link-pay/types';
|
||||
import { useStore } from '@/shared/model/store';
|
||||
import moment from 'moment';
|
||||
|
||||
|
||||
|
||||
export const LinkPaymentApplyPage = () => {
|
||||
const { navigate } = useNavigate();
|
||||
|
||||
const userMid = useStore.getState().UserStore.mid;
|
||||
const [processStep, setProcessStep] = useState<ProcessStep>(ProcessStep.One);
|
||||
const [formData, setFormData] = useState<LinkPaymentFormData>({
|
||||
mid: 'nictest00m',
|
||||
mid: userMid,
|
||||
sendMethod: LinkPaymentSendMethod.SMS,
|
||||
goodsName: '',
|
||||
amount: 0,
|
||||
moid: '',
|
||||
paymentExpiryDate: '',
|
||||
paymentLimitDate: moment().format('YYYY.MM.DD'),
|
||||
buyerName: '',
|
||||
email: '',
|
||||
phoneNumber: '',
|
||||
@@ -36,10 +38,52 @@ export const LinkPaymentApplyPage = () => {
|
||||
useSetHeaderType(HeaderType.LeftArrow);
|
||||
useSetFooterMode(false);
|
||||
|
||||
// Step1 필수 필드 검증
|
||||
const isStep1Valid = () => {
|
||||
return (
|
||||
formData.mid !== '' &&
|
||||
formData.sendMethod !== '' &&
|
||||
formData.goodsName.trim() !== '' &&
|
||||
formData.amount > 0 &&
|
||||
formData.moid.trim() !== '' &&
|
||||
formData.paymentLimitDate !== ''
|
||||
);
|
||||
};
|
||||
|
||||
// 전화번호 형식 검증
|
||||
const isValidPhoneNumber = (phone: string) => {
|
||||
const phoneRegex = /^01[0|1|6|7|8|9][0-9]{7,8}$/;
|
||||
return phoneRegex.test(phone);
|
||||
};
|
||||
|
||||
// 이메일 형식 검증
|
||||
const isValidEmail = (email: string) => {
|
||||
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||
return emailRegex.test(email);
|
||||
};
|
||||
|
||||
// Step2 필수 필드 검증
|
||||
const isStep2Valid = () => {
|
||||
const basicFieldsValid = (
|
||||
formData.buyerName.trim() !== '' &&
|
||||
formData.email.trim() !== '' &&
|
||||
isValidEmail(formData.email) &&
|
||||
formData.phoneNumber.trim() !== '' &&
|
||||
isValidPhoneNumber(formData.phoneNumber)
|
||||
);
|
||||
|
||||
// isIdentity가 true면 identityValue도 필수
|
||||
if (formData.isIdentity) {
|
||||
return basicFieldsValid && formData.identityValue.trim() !== '';
|
||||
}
|
||||
|
||||
return basicFieldsValid;
|
||||
};
|
||||
|
||||
const onClickToBack = () => {
|
||||
navigate(-1);
|
||||
};
|
||||
|
||||
setProcessStep(ProcessStep.One);
|
||||
};
|
||||
|
||||
const onClickToChangeTab = () => {
|
||||
if(processStep === ProcessStep.One) {
|
||||
setProcessStep(ProcessStep.Two);
|
||||
@@ -93,7 +137,8 @@ export const LinkPaymentApplyPage = () => {
|
||||
<div className="apply-row">
|
||||
<button
|
||||
className="btn-50 btn-blue flex-1"
|
||||
onClick={() => onClickToChangeTab() }
|
||||
onClick={() => onClickToChangeTab()}
|
||||
disabled={!isStep1Valid()}
|
||||
>다음</button>
|
||||
</div>
|
||||
}
|
||||
@@ -101,11 +146,12 @@ export const LinkPaymentApplyPage = () => {
|
||||
<div className="apply-row two-button">
|
||||
<button
|
||||
className="btn-50 btn-darkgray flex-1"
|
||||
onClick={() => onClickToBack() }
|
||||
>이전</button>
|
||||
onClick={() => onClickToBack()}
|
||||
>이전</button>
|
||||
<button
|
||||
className="btn-50 btn-blue flex-3"
|
||||
onClick={() => onClickToChangeTab() }
|
||||
onClick={() => onClickToChangeTab()}
|
||||
disabled={!isStep2Valid()}
|
||||
>결제 신청</button>
|
||||
</div>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user