better ui
This commit is contained in:
@@ -239,9 +239,8 @@ pub fn get_account_transactions(con: &Connection, ac_id: i64) -> Vec<Transaction
|
||||
if ac_id == 0 {
|
||||
return get_transactions(con);
|
||||
}
|
||||
// println!("allo{}", ac_id);
|
||||
|
||||
let query = "SELECT * FROM Transactions WHERE account_id = :id";
|
||||
let query = "SELECT * FROM Transactions WHERE account_id = :id ORDER BY Date DESC";
|
||||
let mut statement = con.prepare(query).unwrap();
|
||||
statement.bind((":id", ac_id)).unwrap();
|
||||
let mut vec = Vec::<Transaction>::new();
|
||||
@@ -262,7 +261,7 @@ pub fn get_account_transactions(con: &Connection, ac_id: i64) -> Vec<Transaction
|
||||
}
|
||||
|
||||
pub fn get_transactions(con: &Connection) -> Vec<Transaction> {
|
||||
let query = "SELECT * FROM Transactions";
|
||||
let query = "SELECT * FROM Transactions ORDER BY Date DESC";
|
||||
let mut statement = con.prepare(query).unwrap();
|
||||
let mut vec = Vec::<Transaction>::new();
|
||||
|
||||
|
||||
@@ -72,10 +72,11 @@ pub fn ui(frame: &mut Frame, app: &mut App) {
|
||||
};
|
||||
frame.render_widget(Paragraph::new(info).block(info_block), right_layout[0]);
|
||||
|
||||
let trx_header = Row::new(["Date", "Amount", "Description"]);
|
||||
let trx_header = Row::new(["Date", "Type", "Amount", "Description"]);
|
||||
let trx_rows = app.get_list_trx().into_iter().map(|tr| {
|
||||
Row::new([
|
||||
tr.get_date().format("%Y-%m-%d").to_string(),
|
||||
tr.get_type().get_description(),
|
||||
tr.get_amount().to_string(),
|
||||
tr.get_desc(),
|
||||
])
|
||||
@@ -83,6 +84,7 @@ pub fn ui(frame: &mut Frame, app: &mut App) {
|
||||
let widths = [
|
||||
Constraint::Percentage(30),
|
||||
Constraint::Percentage(20),
|
||||
Constraint::Percentage(20),
|
||||
Constraint::Percentage(50),
|
||||
];
|
||||
let trx_table = Table::new(trx_rows, widths)
|
||||
|
||||
Reference in New Issue
Block a user