mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-30 02:23:47 +00:00
Add files via upload
This commit is contained in:
@@ -3,7 +3,7 @@ import { useNavigate, useLocation, useSearchParams } from 'react-router-dom'
|
|||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { useQuery } from '@tanstack/react-query'
|
import { useQuery } from '@tanstack/react-query'
|
||||||
import { useAuthStore } from '../store/auth'
|
import { useAuthStore } from '../store/auth'
|
||||||
import { brandingApi, getCachedBranding, setCachedBranding, preloadLogo, isLogoPreloaded, type BrandingInfo } from '../api/branding'
|
import { brandingApi, getCachedBranding, setCachedBranding, preloadLogo, isLogoPreloaded, type BrandingInfo, type EmailAuthEnabled } from '../api/branding'
|
||||||
import { getAndClearReturnUrl } from '../utils/token'
|
import { getAndClearReturnUrl } from '../utils/token'
|
||||||
import LanguageSwitcher from '../components/LanguageSwitcher'
|
import LanguageSwitcher from '../components/LanguageSwitcher'
|
||||||
import TelegramLoginButton from '../components/TelegramLoginButton'
|
import TelegramLoginButton from '../components/TelegramLoginButton'
|
||||||
@@ -65,7 +65,29 @@ export default function Login() {
|
|||||||
initialData: cachedBranding ?? undefined,
|
initialData: cachedBranding ?? undefined,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Check if email auth is enabled
|
||||||
|
const { data: emailAuthConfig } = useQuery<EmailAuthEnabled>({
|
||||||
|
queryKey: ['email-auth-enabled'],
|
||||||
|
queryFn: brandingApi.getEmailAuthEnabled,
|
||||||
|
staleTime: 60000,
|
||||||
|
})
|
||||||
|
const isEmailAuthEnabled = emailAuthConfig?.enabled ?? true
|
||||||
|
|
||||||
const botUsername = import.meta.env.VITE_TELEGRAM_BOT_USERNAME || ''
|
const botUsername = import.meta.env.VITE_TELEGRAM_BOT_USERNAME || ''
|
||||||
|
|
||||||
|
// If email auth is disabled but user came with ref param, redirect to bot
|
||||||
|
useEffect(() => {
|
||||||
|
if (referralCode && emailAuthConfig?.enabled === false && botUsername) {
|
||||||
|
window.location.href = `https://t.me/${botUsername}?start=ref_${referralCode}`
|
||||||
|
}
|
||||||
|
}, [referralCode, emailAuthConfig, botUsername])
|
||||||
|
|
||||||
|
// If email auth is disabled but we initially set to email tab, switch back to telegram
|
||||||
|
useEffect(() => {
|
||||||
|
if (!isEmailAuthEnabled && activeTab === 'email') {
|
||||||
|
setActiveTab('telegram')
|
||||||
|
}
|
||||||
|
}, [isEmailAuthEnabled, activeTab])
|
||||||
const appName = branding ? branding.name : (import.meta.env.VITE_APP_NAME || 'VPN')
|
const appName = branding ? branding.name : (import.meta.env.VITE_APP_NAME || 'VPN')
|
||||||
const appLogo = branding?.logo_letter || import.meta.env.VITE_APP_LOGO || 'V'
|
const appLogo = branding?.logo_letter || import.meta.env.VITE_APP_LOGO || 'V'
|
||||||
const logoUrl = branding ? brandingApi.getLogoUrl(branding) : null
|
const logoUrl = branding ? brandingApi.getLogoUrl(branding) : null
|
||||||
@@ -202,8 +224,8 @@ export default function Login() {
|
|||||||
{t('auth.loginSubtitle')}
|
{t('auth.loginSubtitle')}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
{/* Referral Banner */}
|
{/* Referral Banner - only show when email auth is enabled */}
|
||||||
{referralCode && (
|
{referralCode && isEmailAuthEnabled && (
|
||||||
<div className="mt-4 p-3 rounded-xl bg-accent-500/10 border border-accent-500/30">
|
<div className="mt-4 p-3 rounded-xl bg-accent-500/10 border border-accent-500/30">
|
||||||
<div className="flex items-center gap-2 text-accent-400">
|
<div className="flex items-center gap-2 text-accent-400">
|
||||||
<svg className="w-5 h-5 flex-shrink-0" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={1.5}>
|
<svg className="w-5 h-5 flex-shrink-0" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={1.5}>
|
||||||
@@ -247,28 +269,34 @@ export default function Login() {
|
|||||||
/* Card */
|
/* Card */
|
||||||
<div className="card">
|
<div className="card">
|
||||||
{/* Tabs */}
|
{/* Tabs */}
|
||||||
<div className="flex mb-6">
|
{isEmailAuthEnabled ? (
|
||||||
<button
|
<div className="flex mb-6">
|
||||||
className={`flex-1 py-3 text-sm font-medium transition-all border-b-2 ${
|
<button
|
||||||
activeTab === 'telegram'
|
className={`flex-1 py-3 text-sm font-medium transition-all border-b-2 ${
|
||||||
? 'border-accent-500 text-accent-400'
|
activeTab === 'telegram'
|
||||||
: 'border-transparent text-dark-500 hover:text-dark-300'
|
? 'border-accent-500 text-accent-400'
|
||||||
}`}
|
: 'border-transparent text-dark-500 hover:text-dark-300'
|
||||||
onClick={() => setActiveTab('telegram')}
|
}`}
|
||||||
>
|
onClick={() => setActiveTab('telegram')}
|
||||||
Telegram
|
>
|
||||||
</button>
|
Telegram
|
||||||
<button
|
</button>
|
||||||
className={`flex-1 py-3 text-sm font-medium transition-all border-b-2 ${
|
<button
|
||||||
activeTab === 'email'
|
className={`flex-1 py-3 text-sm font-medium transition-all border-b-2 ${
|
||||||
? 'border-accent-500 text-accent-400'
|
activeTab === 'email'
|
||||||
: 'border-transparent text-dark-500 hover:text-dark-300'
|
? 'border-accent-500 text-accent-400'
|
||||||
}`}
|
: 'border-transparent text-dark-500 hover:text-dark-300'
|
||||||
onClick={() => setActiveTab('email')}
|
}`}
|
||||||
>
|
onClick={() => setActiveTab('email')}
|
||||||
Email
|
>
|
||||||
</button>
|
Email
|
||||||
</div>
|
</button>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className="mb-6 pb-3 border-b border-dark-700">
|
||||||
|
<h2 className="text-lg font-medium text-dark-200 text-center">Telegram</h2>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{error && (
|
{error && (
|
||||||
<div className="bg-error-500/10 border border-error-500/30 text-error-400 px-4 py-3 rounded-xl text-sm mb-6">
|
<div className="bg-error-500/10 border border-error-500/30 text-error-400 px-4 py-3 rounded-xl text-sm mb-6">
|
||||||
@@ -276,7 +304,7 @@ export default function Login() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{activeTab === 'telegram' ? (
|
{activeTab === 'telegram' || !isEmailAuthEnabled ? (
|
||||||
<div className="space-y-6">
|
<div className="space-y-6">
|
||||||
<p className="text-center text-sm text-dark-400">
|
<p className="text-center text-sm text-dark-400">
|
||||||
{t('auth.registerHint')}
|
{t('auth.registerHint')}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { useAuthStore } from '../store/auth'
|
|||||||
import { authApi } from '../api/auth'
|
import { authApi } from '../api/auth'
|
||||||
import { notificationsApi, NotificationSettings, NotificationSettingsUpdate } from '../api/notifications'
|
import { notificationsApi, NotificationSettings, NotificationSettingsUpdate } from '../api/notifications'
|
||||||
import { referralApi } from '../api/referral'
|
import { referralApi } from '../api/referral'
|
||||||
import { brandingApi } from '../api/branding'
|
import { brandingApi, type EmailAuthEnabled } from '../api/branding'
|
||||||
|
|
||||||
// Icons
|
// Icons
|
||||||
const CopyIcon = () => (
|
const CopyIcon = () => (
|
||||||
@@ -63,6 +63,14 @@ export default function Profile() {
|
|||||||
staleTime: 60000,
|
staleTime: 60000,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Check if email auth is enabled
|
||||||
|
const { data: emailAuthConfig } = useQuery<EmailAuthEnabled>({
|
||||||
|
queryKey: ['email-auth-enabled'],
|
||||||
|
queryFn: brandingApi.getEmailAuthEnabled,
|
||||||
|
staleTime: 60000,
|
||||||
|
})
|
||||||
|
const isEmailAuthEnabled = emailAuthConfig?.enabled ?? true
|
||||||
|
|
||||||
// Build referral link for cabinet
|
// Build referral link for cabinet
|
||||||
const referralLink = referralInfo?.referral_code
|
const referralLink = referralInfo?.referral_code
|
||||||
? `${window.location.origin}/login?ref=${referralInfo.referral_code}`
|
? `${window.location.origin}/login?ref=${referralInfo.referral_code}`
|
||||||
@@ -258,7 +266,8 @@ export default function Profile() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Email Section */}
|
{/* Email Section - only show when email auth is enabled */}
|
||||||
|
{isEmailAuthEnabled && (
|
||||||
<div className="bento-card">
|
<div className="bento-card">
|
||||||
<h2 className="text-lg font-semibold text-dark-100 mb-6">{t('profile.emailAuth')}</h2>
|
<h2 className="text-lg font-semibold text-dark-100 mb-6">{t('profile.emailAuth')}</h2>
|
||||||
|
|
||||||
@@ -381,6 +390,7 @@ export default function Profile() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Notification Settings */}
|
{/* Notification Settings */}
|
||||||
<div className="bento-card">
|
<div className="bento-card">
|
||||||
|
|||||||
Reference in New Issue
Block a user