use crate::context::use_clerk_context;
use dioxus::prelude::*;
#[component]
pub fn SignedIn(
#[props(default = true)]
treat_pending_as_signed_out: bool,
children: Element,
) -> Element {
let ctx = use_clerk_context();
let auth = ctx.auth.read();
if auth
.resolve_pending(treat_pending_as_signed_out)
.should_render_signed_in()
{
rsx! { {children} }
} else {
rsx! {}
}
}
#[component]
pub fn SignedInWhenLoaded(
#[props(default = rsx! {})]
fallback: Element,
#[props(default = true)]
treat_pending_as_signed_out: bool,
children: Element,
) -> Element {
let ctx = use_clerk_context();
let auth = ctx.auth.read();
let auth = auth.resolve_pending(treat_pending_as_signed_out);
let load_error = ctx.load_error.read();
if auth.is_loaded() && auth.should_render_signed_in() {
rsx! { {children} }
} else if !auth.is_loaded() && !auth.should_render_signed_out() && load_error.is_none() {
fallback
} else {
rsx! {}
}
}