(true);
-export default function App() {
- return (
-
- } />
-
-
-
- } />
-
- )
+ // Функция выхода
+ const handleLogout = () => {
+ localStorage.clear();
+ sessionStorage.clear();
+ window.location.reload(); // Перезагрузка вернет пользователя на экран входа
+ };
+
+ useEffect(() => {
+ // Пример запроса за данными (или проверка профиля)
+ 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 Загрузка...
;
+ }
+
+ // Если возникла критическая ошибка доступа — показываем экран с кнопкой выхода
+ if (authError) {
+ return ;
+ }
+
+ return (
+
+ {/* Ваше основное приложение */}
+
Панель менеджера
+
+ );
}
\ No newline at end of file
diff --git a/src/components/ErrorScreen.tsx b/src/components/ErrorScreen.tsx
new file mode 100644
index 0000000..e780a26
--- /dev/null
+++ b/src/components/ErrorScreen.tsx
@@ -0,0 +1,33 @@
+import React from 'react';
+
+interface ErrorScreenProps {
+ title?: string;
+ message: string;
+ onLogout: () => void;
+}
+
+export const ErrorScreen: React.FC = ({
+ title = 'Ошибка доступа',
+ message,
+ onLogout,
+ }) => {
+ return (
+
+
+
+ !
+
+
{title}
+
+ {message}
+
+
+
+
+ );
+};
\ No newline at end of file
diff --git a/tsconfig.app.json b/tsconfig.app.json
index 6830b6f..9a00dd4 100644
--- a/tsconfig.app.json
+++ b/tsconfig.app.json
@@ -20,7 +20,8 @@
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
- "noFallthroughCasesInSwitch": true
+ "noFallthroughCasesInSwitch": true,
+ "allowSyntheticDefaultImports": true
},
"include": ["src"]
}