mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-30 02:23:47 +00:00
@@ -38,14 +38,13 @@ export default function SubscriptionCardExpired({
|
|||||||
|
|
||||||
const formattedDate = new Date(subscription.end_date).toLocaleDateString();
|
const formattedDate = new Date(subscription.end_date).toLocaleDateString();
|
||||||
|
|
||||||
// Detect DISABLED daily subscription (suspended by system due to insufficient balance)
|
// Detect daily subscription (disabled or expired)
|
||||||
const isDisabledDaily = subscription.status === 'disabled' && subscription.is_daily;
|
const isDaily = subscription.is_daily;
|
||||||
|
const isDisabledDaily = subscription.status === 'disabled' && isDaily;
|
||||||
|
|
||||||
// For disabled daily subs, check if balance covers daily price
|
// For daily subs, check if balance covers daily price; otherwise 100 kopeks minimum
|
||||||
const dailyPrice = subscription.daily_price_kopeks ?? 0;
|
const dailyPrice = subscription.daily_price_kopeks ?? 0;
|
||||||
const hasBalance = isDisabledDaily
|
const hasBalance = isDaily ? balanceKopeks >= dailyPrice && dailyPrice > 0 : balanceKopeks >= 100;
|
||||||
? balanceKopeks >= dailyPrice && dailyPrice > 0
|
|
||||||
: balanceKopeks >= 100;
|
|
||||||
|
|
||||||
const handleQuickRenew = async () => {
|
const handleQuickRenew = async () => {
|
||||||
setIsRenewing(true);
|
setIsRenewing(true);
|
||||||
@@ -56,6 +55,9 @@ export default function SubscriptionCardExpired({
|
|||||||
if (isDisabledDaily) {
|
if (isDisabledDaily) {
|
||||||
// Resume daily subscription via toggle pause endpoint
|
// Resume daily subscription via toggle pause endpoint
|
||||||
await subscriptionApi.togglePause();
|
await subscriptionApi.togglePause();
|
||||||
|
} else if (isDaily && subscription.tariff_id) {
|
||||||
|
// Expired daily tariff — purchase for 1 day
|
||||||
|
await subscriptionApi.purchaseTariff(subscription.tariff_id, 1);
|
||||||
} else {
|
} else {
|
||||||
await subscriptionApi.renewSubscription(30);
|
await subscriptionApi.renewSubscription(30);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -346,6 +346,9 @@
|
|||||||
"daysBeforeExpiry_one": "{{count}} day before expiry",
|
"daysBeforeExpiry_one": "{{count}} day before expiry",
|
||||||
"daysBeforeExpiry_other": "{{count}} days before expiry",
|
"daysBeforeExpiry_other": "{{count}} days before expiry",
|
||||||
"selectPeriod": "Select Period",
|
"selectPeriod": "Select Period",
|
||||||
|
"noPeriodsAvailable": "No available periods for renewal",
|
||||||
|
"noPeriodsAvailableHint": "The administrator has changed this plan's settings. Please choose a different plan to renew your subscription.",
|
||||||
|
"chooseDifferentTariff": "Choose a different plan",
|
||||||
"selectTraffic": "Select Traffic",
|
"selectTraffic": "Select Traffic",
|
||||||
"selectServers": "Select Servers",
|
"selectServers": "Select Servers",
|
||||||
"selectDevices": "Devices",
|
"selectDevices": "Devices",
|
||||||
|
|||||||
@@ -297,6 +297,9 @@
|
|||||||
"daysBeforeExpiry": "روز قبل از انقضا",
|
"daysBeforeExpiry": "روز قبل از انقضا",
|
||||||
"daysBeforeExpiry_other": "{{count}} روز قبل از انقضا",
|
"daysBeforeExpiry_other": "{{count}} روز قبل از انقضا",
|
||||||
"selectPeriod": "انتخاب دوره",
|
"selectPeriod": "انتخاب دوره",
|
||||||
|
"noPeriodsAvailable": "دورهای برای تمدید موجود نیست",
|
||||||
|
"noPeriodsAvailableHint": "مدیر تنظیمات این طرح را تغییر داده است. لطفاً طرح دیگری را برای تمدید اشتراک خود انتخاب کنید.",
|
||||||
|
"chooseDifferentTariff": "انتخاب طرح دیگر",
|
||||||
"selectTraffic": "انتخاب ترافیک",
|
"selectTraffic": "انتخاب ترافیک",
|
||||||
"selectServers": "انتخاب سرورها",
|
"selectServers": "انتخاب سرورها",
|
||||||
"selectDevices": "انتخاب دستگاهها",
|
"selectDevices": "انتخاب دستگاهها",
|
||||||
|
|||||||
@@ -365,6 +365,9 @@
|
|||||||
"daysBeforeExpiry_few": "{{count}} дня до окончания",
|
"daysBeforeExpiry_few": "{{count}} дня до окончания",
|
||||||
"daysBeforeExpiry_many": "{{count}} дней до окончания",
|
"daysBeforeExpiry_many": "{{count}} дней до окончания",
|
||||||
"selectPeriod": "Выберите период",
|
"selectPeriod": "Выберите период",
|
||||||
|
"noPeriodsAvailable": "Нет доступных периодов для продления",
|
||||||
|
"noPeriodsAvailableHint": "Администратор изменил настройки этого тарифа. Выберите другой тариф для продления подписки.",
|
||||||
|
"chooseDifferentTariff": "Выбрать другой тариф",
|
||||||
"selectTraffic": "Выберите трафик",
|
"selectTraffic": "Выберите трафик",
|
||||||
"selectServers": "Выберите серверы",
|
"selectServers": "Выберите серверы",
|
||||||
"selectDevices": "Устройства",
|
"selectDevices": "Устройства",
|
||||||
|
|||||||
@@ -297,6 +297,9 @@
|
|||||||
"daysBeforeExpiry": "到期前天数",
|
"daysBeforeExpiry": "到期前天数",
|
||||||
"daysBeforeExpiry_other": "到期前 {{count}} 天",
|
"daysBeforeExpiry_other": "到期前 {{count}} 天",
|
||||||
"selectPeriod": "选择时长",
|
"selectPeriod": "选择时长",
|
||||||
|
"noPeriodsAvailable": "没有可用的续订周期",
|
||||||
|
"noPeriodsAvailableHint": "管理员已更改此套餐的设置。请选择其他套餐续订您的订阅。",
|
||||||
|
"chooseDifferentTariff": "选择其他套餐",
|
||||||
"selectTraffic": "选择流量",
|
"selectTraffic": "选择流量",
|
||||||
"selectServers": "选择服务器",
|
"selectServers": "选择服务器",
|
||||||
"selectDevices": "选择设备",
|
"selectDevices": "选择设备",
|
||||||
|
|||||||
@@ -1123,6 +1123,33 @@ export default function SubscriptionPurchase() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* No periods available fallback */}
|
||||||
|
{selectedTariff.periods.length === 0 &&
|
||||||
|
!useCustomDays &&
|
||||||
|
!(
|
||||||
|
selectedTariff.custom_days_enabled &&
|
||||||
|
(selectedTariff.price_per_day_kopeks ?? 0) > 0
|
||||||
|
) && (
|
||||||
|
<div className="rounded-xl border border-amber-500/30 bg-amber-500/10 p-4 text-center">
|
||||||
|
<div className="mb-2 text-sm font-medium text-amber-400">
|
||||||
|
{t('subscription.noPeriodsAvailable')}
|
||||||
|
</div>
|
||||||
|
<div className="text-xs text-dark-400">
|
||||||
|
{t('subscription.noPeriodsAvailableHint')}
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
onClick={() => {
|
||||||
|
setShowTariffPurchase(false);
|
||||||
|
setSelectedTariff(null);
|
||||||
|
setSelectedTariffPeriod(null);
|
||||||
|
}}
|
||||||
|
className="btn-secondary mt-3 px-4 py-2 text-sm"
|
||||||
|
>
|
||||||
|
{t('subscription.chooseDifferentTariff')}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Custom days option */}
|
{/* Custom days option */}
|
||||||
{selectedTariff.custom_days_enabled &&
|
{selectedTariff.custom_days_enabled &&
|
||||||
(selectedTariff.price_per_day_kopeks ?? 0) > 0 && (
|
(selectedTariff.price_per_day_kopeks ?? 0) > 0 && (
|
||||||
|
|||||||
Reference in New Issue
Block a user