Skip to content

Commit

Permalink
feat(fe/user/subscribe): Only schools can pay with check
Browse files Browse the repository at this point in the history
  • Loading branch information
MendyBerger committed Aug 2, 2023
1 parent d2ecdbd commit 411dc46
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
17 changes: 10 additions & 7 deletions frontend/apps/crates/entry/user/src/subscribe1/dom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,17 @@ impl Component<Subscribe1> for Rc<Subscribe1> {
secret.map(|_| {
html!("div", {
.class("actions")
.child(html!("button-rect", {
.prop("kind", "text")
.prop("color", "red")
.text("Request other payment method")
.event(clone!(state => move |_: events::Click| {
state.pay_with_check.set(true);
.apply_if(state.plan_type.is_school_plan(), |dom| {
dom.child(html!("button-rect", {
.prop("kind", "text")
.prop("color", "red")
.text("Request other payment method")
.event(clone!(state => move |_: events::Click| {
state.pay_with_check.set(true);
state.plan_type;
}))
}))
}))
})
.child(html!("button-rect", {
.prop("kind", "filled")
.prop("color", "red")
Expand Down
18 changes: 18 additions & 0 deletions shared/rust/src/domain/billing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,24 @@ impl PlanType {
_ => false,
}
}

/// check if is individual plan
#[must_use]
pub const fn is_individual_plan(&self) -> bool {
match self {
Self::IndividualBasicMonthly | Self::IndividualBasicAnnually | Self::IndividualProMonthly | Self::IndividualProAnnually => true,
Self::SchoolLevel1 | Self::SchoolLevel2 | Self::SchoolLevel3 | Self::SchoolLevel4 | Self::SchoolUnlimited => false,
}
}

/// check if is school plan
#[must_use]
pub const fn is_school_plan(&self) -> bool {
match self {
Self::IndividualBasicMonthly | Self::IndividualBasicAnnually | Self::IndividualProMonthly | Self::IndividualProAnnually => false,
Self::SchoolLevel1 | Self::SchoolLevel2 | Self::SchoolLevel3 | Self::SchoolLevel4 | Self::SchoolUnlimited => true,
}
}
}

impl TryFrom<&str> for PlanType {
Expand Down

0 comments on commit 411dc46

Please sign in to comment.