Skip to content

Commit

Permalink
Removes hardcoded 'Wallet' from match (#164)
Browse files Browse the repository at this point in the history
* Removes hardcoded 'Wallet' from match

* Modify pattern with two unique options

* replace match for let else
  • Loading branch information
ail3ngrimaldi authored Oct 31, 2024
1 parent 42de5ff commit 64998e4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
17 changes: 9 additions & 8 deletions src/components/molecules/actions/members.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@ pub fn MembersAction(props: VotingProps) -> Element {
}
},
on_change: move |event: ComboInputValue| {
let medium = match event.option {
ComboInputOption::Dropdown(value) => {
match value.key.as_str() {
"Wallet" => MediumOptions::Wallet,
_ => todo!()
}
},
_ => todo!()
let ComboInputOption::Dropdown(value) = event.option else {
return;
};

let invite_wallet = translate!(i18, "onboard.invite.form.wallet.label");
let medium = if value.key == invite_wallet {
MediumOptions::Wallet
} else {
return;
};
if let ActionItem::AddMembers(ref mut meta) = initiative.get_action(props.index) {
meta.members[index_meta] = MemberItem { medium, account: event.input };
Expand Down
17 changes: 9 additions & 8 deletions src/components/molecules/onboarding/invite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,15 @@ pub fn OnboardingInvite() -> Element {
MediumOptions::Wallet => translate!(i18, "onboard.invite.form.wallet.placeholder"),
},
on_change: move |event: ComboInputValue| {
let medium = match event.option {
ComboInputOption::Dropdown(value) => {
match value.key.as_str() {
"Wallet" => MediumOptions::Wallet,
_ => todo!()
}
},
_ => todo!()
let ComboInputOption::Dropdown(value) = event.option else {
return;
};

let invite_wallet = translate!(i18, "onboard.invite.form.wallet.label");
let medium = if value.key == invite_wallet {
MediumOptions::Wallet
} else {
return;
};

onboard.update_invitation(index, InvitationItem { medium, account: event.input });
Expand Down

0 comments on commit 64998e4

Please sign in to comment.