Fix error component, add to all pages
Some checks failed
Build Crate / build (push) Failing after 1m48s

This commit is contained in:
2024-08-29 22:43:55 -04:00
parent d523373b8e
commit 510158f381
4 changed files with 16 additions and 33 deletions

View File

@@ -15,18 +15,19 @@ pub struct ErrorBlockProps {
error: RcSignal<String>,
}
#[component]
pub fn ErrorBlock<G: Html>(cx: Scope, props: ErrorBlockProps) -> View<G> {
let is_empty = create_selector(cx, || props.error.get().is_empty());
#[component(inline_props)]
pub fn ErrorBlock<'a, G: Html>(cx: Scope<'a>, error: RcSignal<String>) -> View<G> {
let error = create_ref(cx, error);
let is_empty = create_selector(cx, || error.get().is_empty());
view! { cx,
(match *is_empty.get() {
(match !(*is_empty.get()) {
true => { view!{cx,
div (role="alert") {
div (class="bg-red-500 text-white font-bold rounded-t px-4 py-2") {
"Error"
}
div (class="border border-t-0 border-red-400 rounded-b bg-red-100 px-4 py-3 text-red-700"){
p {(*props.error.get())}
p {(*error.get())}
}
}
}},