Skip to content

Commit

Permalink
Improve premium box logic for unknown products
Browse files Browse the repository at this point in the history
  • Loading branch information
D13ce committed Jun 12, 2024
1 parent 64a22cb commit 1519a4d
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions frontend/components/pricing/PremiumProductBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,15 @@ const planButton = computed(() => {
if (isLoggedIn.value) {
if (premiumSubscription.value) {
if (premiumSubscription.value.product_id === props.product.product_id_monthly || premiumSubscription.value.product_id === props.product.product_id_yearly) {
const subscribedProduct = products.value?.premium_products.find(product => product.product_id_monthly === premiumSubscription.value!.product_id || product.product_id_yearly === premiumSubscription.value!.product_id)
if ((premiumSubscription.value.product_id === props.product.product_id_monthly || premiumSubscription.value.product_id === props.product.product_id_yearly) || subscribedProduct === undefined) {
// (this box is either for the subscribed product) || (the user has an unknown product, possible from V1 or maybe a custom plan)
text = $t('pricing.premium_product.button.manage_plan')
} else if (subscribedProduct.price_per_month_eur < props.product.price_per_month_eur) {
text = $t('pricing.premium_product.button.upgrade')
} else {
const subscribedProduct = products.value?.premium_products.find(product => product.product_id_monthly === premiumSubscription.value!.product_id || product.product_id_yearly === premiumSubscription.value!.product_id)
if (subscribedProduct !== undefined) {
if (subscribedProduct.price_per_month_eur < props.product.price_per_month_eur) {
text = $t('pricing.premium_product.button.upgrade')
} else {
isDowngrade = true
text = $t('pricing.premium_product.button.downgrade')
}
}
isDowngrade = true
text = $t('pricing.premium_product.button.downgrade')
}
}
} else {
Expand Down

0 comments on commit 1519a4d

Please sign in to comment.