// Import ========================================================================================================================
import App from '@/layouts/aia/app-layout';
import SectionLanding from '@/components/aia/section-landing';
import Impact from '@/components/aia/our-impact';
import Discover from '@/components/aia/discover';
import Latest from '@/components/aia/latest';
import AiaPartner from '@/components/aia/aia-partner';
import ContactUsForm from '@/components/aia/contact-us-form';
import { index } from '@vendor-web/js/index.js';
import { wheelController } from '@vendor-web/js/extends';
import React from 'react';
import { Head } from '@inertiajs/react';


type Post = {
    id: number;
    title: string;
    slug: string;
    excerpt: string;
    content: string;
    image_url: string;
    post_type: string;
    status: string;
    published_at: string;
    date: string;
    time?: string;
    address?: string;
    description?: string;
    link?: string;
    categories: Array<{
        id: number;
        name: string;
        slug: string;
    }>;
};

type KpiItem = {
    value: number;
    formatted: string;
};

type KpiData = {
    kpi: {
        annual_conferences: KpiItem;
        programs: KpiItem;
        technical_study_cases: KpiItem;
        trainee_companies: KpiItem;
        trainee: KpiItem;
        industry_user_cases: KpiItem;
        lectures: KpiItem;
        industry_involved: KpiItem;
    };
    updated_at: string | null;
};

type HomeProps = {
    landingEvents: Post[];
    lastests: Post[];
    kpiData: KpiData;
};

export default function Home(
    { landingEvents, lastests, kpiData }: HomeProps
) {
    // console.log('@@@@@@@@@', landingEvents);
    React.useEffect(() => {
        index();
        wheelController();

        // 使用 setTimeout 延遲執行,確保所有 carousel 初始化完成
        const timer = setTimeout(() => {
            window.scrollTo({
                top: 0,
                behavior: 'auto'
            });
        }, 300); // 延遲 300ms,配合 carousel.js 的 200ms timeout
    }, []);
    return (

        <App
            section={null}
        >
            <Head title="Home" />
            <SectionLanding
                landingEvents={landingEvents}
            />
            <div className="pageStickyContainer">
                <Impact kpiData={kpiData} />
            </div>
            <Discover />
            <Latest
                landingEvents={lastests}
            />
            <div className="pageBottomSection">
                <div className="pageStickyContainer">
                    <AiaPartner />
                </div>
                <ContactUsForm />
            </div>

        </App>

    );
}
