fix(server): avoid error when other prices added but logic is not released (#6191)

This commit is contained in:
Brooooooklyn
2024-03-22 08:39:11 +00:00
parent 75355867c7
commit aecc523663
6 changed files with 48 additions and 75 deletions

View File

@@ -108,8 +108,8 @@ const SubscriptionSettings = () => {
? '0'
: price
? recurring === SubscriptionRecurring.Monthly
? String(price.amount / 100)
: String(price.yearlyAmount / 100)
? String((price.amount ?? 0) / 100)
: String((price.yearlyAmount ?? 0) / 100)
: '?';
const t = useAFFiNEI18N();

View File

@@ -51,11 +51,14 @@ const Settings = () => {
const detail = planDetail.get(price.plan);
if (detail?.type === 'fixed') {
detail.price = (price.amount / 100).toFixed(2);
detail.yearlyPrice = (price.yearlyAmount / 100 / 12).toFixed(2);
detail.discount = Math.floor(
(1 - price.yearlyAmount / 12 / price.amount) * 100
).toString();
detail.price = ((price.amount ?? 0) / 100).toFixed(2);
detail.yearlyPrice = ((price.yearlyAmount ?? 0) / 100 / 12).toFixed(2);
detail.discount =
price.yearlyAmount && price.amount
? Math.floor(
(1 - price.yearlyAmount / 12 / price.amount) * 100
).toString()
: undefined;
}
});