diff --git a/src/food-market.web/src/App.tsx b/src/food-market.web/src/App.tsx index 5b6a948..cb761d0 100644 --- a/src/food-market.web/src/App.tsx +++ b/src/food-market.web/src/App.tsx @@ -1,6 +1,5 @@ import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom' import { QueryClient, QueryClientProvider } from '@tanstack/react-query' -import { ReactQueryDevtools } from '@tanstack/react-query-devtools' import { LoginPage } from '@/pages/LoginPage' import { DashboardPage } from '@/pages/DashboardPage' import { CountriesPage } from '@/pages/CountriesPage' @@ -49,7 +48,6 @@ export default function App() { } /> - ) } diff --git a/src/food-market.web/src/pages/DashboardPage.tsx b/src/food-market.web/src/pages/DashboardPage.tsx index 9b7a74a..e5d5d42 100644 --- a/src/food-market.web/src/pages/DashboardPage.tsx +++ b/src/food-market.web/src/pages/DashboardPage.tsx @@ -4,6 +4,14 @@ import { PageHeader } from '@/components/PageHeader' import { api } from '@/lib/api' import type { PagedResult } from '@/lib/types' +interface MeResponse { + sub: string + name: string + email: string + roles: string[] + orgId: string +} + function useCount(url: string) { return useQuery({ queryKey: [url, 'count'], @@ -33,18 +41,33 @@ function StatCard({ icon: Icon, label, value, isLoading }: StatCardProps) { } export function DashboardPage() { + const me = useQuery({ + queryKey: ['me'], + queryFn: async () => (await api.get('/api/me')).data, + }) const products = useCount('/api/catalog/products') const counterparties = useCount('/api/catalog/counterparties') const stores = useCount('/api/catalog/stores') const retailPoints = useCount('/api/catalog/retail-points') + const anyError = [products, counterparties, stores, retailPoints].find(q => q.error)?.error as Error | undefined + return (
+ {anyError && ( +
+
API недоступен или ещё не обновился
+
+ Перезапусти API после git pull: Ctrl+C → dotnet run --project src/food-market.api +
+
+ )} +
@@ -52,7 +75,19 @@ export function DashboardPage() {
-
+ {me.data && ( +
+

Текущий пользователь

+
+
Имя:
{me.data.name}
+
Email:
{me.data.email}
+
Роли:
{me.data.roles.join(', ')}
+
Организация:
{me.data.orgId}
+
+
+ )} + +

Что дальше

  • Phase 2: приёмка товара, розничные продажи, складские остатки