add real info for dashboard-last-check

This commit is contained in:
smanylov
2026-04-20 16:48:15 +07:00
parent 3a8a1f9c08
commit 045eef24c0
5 changed files with 85 additions and 12 deletions
+32
View File
@@ -88,3 +88,35 @@ export async function fetchMonitoringStats(): Promise<MonitoringStats | null> {
return null 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
}
}
+2 -2
View File
@@ -1715,13 +1715,13 @@
.left-column { .left-column {
flex-direction: column; flex-direction: column;
width: 100%; width: 100%;
padding-right: 15px; padding-right: 10px;
} }
.right-column { .right-column {
width: 100%; width: 100%;
flex-direction: column; flex-direction: column;
padding-left: 15px; padding-left: 10px;
} }
@media (max-width: 1360px) { @media (max-width: 1360px) {
@@ -1,26 +1,63 @@
'use client'
import { useQuery } from '@tanstack/react-query';
import Link from 'next/link'; 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() { 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 ( return (
<div className="dashboard-last-check"> <div className="dashboard-last-check">
<div className="last-check-info"> <div className="last-check-info">
<div className="last-check-title">Последняя проверка контента</div> <div className="last-check-title">
<div className="last-check-date"> {t('last-content-check')}
17.10.2025 в 10:23</div> </div>
<div
className="relative"
>
{isLoading ? (
<div
className="loading-animation"
>
<div className="global-spinner"></div>
</div>
) : (
<div className="last-check-date">
{data?.recent_searches[0]?.created_at ? `${formatDate(data.recent_searches[0].created_at)} ${t('in')} ${formatDateTime(data.recent_searches[0].created_at)}` : '---'}
</div>
)}
</div>
</div> </div>
<div className="last-check-actions"> <div className="last-check-actions">
<Link <Link
className="btn-report" className="btn-report"
href={'reports'} href={'/pages/reports'}
> >
📄 Отчёт {t('reports')}
</Link> </Link>
<Link {/* <Link
className="btn-new-search" className="btn-new-search"
href={'violations'} href={'violations'}
> >
🔍 Мониторинг нарушений Мониторинг нарушений
</Link> </Link> */}
</div> </div>
</div> </div>
) )
+3 -1
View File
@@ -433,7 +433,9 @@
"recent-complaints": "Recent complaints", "recent-complaints": "Recent complaints",
"recent-claims": "Recent claims", "recent-claims": "Recent claims",
"no-complaints": "No complaints", "no-complaints": "No complaints",
"no-claims": "No claims" "no-claims": "No claims",
"in": "in",
"last-content-check": "Last content check"
}, },
"Login-register-form": { "Login-register-form": {
"and": "and", "and": "and",
+3 -1
View File
@@ -433,7 +433,9 @@
"recent-complaints": "Недавние жалобы", "recent-complaints": "Недавние жалобы",
"recent-claims": "Недавние претензии", "recent-claims": "Недавние претензии",
"no-complaints": "Жалоб нет", "no-complaints": "Жалоб нет",
"no-claims": "Претензии нет" "no-claims": "Претензии нет",
"in": "в",
"last-content-check": "Последняя проверка контента"
}, },
"Login-register-form": { "Login-register-form": {
"and": "и", "and": "и",