login page now in a separate dir
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
// src/components/form.rs
|
||||
pub mod login;
|
||||
pub mod register;
|
||||
|
||||
pub use login::*;
|
||||
pub use register::*;
|
||||
|
||||
@@ -21,7 +21,8 @@ use crate::state::app::state::AppState;
|
||||
use crate::buffer::AppView;
|
||||
use crate::buffer::state::BufferState;
|
||||
use crate::modes::handlers::event::EventOutcome;
|
||||
use crate::tui::functions::common::{login, register};
|
||||
use crate::tui::functions::common::register;
|
||||
use crate::pages::login;
|
||||
use crate::tui::functions::common::add_table::handle_delete_selected_columns;
|
||||
use crate::pages::routing::{Router, Page};
|
||||
use anyhow::Result;
|
||||
|
||||
@@ -29,13 +29,15 @@ use crate::state::{
|
||||
intro::IntroState,
|
||||
},
|
||||
};
|
||||
use crate::tui::common::{register, login};
|
||||
use crate::tui::common::register;
|
||||
use crate::pages::login;
|
||||
use crate::pages::login::logic;
|
||||
use crate::pages::login::logic::LoginResult;
|
||||
use crate::pages::routing::{Router, Page};
|
||||
use crate::dialog;
|
||||
use crate::pages::forms::FormState;
|
||||
use crate::pages::forms::logic::{save, revert, SaveOutcome};
|
||||
use crate::search::state::SearchState;
|
||||
use crate::tui::functions::common::login::LoginResult;
|
||||
use crate::tui::functions::common::register::RegisterResult;
|
||||
use crate::tui::{
|
||||
terminal::core::TerminalCore,
|
||||
@@ -808,7 +810,7 @@ impl EventHandler {
|
||||
match action {
|
||||
"save" => {
|
||||
if let Page::Login(login_state) = &mut router.current {
|
||||
let message = crate::tui::functions::common::login::save(
|
||||
let message = logic::save(
|
||||
auth_state,
|
||||
login_state,
|
||||
&mut self.auth_client,
|
||||
@@ -845,7 +847,7 @@ impl EventHandler {
|
||||
}
|
||||
"save_and_quit" => {
|
||||
let message = if let Page::Login(login_state) = &mut router.current {
|
||||
crate::tui::functions::common::login::save(
|
||||
logic::save(
|
||||
auth_state,
|
||||
login_state,
|
||||
&mut self.auth_client,
|
||||
@@ -874,8 +876,7 @@ impl EventHandler {
|
||||
}
|
||||
"revert" => {
|
||||
let message = if let Page::Login(login_state) = &mut router.current {
|
||||
crate::tui::functions::common::login::revert(login_state, app_state)
|
||||
.await
|
||||
logic::revert(login_state, app_state).await
|
||||
} else if let Page::Register(register_state) = &mut router.current {
|
||||
crate::tui::functions::common::register::revert(
|
||||
register_state,
|
||||
|
||||
9
client/src/pages/login/mod.rs
Normal file
9
client/src/pages/login/mod.rs
Normal file
@@ -0,0 +1,9 @@
|
||||
// src/pages/login/mod.rs
|
||||
|
||||
pub mod state;
|
||||
pub mod ui;
|
||||
pub mod logic;
|
||||
|
||||
pub use state::LoginState;
|
||||
pub use ui::render_login;
|
||||
pub use logic::*;
|
||||
30
client/src/pages/login/state.rs
Normal file
30
client/src/pages/login/state.rs
Normal file
@@ -0,0 +1,30 @@
|
||||
// src/pages/login/state.rs
|
||||
|
||||
use canvas::AppMode;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct LoginState {
|
||||
pub username: String,
|
||||
pub password: String,
|
||||
pub error_message: Option<String>,
|
||||
pub current_field: usize,
|
||||
pub current_cursor_pos: usize,
|
||||
pub has_unsaved_changes: bool,
|
||||
pub login_request_pending: bool,
|
||||
pub app_mode: AppMode,
|
||||
}
|
||||
|
||||
impl Default for LoginState {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
username: String::new(),
|
||||
password: String::new(),
|
||||
error_message: None,
|
||||
current_field: 0,
|
||||
current_cursor_pos: 0,
|
||||
has_unsaved_changes: false,
|
||||
login_request_pending: false,
|
||||
app_mode: AppMode::Edit,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// src/components/auth/login.rs
|
||||
// src/pages/login/ui.rs
|
||||
|
||||
use crate::{
|
||||
config::colors::themes::Theme,
|
||||
@@ -2,3 +2,4 @@
|
||||
|
||||
pub mod routing;
|
||||
pub mod forms;
|
||||
pub mod login;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// src/tui/functions/common.rs
|
||||
|
||||
pub mod login;
|
||||
pub mod logout;
|
||||
pub mod register;
|
||||
pub mod add_table;
|
||||
|
||||
@@ -3,10 +3,11 @@
|
||||
use crate::components::{
|
||||
admin::add_logic::render_add_logic,
|
||||
admin::render_add_table,
|
||||
auth::{login::render_login, register::render_register},
|
||||
auth::register::render_register,
|
||||
intro::intro::render_intro,
|
||||
render_background,
|
||||
};
|
||||
use crate::pages::login::render_login;
|
||||
use crate::bottom_panel::{
|
||||
command_line::render_command_line,
|
||||
status_line::render_status_line,
|
||||
|
||||
@@ -21,10 +21,10 @@ use crate::buffer::state::AppView;
|
||||
use crate::state::app::state::AppState;
|
||||
use crate::tui::terminal::{EventReader, TerminalCore};
|
||||
use crate::ui::handlers::render::render_ui;
|
||||
use crate::tui::functions::common::login::LoginResult;
|
||||
use crate::pages::login;
|
||||
use crate::pages::login::LoginResult;
|
||||
use crate::tui::functions::common::register::RegisterResult;
|
||||
use crate::ui::handlers::context::DialogPurpose;
|
||||
use crate::tui::functions::common::login;
|
||||
use crate::tui::functions::common::register;
|
||||
use crate::utils::columns::filter_user_columns;
|
||||
use canvas::keymap::KeyEventOutcome;
|
||||
|
||||
Reference in New Issue
Block a user