import Alert from "./components/Alert/Alert";
import Header from "./components/Header/Header";
import UserMenu from "./components/UserMenu/UserMenu";
import ApiServerService from "@core/Services/Api.Server.Service";
import { HomeView } from "@core/Models/Views.model";
import Index from "./components/Home/Index/Index";
import { SystemNotificationsProvider } from "./components/SystemNotificationsProvider/SystemNotificationsProvider";
import EvangelizeBanner from "./components/EvangelizeBanner/EvangelizeBanner";

export const dynamic = "force-dynamic"; // Fuerza la página a ser dinámica

const GetHomeData = async (): Promise<HomeView> => {
    //throw new Error("Error");

    try {
        const home = await ApiServerService.post<HomeView>("views/home", {});
        return home;
    } catch {
        return {} as HomeView;
    }
};

export default async function Home() {
    const homeData = await GetHomeData();
    return (
        <div>
            <Header />
            <SystemNotificationsProvider />
            <Index homeData={homeData} />
            <UserMenu />
            <Alert />
            <EvangelizeBanner variant="popup" delay={4000} />
        </div>
    );
}
