add real info for dashboard-last-check
This commit is contained in:
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -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",
|
||||||
|
|||||||
@@ -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": "и",
|
||||||
|
|||||||
Reference in New Issue
Block a user