2026-04-20 16:48:15 +07:00
|
|
|
'use client'
|
|
|
|
|
|
|
|
|
|
import { useQuery } from '@tanstack/react-query';
|
2026-02-02 12:49:31 +07:00
|
|
|
import Link from 'next/link';
|
2026-04-20 16:48:15 +07:00
|
|
|
import { fetchLastMonitoringCheck } from '@/app/actions/monitoringActions';
|
|
|
|
|
import { formatDate, formatDateTime } from '@/app/lib/formatDate';
|
|
|
|
|
import { useTranslations } from 'next-intl';
|
2026-02-02 12:49:31 +07:00
|
|
|
|
2026-01-13 15:29:34 +07:00
|
|
|
export default function DashboardLastCheck() {
|
2026-04-20 16:48:15 +07:00
|
|
|
const { data, isLoading } = useQuery({
|
|
|
|
|
queryKey: ['lastMonitoringCheck'],
|
|
|
|
|
queryFn: () => {
|
|
|
|
|
return fetchLastMonitoringCheck()
|
|
|
|
|
},
|
|
|
|
|
select: (data) => {
|
|
|
|
|
if (!data) {
|
|
|
|
|
return null
|
|
|
|
|
}
|
|
|
|
|
return data;
|
|
|
|
|
},
|
|
|
|
|
retry: false
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const t = useTranslations('Global');
|
|
|
|
|
|
2026-01-13 15:29:34 +07:00
|
|
|
return (
|
|
|
|
|
<div className="dashboard-last-check">
|
|
|
|
|
<div className="last-check-info">
|
2026-04-20 16:48:15 +07:00
|
|
|
<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>
|
2026-01-13 15:29:34 +07:00
|
|
|
</div>
|
|
|
|
|
<div className="last-check-actions">
|
2026-02-02 12:49:31 +07:00
|
|
|
<Link
|
|
|
|
|
className="btn-report"
|
2026-04-20 16:48:15 +07:00
|
|
|
href={'/pages/reports'}
|
2026-02-02 12:49:31 +07:00
|
|
|
>
|
2026-04-20 16:48:15 +07:00
|
|
|
{t('reports')}
|
2026-02-02 12:49:31 +07:00
|
|
|
</Link>
|
2026-04-20 16:48:15 +07:00
|
|
|
{/* <Link
|
2026-02-02 12:49:31 +07:00
|
|
|
className="btn-new-search"
|
|
|
|
|
href={'violations'}
|
|
|
|
|
>
|
2026-04-20 16:48:15 +07:00
|
|
|
Мониторинг нарушений
|
|
|
|
|
</Link> */}
|
2026-01-13 15:29:34 +07:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|