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
+8 -8
View File
@@ -2,7 +2,8 @@ import type { Metadata } from "next";
import { NextIntlClientProvider, hasLocale } from 'next-intl'; import { NextIntlClientProvider, hasLocale } from 'next-intl';
import { notFound } from 'next/navigation'; import { notFound } from 'next/navigation';
import { routing } from '@/i18n/routing'; 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 { Suspense } from 'react';
import "../styles/globals.css"; import "../styles/globals.css";
@@ -32,13 +33,12 @@ export default async function RootLayout({
return ( return (
<html> <html>
<body> <body>
<Suspense fallback={<div>Loading...</div>}> <NextIntlClientProvider locale={locale}>
<NextIntlClientProvider locale={locale}> <Providers>
<ClientProviders> {children}
{children} <ToastProvider />
</ClientProviders> </Providers>
</NextIntlClientProvider> </NextIntlClientProvider>
</Suspense>
</body> </body>
</html> </html>
); );
+1 -1
View File
@@ -1,7 +1,7 @@
'use client' 'use client'
import { PdfProvider } from '@/app/contexts/PdfContext'; 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 }) { export default function RootLayout({ children }: { children: React.ReactNode }) {
return ( return (
-1
View File
@@ -300,7 +300,6 @@ export async function fetchViolationFinalSummaryStatistic() {
if (response.ok) { if (response.ok) {
let parsed = await response.json(); let parsed = await response.json();
console.log(parsed);
if (parsed?.message_code === 0) { if (parsed?.message_code === 0) {
return parsed?.message_body; 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>
);
}
@@ -1,10 +1,10 @@
'use client' 'use client'
import {IconLink, IconDocument, IconCheck, IconPerson, IconGlobe, IconCity} from '@/app/ui/icons/icons'; import { IconLink, IconDocument, IconCheck, IconPerson, IconGlobe, IconCity } from '@/app/ui/icons/icons';
import { useTrackingStats } from '@/app/hooks/react-query/useTrackingStats'; import { useTrackingStats } from '@/app/hooks/react-query/useTrackingStats';
export function TrackingStatistic() { export function TrackingStatistic() {
const { data } = useTrackingStats(); const { data, isLoading } = useTrackingStats();
return ( return (
<div <div
@@ -27,7 +27,17 @@ export function TrackingStatistic() {
<IconDocument /> <IconDocument />
</div> </div>
<div className="general-statistic-item-val"> <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>
<div className="general-statistic-item-lbl"> <div className="general-statistic-item-lbl">
Документов Документов
@@ -36,14 +46,25 @@ export function TrackingStatistic() {
<div className="general-statistic-item"> <div className="general-statistic-item">
<div className="general-statistic-item-ico"> <div className="general-statistic-item-ico">
<IconLink /> <IconLink />
</div><div className="general-statistic-item-val"> </div>
{data?.totalViews? data?.totalViews : 0} <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>
<div className="general-statistic-item-lbl"> <div className="general-statistic-item-lbl">
Открытий Открытий
</div> </div>
</div> </div>
{/* <div className="general-statistic-item"> {/* <div className="general-statistic-item">
<div className="general-statistic-item-ico"> <div className="general-statistic-item-ico">
<IconCheck /> <IconCheck />
</div> </div>
@@ -59,7 +80,17 @@ export function TrackingStatistic() {
<IconPerson /> <IconPerson />
</div> </div>
<div className="general-statistic-item-val"> <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>
<div className="general-statistic-item-lbl"> <div className="general-statistic-item-lbl">
Уникальных IP Уникальных IP
@@ -70,7 +101,17 @@ export function TrackingStatistic() {
<IconGlobe /> <IconGlobe />
</div> </div>
<div className="general-statistic-item-val"> <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>
<div className="general-statistic-item-lbl"> <div className="general-statistic-item-lbl">
Уникальных стран Уникальных стран
@@ -81,7 +122,17 @@ export function TrackingStatistic() {
<IconCity /> <IconCity />
</div> </div>
<div className="general-statistic-item-val"> <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>
<div className="general-statistic-item-lbl"> <div className="general-statistic-item-lbl">
Уникальных городов Уникальных городов