travail sur add transaction
This commit is contained in:
16
src/main.rs
16
src/main.rs
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user