✨ feat(stats): Replace dynamic stat fetching with environment constants for user, server, and location counts
This commit is contained in:
parent
3547bb1596
commit
46ae1665be
@ -5,6 +5,11 @@ NEXT_PUBLIC_DEFAULT_LANGUAGE=en-US
|
||||
NEXT_PUBLIC_SITE_URL=https://user.ppanel.dev
|
||||
NEXT_PUBLIC_API_URL=https://api.ppanel.dev
|
||||
|
||||
# Home Page Settings
|
||||
NEXT_PUBLIC_HOME_USER_COUNT=999
|
||||
NEXT_PUBLIC_HOME_SERVER_COUNT=999
|
||||
NEXT_PUBLIC_HOME_LOCATION_COUNT=999
|
||||
|
||||
# Contact Email
|
||||
NEXT_PUBLIC_EMAIL=support@ppanel.dev
|
||||
# Community Links
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
'use client';
|
||||
|
||||
import { getStat } from '@/services/common/common';
|
||||
import {
|
||||
NEXT_PUBLIC_HOME_LOCATION_COUNT,
|
||||
NEXT_PUBLIC_HOME_SERVER_COUNT,
|
||||
NEXT_PUBLIC_HOME_USER_COUNT,
|
||||
} from '@/config/constants';
|
||||
import { DotLottieReact } from '@lottiefiles/dotlottie-react';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import LocationsLittie from '@workspace/ui/lotties/locations.json';
|
||||
import ServersLottie from '@workspace/ui/lotties/servers.json';
|
||||
import UsersLottie from '@workspace/ui/lotties/users.json';
|
||||
@ -13,31 +16,20 @@ import { useEffect, useState } from 'react';
|
||||
export function Stats() {
|
||||
const t = useTranslations('index');
|
||||
|
||||
const { data } = useQuery({
|
||||
queryKey: ['getStat'],
|
||||
queryFn: async () => {
|
||||
const { data } = await getStat({
|
||||
skipErrorHandler: true,
|
||||
});
|
||||
return data.data;
|
||||
},
|
||||
refetchOnWindowFocus: false,
|
||||
});
|
||||
|
||||
const list = [
|
||||
{
|
||||
name: t('users'),
|
||||
number: data?.user || 999,
|
||||
number: NEXT_PUBLIC_HOME_USER_COUNT,
|
||||
icon: <DotLottieReact className='size-24' data={UsersLottie} autoplay loop />,
|
||||
},
|
||||
{
|
||||
name: t('servers'),
|
||||
number: data?.server || 30,
|
||||
number: NEXT_PUBLIC_HOME_SERVER_COUNT,
|
||||
icon: <DotLottieReact className='size-24' data={ServersLottie} autoplay loop />,
|
||||
},
|
||||
{
|
||||
name: t('locations'),
|
||||
number: data?.country || 10,
|
||||
number: NEXT_PUBLIC_HOME_LOCATION_COUNT,
|
||||
icon: <DotLottieReact className='size-24' data={LocationsLittie} autoplay loop />,
|
||||
},
|
||||
];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user