register form now has optional field role

This commit is contained in:
filipriec
2025-04-11 13:51:05 +02:00
parent 0fd2a589eb
commit cf1aa4fd2a
4 changed files with 26 additions and 7 deletions

View File

@@ -30,6 +30,11 @@ pub async fn save(
} else {
Some(register_state.password_confirmation.clone())
};
let role = if register_state.role.is_empty() {
None
} else {
Some(register_state.role.clone())
};
// Basic client-side validation (example)
if username.is_empty() {
@@ -59,7 +64,7 @@ pub async fn save(
app_state.hide_dialog();
// Call the gRPC register method
match auth_client.register(username, email, password, password_confirmation).await {
match auth_client.register(username, email, password, password_confirmation, role).await {
Ok(response) => {
// Clear fields on success? Optional, maybe wait for dialog confirmation.
// register_state.username.clear();
@@ -117,6 +122,7 @@ pub async fn revert(
register_state.email.clear();
register_state.password.clear();
register_state.password_confirmation.clear();
register_state.role.clear();
register_state.error_message = None;
register_state.set_has_unsaved_changes(false);
register_state.current_field = 0; // Reset focus to first field