From 833393cb3a6426121b3a6e222ac1dc3323750d05 Mon Sep 17 00:00:00 2001 From: Ethan Girouard Date: Mon, 4 Nov 2024 17:11:26 -0500 Subject: [PATCH] Add generic Error component --- src/components/error.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/components/error.rs b/src/components/error.rs index 4691b55..ae2f18a 100644 --- a/src/components/error.rs +++ b/src/components/error.rs @@ -10,6 +10,27 @@ pub fn ServerError( message: TextProp, #[prop(optional, into)] error: Option>, +) -> impl IntoView { + view!{ +
+
+ +

{title}

+
+

{message}

+

{error.map(|error| format!("{}", error))}

+
+ } +} + +#[component] +pub fn Error( + #[prop(optional, into, default="An Error Occurred".into())] + title: TextProp, + #[prop(optional, into)] + message: TextProp, + #[prop(optional, into)] + error: Option, ) -> impl IntoView { view! {