diff --git a/src/api/monthlyOrders.ts b/src/api/monthlyOrders.ts index 6b66aef..d4ec922 100644 --- a/src/api/monthlyOrders.ts +++ b/src/api/monthlyOrders.ts @@ -8,6 +8,11 @@ export interface AdminUser { name?: string; is_analyst: boolean; is_root: boolean; + is_observer: boolean; + telegram_user?: { + id: number; + full_name: string; + }; } export const monthlyOrdersApi = { diff --git a/src/pages/AnalystDashboard.tsx b/src/pages/AnalystDashboard.tsx index e6d9403..6b7bef0 100644 --- a/src/pages/AnalystDashboard.tsx +++ b/src/pages/AnalystDashboard.tsx @@ -1,7 +1,8 @@ import { useEffect, useState } from 'react'; import { Container, Title, SimpleGrid, Card, Text, Button, LoadingOverlay, Badge, Group } from '@mantine/core'; import { useNavigate } from 'react-router-dom'; -import { monthlyOrdersApi, type AdminUser } from '../api/monthlyOrders'; +import { monthlyOrdersApi } from '../api/monthlyOrders'; +import type { AdminUser } from '../api/monthlyOrders'; import { IconTable } from '@tabler/icons-react'; export default function AnalystDashboard() { @@ -16,6 +17,8 @@ export default function AnalystDashboard() { .finally(() => setLoading(false)); }, []); + const managers = users.filter(u => !u.is_analyst && !u.is_root && !u.is_observer && u.telegram_user?.id); + if (loading) return ; return ( @@ -23,32 +26,40 @@ export default function AnalystDashboard() { Панель аналитика Выберите менеджера для просмотра его таблицы заказов: - - {users.map(u => ( - - - {u.name || u.login} - + {managers.length === 0 ? ( + Менеджеры не найдены. + ) : ( + + {managers.map(u => { + // Имя берем из привязанного Telegram профиля, если его нет - из админки + const displayName = u.telegram_user?.full_name || u.name || u.login; - - {u.is_analyst && Аналитик} - {u.is_root && Root} - {!u.is_analyst && !u.is_root && Менеджер} - + return ( + + + {displayName} + - - - ))} - + + Менеджер + + + + + ) + })} + + )} ); } \ No newline at end of file