feat: added category management

This commit is contained in:
Andrew Rioux
2025-01-31 00:04:54 -05:00
parent b381261cea
commit 66b59531c5
6 changed files with 381 additions and 29 deletions
+13 -2
View File
@@ -28,6 +28,18 @@ fn format_delta(time: chrono::TimeDelta) -> String {
}
}
#[derive(Clone, Debug, Serialize, Deserialize, Eq)]
pub struct User {
pub user_id: i64,
pub user_name: String,
}
impl std::cmp::PartialEq for User {
fn eq(&self, other: &Self) -> bool {
self.user_id == other.user_id
}
}
#[derive(Clone, Serialize, Deserialize)]
pub struct DbUser {
user_id: i64,
@@ -250,9 +262,8 @@ async fn add_user(name: String, password: String) -> Result<(), ServerFnError> {
#[component]
pub fn UserView() -> impl IntoView {
#[cfg(feature = "hydrate")]
Effect::new(move || {
let user = expect_context::<ReadSignal<Option<crate::app::User>>>();
let user = expect_context::<ReadSignal<Option<User>>>();
if user.get().is_none() {
let navigate = leptos_router::hooks::use_navigate();
navigate("/login?next=users", Default::default());