only enable transfer button if a valid transfer account is selected

This commit is contained in:
Sebastian Hugentobler 2022-03-26 12:36:06 +01:00
parent 7413f09170
commit 4130d36472
Signed by: shu
GPG Key ID: BB32CF3CA052C2F0

View File

@ -36,6 +36,10 @@ impl Account {
} }
} }
fn is_transfer_account_valid(&self) -> bool {
self.selected_transfer_account().is_some()
}
fn is_amount_valid(&self) -> bool { fn is_amount_valid(&self) -> bool {
self.amount() > 0_f64 self.amount() > 0_f64
} }
@ -157,7 +161,7 @@ impl Component for Account {
<button onclick={on_deposit} class={classes!("account__button")} disabled={!self.amount_valid}>{"deposit"}</button> <button onclick={on_deposit} class={classes!("account__button")} disabled={!self.amount_valid}>{"deposit"}</button>
<button onclick={on_withdraw} class={classes!("account__button")} disabled={!self.amount_valid}>{"withdraw"}</button> <button onclick={on_withdraw} class={classes!("account__button")} disabled={!self.amount_valid}>{"withdraw"}</button>
<button onclick={on_transfer} class={classes!("account__button")} disabled={!self.amount_valid}>{"transfer"}</button> <button onclick={on_transfer} class={classes!("account__button")} disabled={!self.amount_valid || !self.is_transfer_account_valid()}>{"transfer"}</button>
</fieldset> </fieldset>
</section> </section>
</> </>