From d8b747357693d7d62011b0a017358b57dff5190f Mon Sep 17 00:00:00 2001 From: Nickiel12 Date: Mon, 25 Sep 2023 19:53:30 -0700 Subject: [PATCH] added user input to paycheck-quick entry --- src/uis/quick_transaction/paycheck.rs | 28 ++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/uis/quick_transaction/paycheck.rs b/src/uis/quick_transaction/paycheck.rs index f88a41d..20c70e2 100644 --- a/src/uis/quick_transaction/paycheck.rs +++ b/src/uis/quick_transaction/paycheck.rs @@ -60,7 +60,7 @@ impl QuickPaycheckState { f, split_body[4], "Gross:", - &state.net_amount, + &state.gross_amount, state.selected == SelectedEntry::Gross, ); } @@ -68,7 +68,7 @@ impl QuickPaycheckState { pub fn handle_event(event: KeyEvent, app: &mut App) { if event.kind == KeyEventKind::Press { match event.code { - KeyCode::Up => { + KeyCode::Up | KeyCode::BackTab => { match app.states.quick_transactions.paycheck_state.selected { SelectedEntry::Net => { app.states.quick_transactions.paycheck_state.selected = SelectedEntry::Execute; @@ -81,7 +81,7 @@ impl QuickPaycheckState { } } } - KeyCode::Down => { + KeyCode::Down | KeyCode::Tab => { match app.states.quick_transactions.paycheck_state.selected { SelectedEntry::Net => { app.states.quick_transactions.paycheck_state.selected = SelectedEntry::Gross; @@ -94,6 +94,28 @@ impl QuickPaycheckState { } } } + KeyCode::Char(value) => { + match app.states.quick_transactions.paycheck_state.selected { + SelectedEntry::Net => { + app.states.quick_transactions.paycheck_state.net_amount.push(value); + } + SelectedEntry::Gross => { + app.states.quick_transactions.paycheck_state.gross_amount.push(value); + } + _ => {} + } + } + KeyCode::Backspace => { + match app.states.quick_transactions.paycheck_state.selected { + SelectedEntry::Net => { + app.states.quick_transactions.paycheck_state.net_amount.pop(); + } + SelectedEntry::Gross => { + app.states.quick_transactions.paycheck_state.gross_amount.pop(); + } + _ => {} + } + } _ => {} } }