diff --git a/src/app/actions/monitoringActions.ts b/src/app/actions/monitoringActions.ts index 04744fb..368340d 100644 --- a/src/app/actions/monitoringActions.ts +++ b/src/app/actions/monitoringActions.ts @@ -87,4 +87,36 @@ export async function fetchMonitoringStats(): Promise { } catch (error) { return null } +} + +export async function fetchLastMonitoringCheck() { + const token = await getSessionData('token'); + + try { + const response = await fetch(`${API_BASE_URL}/api/v1/data`, { + method: 'POST', + body: JSON.stringify({ + version: 1, + msg_id: 30011, + message_body: { + token: token, + limit: 1 + } + }), + headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json' + } + }); + + if (response.ok) { + const parsed = await response.json(); + + if (parsed?.message_body?.searches_by_status) { + return parsed.message_body; + } + } + } catch (error) { + return null + } } \ No newline at end of file diff --git a/src/app/styles/pages-styles.scss b/src/app/styles/pages-styles.scss index e83c885..ac21c4e 100644 --- a/src/app/styles/pages-styles.scss +++ b/src/app/styles/pages-styles.scss @@ -1715,13 +1715,13 @@ .left-column { flex-direction: column; width: 100%; - padding-right: 15px; + padding-right: 10px; } .right-column { width: 100%; flex-direction: column; - padding-left: 15px; + padding-left: 10px; } @media (max-width: 1360px) { diff --git a/src/app/ui/dashboard/new/dashboard-last-check.tsx b/src/app/ui/dashboard/new/dashboard-last-check.tsx index c8de769..7a7c55d 100644 --- a/src/app/ui/dashboard/new/dashboard-last-check.tsx +++ b/src/app/ui/dashboard/new/dashboard-last-check.tsx @@ -1,26 +1,63 @@ +'use client' + +import { useQuery } from '@tanstack/react-query'; import Link from 'next/link'; +import { fetchLastMonitoringCheck } from '@/app/actions/monitoringActions'; +import { formatDate, formatDateTime } from '@/app/lib/formatDate'; +import { useTranslations } from 'next-intl'; export default function DashboardLastCheck() { + const { data, isLoading } = useQuery({ + queryKey: ['lastMonitoringCheck'], + queryFn: () => { + return fetchLastMonitoringCheck() + }, + select: (data) => { + if (!data) { + return null + } + return data; + }, + retry: false + }); + + const t = useTranslations('Global'); + return (
-
Последняя проверка контента
-
- 17.10.2025 в 10:23
+
+ {t('last-content-check')} +
+
+ {isLoading ? ( +
+
+
+ ) : ( +
+ {data?.recent_searches[0]?.created_at ? `${formatDate(data.recent_searches[0].created_at)} ${t('in')} ${formatDateTime(data.recent_searches[0].created_at)}` : '---'} +
+ )} +
- 📄 Отчёт + {t('reports')} - - 🔍 Мониторинг нарушений - + Мониторинг нарушений + */}
) diff --git a/src/i18n/messages/en.json b/src/i18n/messages/en.json index 9d60125..617d71a 100644 --- a/src/i18n/messages/en.json +++ b/src/i18n/messages/en.json @@ -433,7 +433,9 @@ "recent-complaints": "Recent complaints", "recent-claims": "Recent claims", "no-complaints": "No complaints", - "no-claims": "No claims" + "no-claims": "No claims", + "in": "in", + "last-content-check": "Last content check" }, "Login-register-form": { "and": "and", diff --git a/src/i18n/messages/ru.json b/src/i18n/messages/ru.json index d5f29a0..357156d 100644 --- a/src/i18n/messages/ru.json +++ b/src/i18n/messages/ru.json @@ -433,7 +433,9 @@ "recent-complaints": "Недавние жалобы", "recent-claims": "Недавние претензии", "no-complaints": "Жалоб нет", - "no-claims": "Претензии нет" + "no-claims": "Претензии нет", + "in": "в", + "last-content-check": "Последняя проверка контента" }, "Login-register-form": { "and": "и",