fix loading

This commit is contained in:
smanylov
2026-05-08 13:57:55 +07:00
parent b8a76bd6a9
commit 37b7ccb52e
6 changed files with 80 additions and 44 deletions
+5 -5
View File
@@ -2,7 +2,8 @@ import type { Metadata } from "next";
import { NextIntlClientProvider, hasLocale } from 'next-intl';
import { notFound } from 'next/navigation';
import { routing } from '@/i18n/routing';
import ClientProviders from '@/app/providers/ClientProviders';
import { ToastProvider } from '@/app/providers/ToastProvider';
import Providers from '@/app/providers/getQueryServer';
import { Suspense } from 'react';
import "../styles/globals.css";
@@ -32,13 +33,12 @@ export default async function RootLayout({
return (
<html>
<body>
<Suspense fallback={<div>Loading...</div>}>
<NextIntlClientProvider locale={locale}>
<ClientProviders>
<Providers>
{children}
</ClientProviders>
<ToastProvider />
</Providers>
</NextIntlClientProvider>
</Suspense>
</body>
</html>
);
+1 -1
View File
@@ -1,7 +1,7 @@
'use client'
import { PdfProvider } from '@/app/contexts/PdfContext';
import { WatchDocProviders } from '@/app/providers/ClientProviders';
import { WatchDocProviders } from '@/app/providers/WatchDocProviders';
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
-1
View File
@@ -300,7 +300,6 @@ export async function fetchViolationFinalSummaryStatistic() {
if (response.ok) {
let parsed = await response.json();
console.log(parsed);
if (parsed?.message_code === 0) {
return parsed?.message_body;
-25
View File
@@ -1,25 +0,0 @@
'use client';
import Providers from './getQueryServer';
import { ToastProvider } from './ToastProvider';
export default function ClientProviders({
children
}: {
children: React.ReactNode;
}) {
return (
<Providers>
{children}
<ToastProvider />
</Providers>
);
}
export function WatchDocProviders({ children }: { children: React.ReactNode }) {
return (
<Providers>
{children}
</Providers>
);
}
+11
View File
@@ -0,0 +1,11 @@
'use client';
import Providers from './getQueryServer';
export function WatchDocProviders({ children }: { children: React.ReactNode }) {
return (
<Providers>
{children}
</Providers>
);
}
@@ -4,7 +4,7 @@ import {IconLink, IconDocument, IconCheck, IconPerson, IconGlobe, IconCity} from
import { useTrackingStats } from '@/app/hooks/react-query/useTrackingStats';
export function TrackingStatistic() {
const { data } = useTrackingStats();
const { data, isLoading } = useTrackingStats();
return (
<div
@@ -27,7 +27,17 @@ export function TrackingStatistic() {
<IconDocument />
</div>
<div className="general-statistic-item-val">
{data?.documentsCount ? data?.documentsCount : 0}
<div
className="loading-placeholder start"
>
{isLoading ? (
<div className="loading-animation">
<div className="global-spinner" />
</div>
) : (
data?.documentsCount ? data?.documentsCount : 0
)}
</div>
</div>
<div className="general-statistic-item-lbl">
Документов
@@ -36,8 +46,19 @@ export function TrackingStatistic() {
<div className="general-statistic-item">
<div className="general-statistic-item-ico">
<IconLink />
</div><div className="general-statistic-item-val">
{data?.totalViews? data?.totalViews : 0}
</div>
<div className="general-statistic-item-val">
<div
className="loading-placeholder start"
>
{isLoading ? (
<div className="loading-animation">
<div className="global-spinner" />
</div>
) : (
data?.totalViews ? data?.totalViews : 0
)}
</div>
</div>
<div className="general-statistic-item-lbl">
Открытий
@@ -59,7 +80,17 @@ export function TrackingStatistic() {
<IconPerson />
</div>
<div className="general-statistic-item-val">
{data?.uniqueIps ? data?.uniqueIps : 0}
<div
className="loading-placeholder start"
>
{isLoading ? (
<div className="loading-animation">
<div className="global-spinner" />
</div>
) : (
data?.uniqueIps ? data?.uniqueIps : 0
)}
</div>
</div>
<div className="general-statistic-item-lbl">
Уникальных IP
@@ -70,7 +101,17 @@ export function TrackingStatistic() {
<IconGlobe />
</div>
<div className="general-statistic-item-val">
{data?.uniqueCountryCount ? data?.uniqueCountryCount : 0}
<div
className="loading-placeholder start"
>
{isLoading ? (
<div className="loading-animation">
<div className="global-spinner" />
</div>
) : (
data?.uniqueCountryCount ? data?.uniqueCountryCount : 0
)}
</div>
</div>
<div className="general-statistic-item-lbl">
Уникальных стран
@@ -81,7 +122,17 @@ export function TrackingStatistic() {
<IconCity />
</div>
<div className="general-statistic-item-val">
{data?.uniqueCountryCount ? data?.uniqueCountryCount : 0}
<div
className="loading-placeholder start"
>
{isLoading ? (
<div className="loading-animation">
<div className="global-spinner" />
</div>
) : (
data?.uniqueCountryCount ? data?.uniqueCountryCount : 0
)}
</div>
</div>
<div className="general-statistic-item-lbl">
Уникальных городов