"use client" import * as React from "react" import { useToast } from "@/hooks/use-toast" import { useRouter, useParams, usePathname } from "next/navigation" 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, DropdownMenuContent, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu" import { GlobeIcon, ChevronDownIcon, Loader, Ship, LogIn, InfoIcon, HelpCircle } from "lucide-react" import { languages } from "@/config/language" import { cn } from "@/lib/utils" import { buttonVariants } from "@/components/ui/button" import { siteConfig } from "@/config/site" import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "@/components/ui/tooltip" import { Alert, AlertDescription, AlertTitle, } from "@/components/ui/alert" import { checkJoinPortal } from "@/lib/vendors/service" import Image from "next/image" // ↑ 실제 경로 맞춤 수정 (ex: "@/app/[lng]/actions/joinPortal" 등) interface UserAuthFormProps extends React.HTMLAttributes { } export function CompanyAuthForm({ className, ...props }: UserAuthFormProps) { const [isLoading, setIsLoading] = React.useState(false) const [showInfoBanner, setShowInfoBanner] = React.useState(true) const router = useRouter() const { toast } = useToast() const params = useParams() || {}; const pathname = usePathname() || ''; const lng = params.lng as string const { t, i18n } = useTranslation(lng, "login") const handleChangeLanguage = (lang: string) => { const segments = pathname.split("/") segments[1] = lang router.push(segments.join("/")) } const currentLanguageText = i18n.language === "ko" ? t("languages.korean") : i18n.language === "ja" ? t("languages.japanese") : t("languages.english") // 로그인 페이지로 이동 const goToLogin = () => { router.push(`/${lng}/partners`); } // --------------------------- // 1) onSubmit -> 서버 액션 호출 // --------------------------- async function onSubmit(event: React.FormEvent) { event.preventDefault() setIsLoading(true) const formData = new FormData(event.currentTarget) const taxID = formData.get("taxid")?.toString().trim() if (!taxID) { toast({ variant: "destructive", title: "오류", description: "Tax ID를 입력해주세요.", }) setIsLoading(false) return } try { // --------------------------- // 2) 서버 액션 호출 // --------------------------- const result = await checkJoinPortal(taxID) if (result.success) { toast({ variant: "default", title: "성공", description: "가입 신청이 가능합니다", }) // 가입 가능 → signup 페이지 이동 router.push(`/partners/signup?taxID=${taxID}`) } else { // 이미 등록된 기업인 경우 - 로그인으로 안내하는 토스트와 함께 추가 액션 제공 toast({ variant: "destructive", title: "가입이 진행 중이거나 완료된 회사", description: `${result.data} 에 연락하여 계정 생성 요청을 하시기 바랍니다.`, }) // 로그인 액션 버튼이 있는 알림 표시 setTimeout(() => { toast({ title: "이미 등록된 회사이신가요?", description: "로그인 페이지로 이동하여 계정에 접속하세요.", action: ( ), }) }, 1000); } } catch (error: any) { console.error(error) toast({ variant: "destructive", title: "오류", description: "서버 액션 호출에 실패했습니다. 잠시 후 다시 시도해주세요.", }) } finally { setIsLoading(false) } } return (
{/* Left BG 이미지 영역 */}
{/* Top bar */}
eVCP
{/* 로그인 버튼 가시성 개선 */} {t("login") || "로그인"}
{/* 정보 알림 배너 - 업체 등록과 로그인의 관계 설명 */} {showInfoBanner && ( {t("registrationInfoTitle") || "업체 등록 신청 안내"} {t("registrationInfoDescription") || "이미 등록된 업체의 직원이신가요? 상단의 로그인 버튼을 눌러 로그인하세요. 새로운 업체 등록을 원하시면 아래 양식을 작성해주세요."} )}

{t("heading") || "업체 등록 신청"}

{t("subheading") || "귀사의 사업자 등록 번호를 입력하여 등록을 시작하세요"}

{t("taxIdTooltip") || "법인/개인사업자 사업자등록번호를 '-' 포함하여 입력해주세요 (예: 123-45-67890)"}

{t("taxIdHint") || "사업자 등록 번호는 업체 인증에 사용됩니다"}

{/* 로그인 안내 링크 추가 */}
{/* 언어 선택 Dropdown */}
handleChangeLanguage(value)} > {languages.map((v) => ( {t(v.labelKey)} ))}

{t("agreement")}{" "} {t("privacyPolicy")} {/* {t("privacyAgreement")}. */}

{/* Right Content */}
{/* Image 컴포넌트로 대체 */}
Background image

“{t("blockquote")}”

{/* */}
) }