import React from "react"; import Breadcrumb from "../../components/Breadcrumb"; import { type VisaCountry } from "@/api/visa"; interface VisaDetailProps { country: VisaCountry; } export default function VisaDetail({ country }: VisaDetailProps) { // 1. Kiểm tra an toàn (Null Check) // Vì detailedView có kiểu là 'DetailedView | undefined', ta phải chắc chắn nó tồn tại if (!country || !country.detailedView) { return (

Đang tải dữ liệu...

); } const { name: rootName, detailedView } = country; // 2. Bóc tách dữ liệu sau khi đã kiểm tra detailedView tồn tại const { activeCountry: countryData, relatedCountries, contactInfo, } = detailedView; return ( <>
img

{countryData.name}

{countryData.description}

{countryData.additionalInfo}

{countryData.tagline}
{/* Visa Types */}
{countryData.visaTypes?.map((type: any, idx: number) => (
{type.items.map((item: any, itemIdx: number) => (
{item.title}

{item.description}

))}
))}
{/* Visa Process */} {countryData.visaProcess && ( <>

{countryData.visaProcess.title}

    {countryData.visaProcess.steps.map( (process: any, idx: number) => (
  • {process.number}. {process.title} {process.description}
  • ), )}
)} {/* Gallery */} {countryData.gallery && countryData.gallery.length > 0 && (
{countryData.gallery.map( (image: string, idx: number) => (
gallery-img
), )}
)}
{/* Sidebar */}
{relatedCountries?.map((relCountry: any, idx: number) => (
img
{relCountry.name}
))} {/* Contact Box */} {contactInfo && (

{contactInfo.sectionTitle}

{contactInfo.helpText}

{contactInfo.phone.label}:
{contactInfo.phone.value}
{/* Email */}
{contactInfo.email.label}:
{contactInfo.email.value}
{/* Location */}
{contactInfo.location.label}:
{contactInfo.location.address}
)}
); }