début new account
This commit is contained in:
31
src/entities/trxlist.rs
Normal file
31
src/entities/trxlist.rs
Normal file
@@ -0,0 +1,31 @@
|
||||
use ratatui::widgets::ListState;
|
||||
use sqlite::Connection;
|
||||
|
||||
use crate::{data_layer, entities::*};
|
||||
|
||||
pub struct TrxList {
|
||||
trx: Vec<Transaction>,
|
||||
ac_id: i64,
|
||||
pub state: ListState,
|
||||
}
|
||||
impl TrxList {
|
||||
pub fn new() -> TrxList {
|
||||
let mut list_state = ListState::default();
|
||||
list_state.select_first();
|
||||
return TrxList {
|
||||
trx: Vec::new(),
|
||||
state: list_state,
|
||||
ac_id: 0,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn get_trx(&mut self, ac_id: i64, con: &Connection) -> Vec<Transaction> {
|
||||
if ac_id == -1 {
|
||||
return Vec::new();
|
||||
}
|
||||
if self.trx.iter().count() == 0 || self.ac_id != ac_id {
|
||||
self.trx = data_layer::get_account_transactions(con, ac_id);
|
||||
}
|
||||
return self.trx.clone();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user