Skip to content

Commit

Permalink
fix: Prevent non-members from viewing pro content; Update account but…
Browse files Browse the repository at this point in the history
…tons
  • Loading branch information
johnnynotsolucky committed Aug 5, 2024
1 parent 01632be commit 9356914
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 24 deletions.
11 changes: 6 additions & 5 deletions frontend/apps/crates/entry/user/src/settings/dom/plan_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ impl SettingsPage {
link.as_ref().map(|link| {
html!("button-rect", {
.prop("href", link)
.prop("style", "width: 196px")
.prop("target", "_blank")
.text("Manage my plan")
})
Expand Down Expand Up @@ -131,12 +132,10 @@ impl SettingsPage {
match frequency {
BillingInterval::Monthly => {
Some(html!("button-rect", {
.prop("style", "width: 196px")
.prop("type", "filled")
.prop("color", "blue")
.text(match plan_type {
Some(PlanType::SchoolLevel1Monthly) => "Get 1 month FREE by switching to annual billing",
_ => "Get extra saving by switching to annual billing"
})
.text("Switch to Annual Billing")
.event(clone!(state, plan_info => move|_ :events::Click| {
spawn_local(clone!(state, plan_info => async move {
let plan_type: PlanType = plan_type.unwrap_ji();
Expand Down Expand Up @@ -173,6 +172,7 @@ impl SettingsPage {
let new_plan_type = plan_type.basic_to_pro();
let billing_interval = plan_type.billing_interval();
Some(html!("button-rect", {
.prop("style", "width: 196px")
.prop("type", "filled")
.prop("color", "blue")
.text(&format!("Switch to Pro {billing_interval}"))
Expand Down Expand Up @@ -277,6 +277,7 @@ impl SettingsPage {
}

Some(html!("button-rect", {
.prop("style", "width: 196px")
.prop("type", "filled")
.prop("color", "blue")
.text(match plan_info.status.is_paused() {
Expand All @@ -294,7 +295,7 @@ impl SettingsPage {
} else {
(
"Pause subscription".to_string(),
"Are you sure you want to pause your subscription?".to_string(),
"Are you sure you want to pause your subscription? No further payment will be taken until you choose to unpause your plan and have full access again.".to_string(),
"Pause".to_string(),
)
};
Expand Down
6 changes: 3 additions & 3 deletions frontend/apps/crates/entry/user/src/welcome/dom.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
use std::rc::Rc;

use super::Welcome;
use dominator::{html, Dom};
use shared::domain::billing::PlanType;
use utils::prelude::HomePricingRoute;
use utils::routes::UserRoute;
use utils::{
prelude::{get_plan_type, get_school_id, get_user_email, get_user_mutable},
routes::{AssetRoute, HomeRoute, Route},
unwrap::UnwrapJiExt,
};

use super::Welcome;

fn get_add_teacher_form_link() -> String {
let user = get_user_mutable();
let user = user.lock_ref();
Expand Down Expand Up @@ -122,7 +122,7 @@ impl Welcome {
.prop("slot", "actions")
.prop("color", "blue")
.prop("kind", "filled")
.prop("href", Route::Home(HomeRoute::Pricing(HomePricingRoute::default())).to_string())
.prop("href", format!("{}#plan", Route::User(UserRoute::Settings).to_string()))
.text("Upgrade account")
}))
})
Expand Down
2 changes: 1 addition & 1 deletion frontend/apps/crates/utils/src/init/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub fn get_plan_tier() -> PlanTier {
.as_ref()
.and_then(|user| user.account_summary.as_ref())
.map(|summary| match summary.subscription_status {
Some(subscription_status) if subscription_status.is_paused() => PlanTier::Free,
Some(subscription_status) if !subscription_status.is_active() => PlanTier::Free,
_ => summary.plan_tier,
})
.unwrap_or_default()
Expand Down
17 changes: 10 additions & 7 deletions frontend/apps/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/apps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dependencies": {
"@rollup/plugin-commonjs": "^22.0.2",
"@rollup/plugin-node-resolve": "^13.1.1",
"@stripe/stripe-js": "^1.54.1",
"@stripe/stripe-js": "^4.1.0",
"@wasm-tool/rollup-plugin-rust": "1.0.7",
"cross-env": "^7.0.3",
"firebase": "^9.6.1",
Expand Down
14 changes: 7 additions & 7 deletions frontend/elements/src/entry/user/profile/landing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ export class _ extends LitElement {
}
@media (min-width: 1024px) {
::slotted([slot=change-to-annual]) {
flex-direction: row;
flex-direction: column;
}
}
::slotted(dialog-overlay) {
Expand Down Expand Up @@ -421,12 +421,6 @@ export class _ extends LitElement {
${ this.showPlan ? html`
<section id="plan">
<h2>${this.planSectionTitle}</h2>
<slot name="portal-link"></slot>
<label class="tags-label">
<span style="grid-column: 1/3;">
Use the 'Manage my plan' button to update credit card details, view your invoice history, or make changes to your plan.
</span>
</label>
<label class="tags-label">
<span class="key">${STR_PLAN}</span>
<div class="value">
Expand Down Expand Up @@ -461,6 +455,12 @@ export class _ extends LitElement {
<slot name="plan-payment-method"></slot>
</div>
</label>
<slot name="portal-link"></slot>
<label class="tags-label">
<span style="grid-column: 1/3;">
Use the 'Manage my plan' button to update credit card details, view your invoice history, or cancel your plan. To make changes to your plan, use the buttons below.
</span>
</label>
<slot name="change-to-annual"></slot>
</section>
` : nothing }
Expand Down

0 comments on commit 9356914

Please sign in to comment.