use leptos::prelude::*;
use leptos_router::hooks::use_navigate;
use crate::auth::use_auth;
use crate::components::auth_guard::AuthGuard;
use crate::components::profile::ProfilePageLayout;
use crate::t8s;

#[component]
pub fn ProfilePage() -> impl IntoView {
    let auth = use_auth();
    let navigate = use_navigate();
    
    let on_logout = { 
        let auth = auth.clone();
        Callback::new(move |()| {
            auth.logout();
            navigate("/", Default::default());
        })
    };
    
    view! {
        <AuthGuard redirect_to=t8s!("/en/login")>
            <ProfilePageLayout auth=auth on_logout=on_logout />
        </AuthGuard>
    }
}
