'use client'; import { useParams, useRouter } from 'next/navigation'; import { useState, useEffect } from 'react'; import PageLayout from '../../../components/PageLayout'; import Icon from '../../../components/Icon'; import { content } from '../../../data/content'; import { contactContent } from '../../../data/pageContent'; export default function ContactPage() { const router = useRouter(); const params = useParams(); const currentLang = typeof params.lang === 'string' ? params.lang : 'en'; // Form state const [formData, setFormData] = useState({ name: '', email: '', phone: '', company: '', subject: '', message: '', }); const [formSubmitted, setFormSubmitted] = useState(false); const [isClient, setIsClient] = useState(false); // Set client-side flag useEffect(() => { setIsClient(true); }, []); // Validate language and redirect if invalid useEffect(() => { const supportedLangs = ['zh-CN', 'zh-TW', 'en', 'ko', 'ja']; if (!supportedLangs.includes(currentLang)) { router.push('/en/contact'); } }, [currentLang, router]); const currentContent = content[currentLang as keyof typeof content] || content.en; const pageContent = contactContent[currentLang as keyof typeof contactContent] || contactContent.en; const handleLanguageChange = (lang: string) => { router.push(`/${lang}/contact`); }; const handleInputChange = ( e: React.ChangeEvent, ) => { const { name, value } = e.target; setFormData((prev) => ({ ...prev, [name]: value })); }; const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); // Here you would typically send the form data to your backend console.log('Form submitted:', formData); setFormSubmitted(true); // Reset form after submission setTimeout(() => { setFormData({ name: '', email: '', phone: '', company: '', subject: '', message: '', }); setFormSubmitted(false); }, 5000); }; return (
{/* Page Header */}

{pageContent.heading}

{pageContent.subheading}

{/* Contact Information */}

{currentLang === 'en' ? 'Contact Information' : currentLang === 'zh-CN' ? '联系信息' : currentLang === 'zh-TW' ? '聯繫信息' : currentLang === 'ko' ? '연락처 정보' : '連絡先情報'}

{currentLang === 'en' ? 'Address' : currentLang === 'zh-CN' ? '地址' : currentLang === 'zh-TW' ? '地址' : currentLang === 'ko' ? '주소' : '住所'}

{pageContent.contactInfo.address}

{currentLang === 'en' ? 'Phone' : currentLang === 'zh-CN' ? '电话' : currentLang === 'zh-TW' ? '電話' : currentLang === 'ko' ? '전화' : '電話'}

{pageContent.contactInfo.phone}

{currentLang === 'en' ? 'Email' : currentLang === 'zh-CN' ? '电子邮箱' : currentLang === 'zh-TW' ? '電子郵箱' : currentLang === 'ko' ? '이메일' : 'メール'}

{pageContent.contactInfo.email}

{currentLang === 'en' ? 'Business Hours' : currentLang === 'zh-CN' ? '营业时间' : currentLang === 'zh-TW' ? '營業時間' : currentLang === 'ko' ? '영업 시간' : '営業時間'}

{pageContent.contactInfo.hours}

{/* Map Placeholder */}

{currentLang === 'en' ? 'Map will be displayed here' : currentLang === 'zh-CN' ? '地图将显示在这里' : currentLang === 'zh-TW' ? '地圖將顯示在這裡' : currentLang === 'ko' ? '지도가 여기에 표시됩니다' : '地図がここに表示されます'}

{/* Contact Form */}

{pageContent.formTitle}

{!isClient ? (
{pageContent.formFields.name.label}
{pageContent.formFields.name.placeholder}
{pageContent.formFields.email.label}
{pageContent.formFields.email.placeholder}
Loading form...
) : formSubmitted ? (
{currentLang === 'en' ? 'Thank you!' : currentLang === 'zh-CN' ? '谢谢!' : currentLang === 'zh-TW' ? '謝謝!' : currentLang === 'ko' ? '감사합니다!' : 'ありがとうございます!'} {' '} {currentLang === 'en' ? 'Your message has been sent. We will contact you soon.' : currentLang === 'zh-CN' ? '您的消息已发送。我们将尽快与您联系。' : currentLang === 'zh-TW' ? '您的訊息已發送。我們將盡快與您聯繫。' : currentLang === 'ko' ? '메시지가 전송되었습니다. 곧 연락 드리겠습니다.' : 'メッセージが送信されました。すぐにご連絡いたします。'}
) : (
)}
); }