import Breadcrumb from "../components/Breadcrumb"; import { PricingData, PricingAPIResponse, Plan, TestimonialItem } from "./types"; const API_URL = process.env.NEXT_PUBLIC_API_URL || "http://localhost:3001"; async function getPricingData(): Promise { try { const res = await fetch(`${API_URL}/api/pricing`, { next: { revalidate: 60 }, // Revalidate every 60 seconds }); if (!res.ok) { throw new Error("Failed to fetch pricing data"); } const response: PricingAPIResponse = await res.json(); return response.data; } catch (error) { console.error("Error fetching pricing data:", error); return null; } } // Component to render a single plan function PlanCard({ plan, index }: { plan: Plan; index: number }) { const styleClass = plan.style === "style-2" ? " style-2" : ""; const buttonStyleClass = plan.style === "style-2" ? " style-2" : ""; return (

{plan.currency} {plan.price} /{plan.period}

{plan.name}
{plan.buttonText}
); } // Component to render star rating function StarRating({ rating }: { rating: number }) { return (
{[...Array(rating)].map((_, i) => ( ))}
); } // Component to render testimonial slide function TestimonialSlide({ item }: { item: TestimonialItem }) { return (

“{item.content}”

{item.name},
{item.role}
); } export default async function PricingPage() { const data = await getPricingData(); // Fallback values if data is not available const pricingSection = data?.pricingSection || { subtitle: "pricing plan", heading: "Flexible Plans to Suit Every Traveler", description: "Choose the plan that fits your visa needs and enjoy expert guidance every step of the way.", }; const plans = data?.plans || { monthly: [], yearly: [], }; const testimonials = data?.testimonials || { subtitle: "What Our Clients Say", heading: "Immigration Success Stories", buttonText: "View All Review", buttonLink: "/contact", buttonIcon: "fa-solid fa-arrow-right", image: "/assets/img/home-3/test-thumb.jpg", items: [], }; const hero = data?.hero || { title: "pricing plan", }; return ( <> {/* Breadcrumb-Wrapper Section Start */} {/* Pricing Section Start */}
{pricingSection.subtitle}

{pricingSection.heading}

{pricingSection.description}

{/* Testimonial Section Start */}
{testimonials.subtitle}

{testimonials.heading}

{testimonials.buttonText}
testimonial
{testimonials.items.map((item, index) => ( ))}
); }