v0.1 - макет интерфейса, аутентификация через логин, аккаунт админа, создание партии в 2 этапа, базовые настройки профиля и группы, переключение между группами, статистика

This commit is contained in:
2026-06-16 17:41:06 +03:00
parent 6ab74f01aa
commit 56b5d09a4d
123 changed files with 13572 additions and 21 deletions
+29
View File
@@ -0,0 +1,29 @@
import type { PropsWithChildren } from "react";
import { Navigate, useLocation } from "react-router-dom";
import { Spinner } from "../components/Spinner";
import { useMe } from "../hooks/auth";
import { useAdminMe } from "../hooks/admin";
export function RequireAuth({ children }: PropsWithChildren) {
const { data: me, isLoading } = useMe();
const location = useLocation();
if (isLoading) return <Spinner />;
if (!me) return <Navigate to="/login" replace state={{ from: location }} />;
return <>{children}</>;
}
export function RequireGroup({ children }: PropsWithChildren) {
const { data: me, isLoading } = useMe();
if (isLoading) return <Spinner />;
if (!me) return <Navigate to="/login" replace />;
if (me.active_group_id == null) return <Navigate to="/" replace />;
return <>{children}</>;
}
export function RequireAdmin({ children }: PropsWithChildren) {
const { data: admin, isLoading } = useAdminMe();
if (isLoading) return <Spinner />;
if (!admin) return <Navigate to="/admin/login" replace />;
return <>{children}</>;
}