use leptos::*;

#[server(SetSession, "/api", "Url", "set_session")]
pub async fn set_session() -> Result<(), ServerFnError> {
    use leptos_actix::extract;
    use actix_session::*;
    use actix_web::web::Data;
    use leptos::logging::log;
    //use crate::DataPok;

    extract(|session: Session| async move {
        log!("extract");
        let pok = session.insert("user", "uzivatel");
        log!("{pok:?}");
    }).await

    //Ok(())
}

#[server(GetSession, "/api")]
pub async fn get_session() -> Result<(), ServerFnError> {
    use leptos_actix::extract;
    use actix_session::*;
    use leptos::logging::log;

    extract(|session: Session| async move {
        log!("extract");
        let pok = session.get::<String>("user");
        log!("{pok:?}");
    }).await

    //Ok(())
}