user-auth store frontend css v1

This commit is contained in:
2023-01-02 17:09:16 +05:30
parent ca6e6e88ce
commit 9eabcb9e0d
34 changed files with 20189 additions and 6 deletions

View File

@@ -95,6 +95,7 @@ pub struct AppState {
pub dropdownselect: RcSignal<bool>,
pub scrolling: RcSignal<bool>,
pub scrollevent: RcSignal<bool>,
pub warningmsg: RcSignal<String>,
}
async fn login_user(user: AxumUser) -> Result<reqwasm::http::Response, reqwasm::Error> {
@@ -343,7 +344,7 @@ pub fn Header<G: Html>(cx: Scope) -> View<G> {
div(class="header-button"){
(if *app_state.loggedin.get() == false {
view!{ cx,
button(on:click=click_userscreen) { "Register / Login" }
button(on:click=click_userscreen) { i(class="fa-solid fa-user") "Register / Login" }
}
} else {
view!{cx,
@@ -1369,14 +1370,20 @@ async fn LoginScreenUI<G: Html>(cx: Scope<'_>) -> View<G> {
password_hash: (*passval.get()).clone(),
};
spawn_local(async move {
register_user(user)
.await.expect("Couldn't register user");
let resp = register_user(user)
.await;
//.expect("Couldn't register user");
if resp.is_err() {
app_state.warningmsg.set("Failed to register user".to_string());
} else {
app_state.warningmsg.set("Successfully registered user".to_string());
}
});
spawn_local(async move {
app_state.userlist.set(list_users()
.await.expect("Couldn't list user"));
});
app_state.userscreen.set(false);
//app_state.userscreen.set(false);
};
let handle_login = move |_| {
@@ -1401,6 +1408,9 @@ async fn LoginScreenUI<G: Html>(cx: Scope<'_>) -> View<G> {
app_state.useridloggedin.set( *(*app_state.userlist.get()).get(&userstr).unwrap_or(&0));
app_state.userid.set( *(*app_state.userlist.get()).get(&userstr).unwrap_or(&0));
app_state.userscreen.set(false);
app_state.warningmsg.set("".to_string());
} else {
app_state.warningmsg.set("Failed to login".to_string());
}
});
};
@@ -1429,6 +1439,9 @@ async fn LoginScreenUI<G: Html>(cx: Scope<'_>) -> View<G> {
app_state.useridloggedin.set( * ((*app_state.userlist.get()).get(&userstr).unwrap_or(&0)) );
app_state.userid.set( *(*app_state.userlist.get()).get(&userstr).unwrap_or(&0));
app_state.userscreen.set(false);
app_state.warningmsg.set("".to_string());
} else {
app_state.warningmsg.set("Failed to login".to_string());
}
});
}
@@ -1487,6 +1500,13 @@ async fn LoginScreenUI<G: Html>(cx: Scope<'_>) -> View<G> {
button(on:click=handle_login){ "LOGIN" }
button(on:click=handle_register){ "REGISTER" }
button(class="close", on:click=handle_close){ "CLOSE" }
br{}
(if *app_state.warningmsg.get() != "".to_string() {
view!{cx, (*app_state.warningmsg.get())}
} else {
view!{cx, ""}
})
}
}
}else {
@@ -1530,6 +1550,7 @@ fn App<G: Html>(cx: Scope) -> View<G> {
dropdownselect: create_rc_signal(bool::default()),
scrolling: create_rc_signal(bool::default()),
scrollevent: create_rc_signal(bool::default()),
warningmsg: create_rc_signal("".to_string()),
};
provide_context(cx, app_state);

View File

@@ -0,0 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;