add real info for dashboard-last-check
This commit is contained in:
@@ -87,4 +87,36 @@ export async function fetchMonitoringStats(): Promise<MonitoringStats | null> {
|
||||
} 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
|
||||
}
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 (
|
||||
<div className="dashboard-last-check">
|
||||
<div className="last-check-info">
|
||||
<div className="last-check-title">Последняя проверка контента</div>
|
||||
<div className="last-check-date">
|
||||
17.10.2025 в 10:23</div>
|
||||
<div className="last-check-title">
|
||||
{t('last-content-check')}
|
||||
</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 className="last-check-actions">
|
||||
<Link
|
||||
className="btn-report"
|
||||
href={'reports'}
|
||||
href={'/pages/reports'}
|
||||
>
|
||||
📄 Отчёт
|
||||
{t('reports')}
|
||||
</Link>
|
||||
<Link
|
||||
{/* <Link
|
||||
className="btn-new-search"
|
||||
href={'violations'}
|
||||
>
|
||||
🔍 Мониторинг нарушений
|
||||
</Link>
|
||||
Мониторинг нарушений
|
||||
</Link> */}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -433,7 +433,9 @@
|
||||
"recent-complaints": "Недавние жалобы",
|
||||
"recent-claims": "Недавние претензии",
|
||||
"no-complaints": "Жалоб нет",
|
||||
"no-claims": "Претензии нет"
|
||||
"no-claims": "Претензии нет",
|
||||
"in": "в",
|
||||
"last-content-check": "Последняя проверка контента"
|
||||
},
|
||||
"Login-register-form": {
|
||||
"and": "и",
|
||||
|
||||
Reference in New Issue
Block a user