travail sur add transaction

This commit is contained in:
thatscringebro
2026-03-11 16:05:56 -04:00
parent e58387a1bf
commit 461468ff1b
6 changed files with 192 additions and 7 deletions

View File

@@ -4,6 +4,7 @@ mod entities;
mod enums;
mod ui;
use crate::{app::App, enums::*, ui::ui};
use chrono::Local;
use entities::{Account, AccountType, Transaction};
use ratatui::{
Terminal,
@@ -87,6 +88,9 @@ where
}
CurrentWidget::TrxList => {
app.current_screen = CurrentScreen::NewTransaction;
app.new_transaction
.set_account_id(app.acc_list.get_selected_id());
app.new_transaction.set_date(Local::now());
}
_ => {}
},
@@ -104,10 +108,22 @@ where
_ => {}
},
CurrentScreen::NewTransaction => match key.code {
KeyCode::Down => {
app.next_tr_input();
}
KeyCode::Up => {
app.previous_tr_input();
}
KeyCode::Enter => {
app.save_new_tr();
app.current_screen = CurrentScreen::Main;
}
KeyCode::Backspace => {
app.current_input.pop();
}
KeyCode::Char(value) => {
app.current_input.push(value);
}
KeyCode::Esc => {
app.current_screen = CurrentScreen::Main;
app.new_transaction = Transaction::new_empty();