dm: LoginModal 사업자등록번호 입력 수정

This commit is contained in:
2026-08-07 20:59:05 +09:00
parent d07bb6074d
commit 7f1c804a0c
+21 -22
View File
@@ -20,9 +20,24 @@ type FieldKey = "bizNo" | "workerNo" | "pw";
const REGISTER_HREF = "/apply/dmdco";
function isBizNoValid(v: string) {
return /^\d{10}$/.test(v);
return /^\d{10}$/.test(v.replace(/\D/g, ""));
}
const getBusinessNumberDigits = (value: string) =>
value.replace(/\D/g, "").slice(0, 10);
const formatBusinessNumber = (value: string) => {
const normalized = value.replace(/[^\d-]/g, "").slice(0, 12);
const digits = getBusinessNumberDigits(normalized);
if (normalized.endsWith("-") && digits.length === 3) return `${digits}-`;
if (normalized.endsWith("-") && digits.length === 5)
return `${digits.slice(0, 3)}-${digits.slice(3)}-`;
if (digits.length <= 3) return digits;
if (digits.length <= 5) return `${digits.slice(0, 3)}-${digits.slice(3)}`;
return `${digits.slice(0, 3)}-${digits.slice(3, 5)}-${digits.slice(5)}`;
};
function inputCls(opts: { hasError?: boolean; disabled?: boolean }) {
const base =
"h-[48px] w-full rounded-[4px] border px-5 text-[18px] outline-none";
@@ -102,7 +117,7 @@ export default function LoginModal({
const validate = () => {
const next: Partial<Record<FieldKey, string>> = {};
const b = bizNo.trim();
const b = getBusinessNumberDigits(bizNo);
const w = workerNo.trim();
const p = pw.trim();
@@ -122,23 +137,6 @@ export default function LoginModal({
return next;
};
const formatBusinessNumber = (value: string) => {
// 숫자만 추출
const digitsOnly = value.replace(/\D/g, "");
// 10자리까지만 처리
const limitedDigits = digitsOnly.slice(0, 10);
// 3-2-5 형식으로 포맷팅
if (limitedDigits.length <= 3) {
return limitedDigits;
} else if (limitedDigits.length <= 5) {
return `${limitedDigits.slice(0, 3)}-${limitedDigits.slice(3)}`;
} else {
return `${limitedDigits.slice(0, 3)}-${limitedDigits.slice(3, 5)}-${limitedDigits.slice(5)}`;
}
};
const markTouched = (key: FieldKey) =>
setTouched((p) => ({ ...p, [key]: true }));
@@ -154,8 +152,9 @@ export default function LoginModal({
try {
setSubmitting(true);
const businessNumber = getBusinessNumberDigits(bizNo);
const param = {
dmdInfoId: bizNo + (noWorker ? "0000" : workerNo), // 종사업자번호 해당없음 "0000"으로 채움
dmdInfoId: businessNumber + (noWorker ? "0000" : workerNo), // 종사업자번호 해당없음 "0000"으로 채움
dmdAplyPswd: sha512.hex(pw),
};
await actionLogin(param as DemandCompType);
@@ -227,9 +226,9 @@ export default function LoginModal({
사업자 등록번호
</label>
<input
value={formatBusinessNumber(bizNo)}
value={bizNo}
onChange={(e) => {
setBizNo(e.target.value.replace(/\D/g, "").slice(0, 10));
setBizNo(formatBusinessNumber(e.target.value));
setErrors((p) => ({ ...p, bizNo: undefined }));
}}
onBlur={() => {