-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: add basic console app using dioxus
- Loading branch information
Showing
17 changed files
with
2,454 additions
and
398 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
_version: 2 | ||
id: 202400001 | ||
issue_date: 2024-01-19 | ||
due_date: 2024-02-03 | ||
issuer: | ||
name: Your Name | ||
address: | ||
- YouStreet 123/4 | ||
- 56789 YouCity | ||
- YouCountry | ||
phone: | ||
- +420 111 222 333 | ||
email: | ||
- [email protected] | ||
www: | ||
- www.your-site.com | ||
identifications: | ||
- name: tax | ||
value: CZ1234567890 | ||
- name: registration | ||
value: "987654321" | ||
customer: | ||
name: First Customer | ||
address: | ||
- CoStreet 1234/5 | ||
- 12345 CoCity | ||
- CoCountry | ||
identifications: | ||
- name: registration | ||
value: "123456" | ||
- name: tax | ||
value: CZ123456 | ||
email: | ||
- [email protected] | ||
entries: | ||
- name: IT system management | ||
price: 999.989990234375 | ||
currency: USD | ||
details: | ||
- System maintenance | ||
- DB Optimizations | ||
- Performing security updates | ||
billing: | ||
account_name: Your Name | ||
account_number: 12-1234632/2700 | ||
BIC: AABBCCDDEE | ||
IBAN: MY11 2222 3333 4444 5555 6666 | ||
total: 999.989990234375 | ||
currency: USD | ||
variable_symbol: "202400001" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#![allow(non_snake_case, deprecated)] | ||
|
||
pub mod account; | ||
pub mod app; | ||
pub mod customer; | ||
pub mod entry; | ||
pub mod identity; | ||
pub mod list; | ||
pub mod table; | ||
pub mod invoice; | ||
|
||
pub use app::{App, AppProps}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#![allow(non_snake_case, deprecated)] | ||
|
||
use dioxus::prelude::*; | ||
use std::rc::Rc; | ||
use ucelofka_data::account::Account; | ||
|
||
use crate::actions::account::list; | ||
|
||
use super::{app::UcelofkaTuiCfg, list::List, table::Table}; | ||
|
||
struct CurrentAccountPage(usize); | ||
|
||
#[derive(Clone)] | ||
enum SubPage { | ||
Create, | ||
Account(Account), | ||
} | ||
|
||
impl AsRef<str> for SubPage { | ||
fn as_ref(&self) -> &str { | ||
match self { | ||
Self::Create => "<Create>", | ||
Self::Account(account) => account.name.as_str(), | ||
} | ||
} | ||
} | ||
|
||
#[inline_props] | ||
pub fn Accounts(cx: Scope) -> Element { | ||
use_shared_state_provider(cx, || CurrentAccountPage(0)); | ||
|
||
let account_page = use_shared_state::<CurrentAccountPage>(cx).unwrap(); | ||
|
||
let cfg = use_shared_state::<UcelofkaTuiCfg>(cx).unwrap(); | ||
let accounts = list(cfg.read().path.as_path()).unwrap().accounts; | ||
let items: Vec<SubPage> = vec![SubPage::Create] | ||
.into_iter() | ||
.chain(accounts.iter().map(|e| SubPage::Account(e.clone()))) | ||
.collect(); | ||
|
||
let items_str: Vec<String> = items.iter().map(|e| e.as_ref().to_string()).collect(); | ||
let selected_idx = account_page.read().0; | ||
let selected_account = if selected_idx == 0 { | ||
None | ||
} else { | ||
Some(accounts[selected_idx - 1].clone()) | ||
}; | ||
|
||
cx.render(rsx! { | ||
List { | ||
tabindex: 0, | ||
width: "20%", | ||
items: Rc::new(items_str), | ||
dot: "❱", | ||
idx: account_page.read().0.into(), | ||
onindexupdate: move |i: usize| { | ||
account_page.write().0 = i.into(); | ||
} | ||
} | ||
div { width: "60%", border_width: "1px", height: "100%", justify_content: "center", | ||
if let Some(account) = selected_account { | ||
rsx! { | ||
Table { | ||
width: "100%", | ||
items: vec![ | ||
("Name:", account.name), | ||
("Bank Name:", account.bank_name), | ||
("Account Name:", account.account_name), | ||
("Account number:", account.account_number), | ||
("IBAN:", account.IBAN), | ||
("BIC:", account.BIC), | ||
("Currency:", account.currency), | ||
|
||
] | ||
} | ||
} | ||
} else { | ||
rsx! {span { "TODO CREATE FORM"}} | ||
} | ||
} | ||
}) | ||
} |
Oops, something went wrong.