Skip to content

Commit

Permalink
Merge pull request #442 from gobitfly/NOBIDS/HandleUnknownPremiumProd…
Browse files Browse the repository at this point in the history
…ucts

Improve premium box logic for unknown products
  • Loading branch information
D13ce authored Jun 12, 2024
2 parents 4405bd9 + 1519a4d commit d088f4d
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 d088f4d

Please sign in to comment.