import AdminDashboardCards from "@/app/(admin)/admin/_components/_dashboard_cards";
import AdminDashboardTabs from "@/app/(admin)/admin/_components/_dashboard_tabs";
import AdminDashboardPanel from "@/app/(admin)/admin/_components/_dasboard_right_panel";
import AdminPageContainer from "@/app/(admin)/_components/_admin_container";
import {
    Breadcrumb,
    BreadcrumbItem,
    BreadcrumbList,
    BreadcrumbPage,
    BreadcrumbSeparator
} from "@/components/ui/breadcrumb";
import {getAdminDashboardData} from "@/lib/backend/api";
import {ClientProfile, PatientProfile} from "@/lib/backend/appwrite_types";


export default async function AdminDashboard() {

    const dashboardData = await getAdminDashboardData()

    return (
        <AdminPageContainer breadcrumbs={
            <Breadcrumb className="hidden md:flex">
                <BreadcrumbList>
                    <BreadcrumbItem>
                        <p>LulamaChat</p>
                    </BreadcrumbItem>
                    <BreadcrumbSeparator/>
                    <BreadcrumbItem>
                        <BreadcrumbPage>Dashboard</BreadcrumbPage>
                    </BreadcrumbItem>
                </BreadcrumbList>
            </Breadcrumb>
        }>

            <div className="grid auto-rows-max items-start gap-4 md:gap-8 lg:col-span-2">

                <AdminDashboardCards
                    total_clients={dashboardData.clientsResponse.total}
                    total_patients={dashboardData.patientResponse.total}/>

                <AdminDashboardTabs
                    recent_clients={dashboardData.clientsResponse.documents as ClientProfile[]}
                    recent_patients={dashboardData.patientResponse.documents as PatientProfile[]}/>

            </div>

            <AdminDashboardPanel
                admins={1}
                clients={dashboardData.clientsResponse.total}
                patients={dashboardData.patientResponse.total}/>

        </AdminPageContainer>
    )
}

export const fetchCache = 'force-no-store';