very bald changes, still destroyed

This commit is contained in:
filipriec
2025-04-14 12:07:15 +02:00
parent 2d724876eb
commit 71dabc1e37
7 changed files with 97 additions and 159 deletions

View File

@@ -6,7 +6,6 @@ use crate::components::{
render_status_line,
handlers::sidebar::{self, calculate_sidebar_layout},
form::form::render_form,
admin::{admin_panel::AdminPanelState},
auth::{login::render_login, register::render_register},
};
use crate::config::colors::themes::Theme;
@@ -25,6 +24,7 @@ pub fn render_ui(
auth_state: &mut AuthState,
login_state: &LoginState,
register_state: &RegisterState,
admin_state: &mut AdminState,
theme: &Theme,
is_edit_mode: bool,
total_count: u64,
@@ -68,24 +68,9 @@ pub fn render_ui(
login_state.current_field < 2
);
} else if app_state.ui.show_admin {
// Create temporary AdminPanelState for rendering
let mut admin_state = AdminPanelState::new(
app_state.profile_tree.profiles
.iter()
.map(|p| p.name.clone())
.collect()
);
// Set the selected item - FIXED
if !admin_state.profiles.is_empty() {
let selected_index = admin_state.get_selected_index()
.unwrap_or(0)
.min(admin_state.profiles.len() - 1);
admin_state.list_state.select(Some(selected_index));
}
admin_state.render(
crate::components::admin::admin_panel::render_admin_panel(
f,
admin_state,
main_content_area,
theme,
&app_state.profile_tree,

View File

@@ -61,6 +61,7 @@ pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
&mut auth_state,
&login_state,
&register_state,
&mut admin_state,
&theme,
is_edit_mode,
app_state.total_count,