"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 } 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 { 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 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") // --------------------------- // 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} 에 연락하여 계정 생성 요청을 하시기 바랍니다.`, }) } } catch (error: any) { console.error(error) toast({ variant: "destructive", title: "오류", description: "서버 액션 호출에 실패했습니다. 잠시 후 다시 시도해주세요.", }) } finally { setIsLoading(false) } } return (
{/* Left BG 이미지 영역 */}
{/* Top bar */}
{/* logo */} eVCP
{/* Remove 'absolute right-4 top-4 ...', just use buttonVariants */} Login

{t("heading")}

{t("subheading")}

{/* 언어 선택 Dropdown */}
handleChangeLanguage(value)} > {languages.map((v) => ( {t(v.labelKey)} ))}

{t("agreement")}{" "} {t("termsOfService")} {" "} {t("and")}{" "} {t("privacyPolicy")} .

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

“{t("blockquote")}”

{/* */}
) }