do not show account details if there are no accounts

This commit is contained in:
Sebastian Hugentobler 2022-03-26 17:17:43 +01:00
parent 9e37ddc955
commit 36e35768c1
Signed by: shu
GPG Key ID: BB32CF3CA052C2F0
2 changed files with 11 additions and 5 deletions

View File

@ -40,9 +40,13 @@ impl Component for Accounts {
fn view(&self, ctx: &Context<Self>) -> Html {
html! {
<>
<ul class={classes!("accounts")}>
{ for ctx.props().account_nrs.iter().map(|e| self.account_entry(e, &ctx.props().selected_nr, ctx)) }
</ul>
if ctx.props().account_nrs.is_empty() {
<h2>{"No accounts"}</h2>
} else {
<ul class={classes!("accounts")}>
{ for ctx.props().account_nrs.iter().map(|e| self.account_entry(e, &ctx.props().selected_nr, ctx)) }
</ul>
}
</>
}
}

View File

@ -100,8 +100,10 @@ impl Component for Main {
{"welcome to your vaults"}
</h1>
<div class={classes!("inner-content")}>
<Accounts account_nrs={self.account_nrs.clone()} selected_nr={self.selected_nr.clone()} />
<Account balance={self.selected_balance} owner={self.selected_owner.clone()} nr={self.selected_nr.clone()} account_nrs={self.account_nrs.clone()} />
<Accounts account_nrs={self.account_nrs.clone()} selected_nr={self.selected_nr.clone()} />
if !self.account_nrs.is_empty() {
<Account balance={self.selected_balance} owner={self.selected_owner.clone()} nr={self.selected_nr.clone()} account_nrs={self.account_nrs.clone()} />
}
</div>
</main>
</>