diff --git a/src/api/auth.ts b/src/api/auth.ts index 4cf23a5..798d587 100644 --- a/src/api/auth.ts +++ b/src/api/auth.ts @@ -110,7 +110,9 @@ export const authApi = { }, // Request email change - sends verification code to new email - requestEmailChange: async (newEmail: string): Promise<{ message: string }> => { + requestEmailChange: async ( + newEmail: string, + ): Promise<{ message: string; new_email: string; expires_in_minutes: number }> => { const response = await apiClient.post('/cabinet/auth/email/change', { new_email: newEmail, }); diff --git a/src/locales/en.json b/src/locales/en.json index deb3be8..6164f83 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -454,6 +454,7 @@ "trafficUnavailable": "Traffic purchase is not available for your tariff", "unlimited": "Unlimited", "buyTrafficGb": "Buy {{gb}} GB", + "buyUnlimited": "Buy Unlimited", "manageServers": "Server management", "manageServersTitle": "Server management" }, diff --git a/src/locales/fa.json b/src/locales/fa.json index de083f3..0309f95 100644 --- a/src/locales/fa.json +++ b/src/locales/fa.json @@ -328,6 +328,7 @@ "trafficUnavailable": "خرید ترافیک برای اشتراک شما در دسترس نیست", "unlimited": "نامحدود", "buyTrafficGb": "خرید {{gb}} GB", + "buyUnlimited": "خرید نامحدود", "manageServers": "مدیریت سرورها", "manageServersTitle": "مدیریت سرورها" }, diff --git a/src/locales/ru.json b/src/locales/ru.json index 8108aa2..c7123fe 100644 --- a/src/locales/ru.json +++ b/src/locales/ru.json @@ -481,6 +481,7 @@ "trafficUnavailable": "Докупка трафика недоступна для вашего тарифа", "unlimited": "Безлимит", "buyTrafficGb": "Купить {{gb}} ГБ", + "buyUnlimited": "Купить Безлимит", "manageServers": "Управление серверами", "manageServersTitle": "Управление серверами" }, diff --git a/src/locales/zh.json b/src/locales/zh.json index f99142b..2dcae90 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -328,6 +328,7 @@ "trafficUnavailable": "您的套餐不支持购买流量", "unlimited": "无限制", "buyTrafficGb": "购买 {{gb}} GB", + "buyUnlimited": "购买无限流量", "manageServers": "服务器管理", "manageServersTitle": "服务器管理" }, diff --git a/src/pages/Profile.tsx b/src/pages/Profile.tsx index 389c074..b811f23 100644 --- a/src/pages/Profile.tsx +++ b/src/pages/Profile.tsx @@ -181,10 +181,17 @@ export default function Profile() { // Email change mutations const requestEmailChangeMutation = useMutation({ mutationFn: (emailAddr: string) => authApi.requestEmailChange(emailAddr), - onSuccess: () => { + onSuccess: async (data) => { setChangeError(null); - setChangeEmailStep('code'); - setResendCooldown(UI.RESEND_COOLDOWN_SEC); + if (data.expires_in_minutes === 0) { + // Unverified email was replaced directly + setChangeEmailStep('success'); + const updatedUser = await authApi.getMe(); + setUser(updatedUser); + } else { + setChangeEmailStep('code'); + setResendCooldown(UI.RESEND_COOLDOWN_SEC); + } }, onError: (err: { response?: { data?: { detail?: string } } }) => { const detail = err.response?.data?.detail; diff --git a/src/pages/Subscription.tsx b/src/pages/Subscription.tsx index 24a78b2..90cfb8e 100644 --- a/src/pages/Subscription.tsx +++ b/src/pages/Subscription.tsx @@ -1588,7 +1588,7 @@ export default function Subscription() { ))} - {selectedTrafficPackage && + {selectedTrafficPackage !== null && (() => { const selectedPkg = trafficPackages.find( (p) => p.gb === selectedTrafficPackage, @@ -1625,6 +1625,8 @@ export default function Subscription() { + ) : selectedPkg?.is_unlimited ? ( + t('subscription.additionalOptions.buyUnlimited') ) : ( t('subscription.additionalOptions.buyTrafficGb', { gb: selectedTrafficPackage,