Added znzt web app
Deploy Manager App / deploy (push) Failing after 17s Details

This commit is contained in:
romanskijdev 2026-08-25 13:03:14 +03:00
parent af3d4fcc10
commit 883f990598
3 changed files with 88 additions and 21 deletions

View File

@ -1,23 +1,56 @@
import { Routes, Route, Navigate } from 'react-router-dom' import { useState, useEffect } from 'react';
import Login from './pages/Login' import { ErrorScreen } from './components/ErrorScreen';
import OrdersPage from './pages/OrdersPage'
import React from "react";
function ProtectedRoute({ children }: { children: React.ReactNode }) { export function App() {
const token = localStorage.getItem('token') const [authError, setAuthError] = useState<string | null>(null);
if (!token) return <Navigate to="/login" replace /> const [loading, setLoading] = useState<boolean>(true);
return <>{children}</>
}
export default function App() { // Функция выхода
return ( const handleLogout = () => {
<Routes> localStorage.clear();
<Route path="/login" element={<Login />} /> sessionStorage.clear();
<Route path="/" element={ window.location.reload(); // Перезагрузка вернет пользователя на экран входа
<ProtectedRoute> };
<OrdersPage />
</ProtectedRoute> useEffect(() => {
} /> // Пример запроса за данными (или проверка профиля)
</Routes> fetch('/api/monthly-orders/matrix', {
) headers: {
'Authorization': `Bearer ${localStorage.getItem('token')}`
}
})
.then(async (res) => {
if (!res.ok) {
const data = await res.json();
// Если бэкенд вернул ошибку привязки Telegram
if (data && data.error_description) {
throw new Error(data.error_description);
}
throw new Error('Произошла ошибка загрузки данных');
}
return res.json();
})
.catch((err) => {
setAuthError(err.message);
})
.finally(() => {
setLoading(false);
});
}, []);
if (loading) {
return <div className="flex justify-center items-center h-screen">Загрузка...</div>;
}
// Если возникла критическая ошибка доступа — показываем экран с кнопкой выхода
if (authError) {
return <ErrorScreen message={authError} onLogout={handleLogout} />;
}
return (
<div>
{/* Ваше основное приложение */}
<h1>Панель менеджера</h1>
</div>
);
} }

View File

@ -0,0 +1,33 @@
import React from 'react';
interface ErrorScreenProps {
title?: string;
message: string;
onLogout: () => void;
}
export const ErrorScreen: React.FC<ErrorScreenProps> = ({
title = 'Ошибка доступа',
message,
onLogout,
}) => {
return (
<div className="flex flex-col items-center justify-center min-h-screen bg-gray-100 p-4">
<div className="max-w-md w-full bg-white rounded-lg shadow-lg p-6 text-center">
<div className="w-12 h-12 mx-auto mb-4 text-red-500 bg-red-100 rounded-full flex items-center justify-center text-xl font-bold">
!
</div>
<h2 className="text-xl font-semibold text-gray-800 mb-2">{title}</h2>
<p className="text-gray-600 mb-6 bg-gray-50 p-3 rounded border border-gray-200 text-sm">
{message}
</p>
<button
onClick={onLogout}
className="w-full bg-red-600 hover:bg-red-700 text-white font-medium py-2 px-4 rounded transition-colors duration-200 shadow"
>
Выйти и войти заново
</button>
</div>
</div>
);
};

View File

@ -20,7 +20,8 @@
"noUnusedLocals": true, "noUnusedLocals": true,
"noUnusedParameters": true, "noUnusedParameters": true,
"erasableSyntaxOnly": true, "erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true "noFallthroughCasesInSwitch": true,
"allowSyntheticDefaultImports": true
}, },
"include": ["src"] "include": ["src"]
} }