"use client"; import { useState } from "react"; import appointmentData from "./appointment.json"; export default function AppointmentPage() { const [selectedType, setSelectedType] = useState("consultation"); const [selectedConsultant, setSelectedConsultant] = useState(""); const [selectedDate, setSelectedDate] = useState(""); const [selectedTime, setSelectedTime] = useState(""); const [selectedOffice, setSelectedOffice] = useState("online"); const [openFaq, setOpenFaq] = useState(null); const [formData, setFormData] = useState({ fullName: "", email: "", phone: "", visaType: "", country: "", travelDate: "", previousVisa: "", notes: "", }); const handleInputChange = ( e: React.ChangeEvent< HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement >, ) => { const { name, value } = e.target; setFormData((prev) => ({ ...prev, [name]: value, })); }; const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); console.log("Appointment booked:", { type: selectedType, consultant: selectedConsultant, date: selectedDate, time: selectedTime, office: selectedOffice, ...formData, }); alert( "Đặt lịch thành công! Chúng tôi sẽ liên hệ xác nhận trong thời gian sớm nhất.", ); }; const toggleFaq = (index: number) => { setOpenFaq(openFaq === index ? null : index); }; const selectedAppointmentType = appointmentData.appointmentTypes.find( (type) => type.id === selectedType, ); const selectedConsultantData = appointmentData.consultants.find( (c) => c.id === selectedConsultant, ); return (
{/* Header */}

{appointmentData.title}

{appointmentData.subtitle}

{/* Benefits */}
{appointmentData.hero.benefits.map((benefit, index) => (

{benefit}

))}
{/* Booking Form */}

Đặt Lịch Hẹn

{/* Appointment Type */}
{appointmentData.appointmentTypes.map((type) => (
setSelectedType(type.id)} >
{type.icon}

{type.name}

{type.popular && ( Phổ biến )}
{type.price}
{type.duration}

{type.description}

))}
{/* Consultant Selection */}
setSelectedConsultant("")} >
Để chúng tôi chọn chuyên gia phù hợp
Dựa trên loại visa và quốc gia bạn quan tâm
{appointmentData.consultants.map((consultant) => (
setSelectedConsultant(consultant.id)} >
👤
{consultant.name}
{consultant.title}
⭐ {consultant.rating} ({consultant.reviews} đánh giá) {consultant.experience}
))}
{/* Date & Time */}
setSelectedDate(e.target.value)} min={new Date().toISOString().split("T")[0]} required className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" />
{/* Office Selection */}
setSelectedOffice("online")} >
💻
Tư vấn online
Video call qua Zoom/Google Meet
{appointmentData.offices.map((office, index) => (
setSelectedOffice(office.name)} >
🏢
Văn phòng {office.name}
{office.address}
{office.hours}
))}
{/* Personal Information */}

Thông Tin Cá Nhân

{appointmentData.formFields.map((field) => (
{field.type === "textarea" ? (