This commit is contained in:
arrelin
2026-01-23 12:23:25 +03:00
parent a3e941b19f
commit 71f772f2b9
14 changed files with 569 additions and 131 deletions

View File

@@ -1,10 +1,12 @@
import { useEffect, useState } from 'react';
import { useParams, useNavigate } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { inviteLinkApi, authApi } from '../api/client';
import { useStore } from '../store/useStore';
import { Loader2, Users, UserPlus, AlertCircle } from 'lucide-react';
export default function InvitePage() {
const { t } = useTranslation();
const { token } = useParams<{ token: string }>();
const navigate = useNavigate();
const { isAuthenticated, setUser } = useStore();
@@ -37,10 +39,10 @@ export default function InvitePage() {
setIsValid(true);
setFamilyName(response.data.family_name);
} else {
setError('Ссылка недействительна или срок её действия истёк');
setError(t('invite.invalid'));
}
} catch (err) {
setError('Ссылка не найдена');
setError(t('invite.notFound'));
} finally {
setLoading(false);
}
@@ -61,9 +63,9 @@ export default function InvitePage() {
}
} catch (err: any) {
if (err.response?.status === 400) {
setError('Вы уже состоите в семье');
setError(t('invite.alreadyInFamily'));
} else {
setError('Ошибка при присоединении к семье');
setError(t('invite.joinError'));
}
} finally {
setJoining(false);
@@ -78,7 +80,7 @@ export default function InvitePage() {
const response = await authApi.getGoogleAuthUrl(window.location.href);
window.location.href = response.data.url;
} catch (err) {
setError('Ошибка при получении ссылки для авторизации');
setError(t('login.authError'));
}
};
@@ -87,7 +89,7 @@ export default function InvitePage() {
<div className="min-h-screen flex items-center justify-center gradient-bg">
<div className="flex items-center gap-3 text-white">
<Loader2 className="w-8 h-8 animate-spin" />
<span className="text-xl font-medium">Проверка приглашения...</span>
<span className="text-xl font-medium">{t('invite.validating')}</span>
</div>
</div>
);
@@ -98,7 +100,7 @@ export default function InvitePage() {
<div className="min-h-screen flex items-center justify-center gradient-bg">
<div className="flex items-center gap-3 text-white">
<Loader2 className="w-8 h-8 animate-spin" />
<span className="text-xl font-medium">Присоединение к семье...</span>
<span className="text-xl font-medium">{t('invite.joining')}</span>
</div>
</div>
);
@@ -111,13 +113,13 @@ export default function InvitePage() {
<div className="p-4 bg-red-100 rounded-2xl inline-block mb-6">
<AlertCircle className="w-12 h-12 text-red-500" />
</div>
<h1 className="text-2xl font-bold text-gray-800 mb-4">Ошибка</h1>
<h1 className="text-2xl font-bold text-gray-800 mb-4">{t('common.error')}</h1>
<p className="text-gray-600 mb-6">{error}</p>
<button
onClick={() => navigate('/')}
className="px-6 py-3 bg-gradient-to-r from-purple-600 to-blue-600 text-white rounded-2xl font-semibold hover:shadow-xl transition-all"
>
На главную
{t('common.toHome')}
</button>
</div>
</div>
@@ -131,21 +133,20 @@ export default function InvitePage() {
<Users className="w-12 h-12 text-white" />
</div>
<h1 className="text-2xl font-bold text-gray-800 mb-2">
Приглашение в семью
{t('invite.pageTitle')}
</h1>
<p className="text-3xl font-bold text-purple-600 mb-6">
{familyName}
</p>
<p className="text-gray-600 mb-8">
Вас пригласили присоединиться к семейному бюджету.
Войдите через Google, чтобы принять приглашение.
{t('invite.pageDescription')}
</p>
<button
onClick={handleGoogleLogin}
className="w-full flex items-center justify-center gap-3 px-6 py-4 bg-gradient-to-r from-purple-600 to-blue-600 text-white rounded-2xl font-semibold hover:shadow-xl transition-all"
>
<UserPlus className="w-5 h-5" />
Войти и присоединиться
{t('invite.loginAndJoin')}
</button>
</div>
</div>