gRPC implementation of a registration working
This commit is contained in:
@@ -2,12 +2,13 @@
|
||||
|
||||
use crossterm::event::{Event, KeyCode};
|
||||
use crate::config::binds::config::Config;
|
||||
use crate::state::state::AppState;
|
||||
use crate::ui::handlers::context::DialogPurpose;
|
||||
use crate::state::state::AppState;
|
||||
use crate::state::pages::auth::AuthState;
|
||||
use crate::state::pages::auth::RegisterState;
|
||||
use crate::services::auth::AuthClient;
|
||||
use crate::modes::handlers::event::EventOutcome;
|
||||
use crate::tui::functions::common::login;
|
||||
use crate::tui::functions::common::{login, register};
|
||||
|
||||
/// Handles key events specifically when a dialog is active.
|
||||
/// Returns Some(Result<EventOutcome, Error>) if the event was handled (consumed),
|
||||
@@ -17,6 +18,7 @@ pub async fn handle_dialog_event(
|
||||
config: &Config,
|
||||
app_state: &mut AppState,
|
||||
auth_state: &mut AuthState,
|
||||
register_state: &mut RegisterState,
|
||||
auth_client: &mut AuthClient,
|
||||
) -> Option<Result<EventOutcome, Box<dyn std::error::Error>>> {
|
||||
if let Event::Key(key) = event {
|
||||
@@ -85,7 +87,32 @@ pub async fn handle_dialog_event(
|
||||
}
|
||||
}
|
||||
}
|
||||
// Add cases for other DialogPurpose variants here if needed
|
||||
DialogPurpose::RegisterSuccess => { // Add this arm
|
||||
match selected_index {
|
||||
0 => { // "OK" button for RegisterSuccess
|
||||
app_state.hide_dialog();
|
||||
// Go back to intro after successful registration dialog
|
||||
let message = register::back_to_main(register_state, app_state).await;
|
||||
return Some(Ok(EventOutcome::Ok(message)));
|
||||
}
|
||||
_ => { // Default for RegisterSuccess
|
||||
app_state.hide_dialog();
|
||||
return Some(Ok(EventOutcome::Ok("Unknown dialog button selected".to_string())));
|
||||
}
|
||||
}
|
||||
}
|
||||
DialogPurpose::RegisterFailed => { // Add this arm
|
||||
match selected_index {
|
||||
0 => { // "OK" button for RegisterFailed
|
||||
app_state.hide_dialog(); // Just dismiss
|
||||
return Some(Ok(EventOutcome::Ok("Register failed dialog dismissed".to_string())));
|
||||
}
|
||||
_ => { // Default for RegisterFailed
|
||||
app_state.hide_dialog();
|
||||
return Some(Ok(EventOutcome::Ok("Unknown dialog button selected".to_string())));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {} // Ignore other general actions when dialog is shown
|
||||
|
||||
@@ -60,6 +60,8 @@ pub async fn handle_navigation_event(
|
||||
(UiContext::Intro, app_state.ui.intro_state.selected_option)
|
||||
} else if app_state.ui.show_login && app_state.ui.focus_outside_canvas {
|
||||
(UiContext::Login, app_state.general.selected_item)
|
||||
} else if app_state.ui.show_register && app_state.ui.focus_outside_canvas {
|
||||
(UiContext::Register, app_state.general.selected_item)
|
||||
} else if app_state.ui.show_admin {
|
||||
(UiContext::Admin, app_state.general.selected_item)
|
||||
} else if app_state.ui.dialog.dialog_show {
|
||||
|
||||
Reference in New Issue
Block a user