wrbapp/src/components/layout.rs
2024-09-20 08:22:15 +02:00

40 lines
902 B
Rust

pub mod auth;
pub mod icons;
pub mod navbar;
pub mod topbar;
use crate::Route;
use auth::Auth;
use dioxus::prelude::*;
#[component]
pub fn Global() -> Element {
let user = use_resource(get_user_from_cookie);
use_context_provider(|| user);
rsx! {
match &*user.read_unchecked() {
Some(Ok(_)) => rsx! {
crate::components::layout::topbar::Topbar {}
main {
class: "h-full overflow-y-auto",
Outlet::<Route> {}
}
crate::components::layout::navbar::Navbar {}
},
Some(Err(_)) => rsx! {
Auth { }
},
None => rsx! {
div { "Loading..." }
}
}
}
}
#[server]
async fn get_user_from_cookie() -> Result<(), ServerFnError> {
Err(ServerFnError::new("Not authenticated"))
}