diff options
| author | joonhoekim <26rote@gmail.com> | 2025-09-17 19:53:17 +0900 |
|---|---|---|
| committer | joonhoekim <26rote@gmail.com> | 2025-09-17 19:53:17 +0900 |
| commit | 6f29745d35fc5b609b8aae35a63bc89cf68dfe9a (patch) | |
| tree | 41491ebe2579c4725ef63f14e1cd95f960fb5968 | |
| parent | 06064536f55e596b65c1b019ae1b84e7b13b6cb4 (diff) | |
(김준회) 한국업체 법인등록번호 필수값에서 제외, taxId 입력시 10자리 숫자 아니면 한국업체 taxid 아니라고 경고 UI 추가
| -rw-r--r-- | components/login/partner-auth-form.tsx | 38 | ||||
| -rw-r--r-- | components/signup/join-form.tsx | 2 | ||||
| -rw-r--r-- | i18n/locales/en/login.json | 1 | ||||
| -rw-r--r-- | i18n/locales/ko/login.json | 1 |
4 files changed, 34 insertions, 8 deletions
diff --git a/components/login/partner-auth-form.tsx b/components/login/partner-auth-form.tsx index fb8cd8af..10efaec5 100644 --- a/components/login/partner-auth-form.tsx +++ b/components/login/partner-auth-form.tsx @@ -7,7 +7,6 @@ import { useTranslation } from "@/i18n/client" import Link from "next/link" import { Button } from "@/components/ui/button" -import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" import { DropdownMenu, @@ -20,7 +19,6 @@ import { GlobeIcon, ChevronDownIcon, Loader, Ship, LogIn, InfoIcon, HelpCircle } import { languages } from "@/config/language" import { cn } from "@/lib/utils" import { buttonVariants } from "@/components/ui/button" -import { siteConfig } from "@/config/site" import { Tooltip, TooltipContent, @@ -37,11 +35,10 @@ import { checkJoinPortal } from "@/lib/vendors/service" import Image from "next/image" // ↑ 실제 경로 맞춤 수정 (ex: "@/app/[lng]/actions/joinPortal" 등) -interface UserAuthFormProps extends React.HTMLAttributes<HTMLDivElement> { } - -export function CompanyAuthForm({ className, ...props }: UserAuthFormProps) { +export function CompanyAuthForm({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) { const [isLoading, setIsLoading] = React.useState<boolean>(false) const [showInfoBanner, setShowInfoBanner] = React.useState<boolean>(true) + const [taxIdWarning, setTaxIdWarning] = React.useState<boolean>(false) const router = useRouter() const { toast } = useToast() @@ -51,6 +48,11 @@ export function CompanyAuthForm({ className, ...props }: UserAuthFormProps) { const lng = params.lng as string const { t, i18n } = useTranslation(lng, "login") + // 컴포넌트 마운트 시 초기 상태 설정 + React.useEffect(() => { + setTaxIdWarning(false) + }, []) + const handleChangeLanguage = (lang: string) => { const segments = pathname.split("/") segments[1] = lang @@ -69,6 +71,16 @@ export function CompanyAuthForm({ className, ...props }: UserAuthFormProps) { router.push(`/${lng}/partners`); } + // 사업자등록번호 검증 함수 + const validateTaxId = (value: string) => { + // - 제거하고 숫자만 추출 + const numericValue = value.replace(/-/g, '').replace(/\D/g, ''); + // 한국 기업의 사업자등록번호는 10자리 숫자 + const isValidLength = numericValue.length === 10; + setTaxIdWarning(!isValidLength && numericValue.length > 0); + return isValidLength; + } + // --------------------------- // 1) onSubmit -> 서버 액션 호출 // --------------------------- @@ -89,6 +101,9 @@ export function CompanyAuthForm({ className, ...props }: UserAuthFormProps) { return } + // 제출 시에도 검증 수행 + validateTaxId(taxID) + try { // --------------------------- // 2) 서버 액션 호출 @@ -125,8 +140,8 @@ export function CompanyAuthForm({ className, ...props }: UserAuthFormProps) { }) }, 1000); } - } catch (error: any) { - console.error(error) + } catch (error: unknown) { + console.error('Form submission error:', error) toast({ variant: "destructive", title: "오류", @@ -227,11 +242,20 @@ export function CompanyAuthForm({ className, ...props }: UserAuthFormProps) { autoComplete="off" autoCorrect="off" disabled={isLoading} + onChange={(e) => validateTaxId(e.target.value)} className="w-full rounded-md border border-input bg-background px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:opacity-50" /> <p className="text-xs text-muted-foreground"> {t("taxIdHint") || "사업자 등록 번호는 업체 인증에 사용됩니다"} </p> + {taxIdWarning && ( + <div className="flex items-center gap-2 p-2 bg-orange-50 border border-orange-200 rounded-md"> + <InfoIcon className="h-4 w-4 text-orange-600 flex-shrink-0" /> + <p className="text-xs text-orange-700"> + {t("taxIdWarning") || "한국 기업의 사업자등록번호는 10자리 숫자입니다. 외국 기업의 경우 다른 형식으로 입력 가능합니다."} + </p> + </div> + )} </div> <Button type="submit" disabled={isLoading} variant="samsung"> {isLoading && <Loader className="mr-2 h-4 w-4 animate-spin" />} diff --git a/components/signup/join-form.tsx b/components/signup/join-form.tsx index cbf6a2f7..2dd07959 100644 --- a/components/signup/join-form.tsx +++ b/components/signup/join-form.tsx @@ -1562,7 +1562,7 @@ function CompleteVendorForm({ </div> <div> <label className="block text-sm font-medium mb-1"> - {t('corporateRegistrationNumber')} <span className="text-red-500">*</span> + {t('corporateRegistrationNumber')} </label> <Input value={data.corporateRegistrationNumber} diff --git a/i18n/locales/en/login.json b/i18n/locales/en/login.json index a05913b1..95f5cf04 100644 --- a/i18n/locales/en/login.json +++ b/i18n/locales/en/login.json @@ -44,6 +44,7 @@ "registerVendor": "Vendor Registration", "taxIdTooltip": "Please enter your corporate or individual business registration number including dashes (e.g., 123-45-67890)", "taxIdHint": "The business registration number is used for vendor verification", + "taxIdWarning": "Korean companies' business registration numbers should be 10 digits. Foreign companies can use other formats.", "alreadyRegistered": "Already registered? Login here", "registrationInfoTitle": "Vendor Registration Guide", "registrationInfoDescription": "Are you an employee of an already registered vendor? Please use the login button above. If you want to register a new vendor, fill out the form below.", diff --git a/i18n/locales/ko/login.json b/i18n/locales/ko/login.json index f2247c0e..9b66ac83 100644 --- a/i18n/locales/ko/login.json +++ b/i18n/locales/ko/login.json @@ -44,6 +44,7 @@ "registerVendor": "업체 등록 신청", "taxIdTooltip": "법인/개인사업자 사업자등록번호를 '-' 포함하여 입력해주세요 (예: 123-45-67890)", "taxIdHint": "사업자 등록 번호는 업체 인증에 사용됩니다", + "taxIdWarning": "한국 기업의 사업자등록번호는 10자리 숫자입니다. 외국 기업의 경우 다른 형식으로 입력 가능합니다.", "alreadyRegistered": "이미 등록된 업체이신가요? 로그인하기", "registrationInfoTitle": "업체 등록 신청 안내", "registrationInfoDescription": "이미 등록된 업체의 직원이신가요? 상단의 로그인 버튼을 눌러 로그인하세요. 새로운 업체 등록을 원하시면 아래 양식을 작성해주세요.", |
