gitscope
← marzneshin / v0.7.0 / dashboard/src/routes/_dashboard/index.lazy.tsx
https://dev.kronoz.win/r/marzneshin.git
dashboard/src/routes/_dashboard/index.lazy.tsx · TypeScript
Blame Raw
 1import { createLazyFileRoute } from '@tanstack/react-router'
 2import { Page } from '@marzneshin/common/components'
 3import { UsersStatsWidget, useUsersStatsQuery } from '@marzneshin/modules/users'
 4import { TotalTrafficsWidget } from '@marzneshin/features/total-traffic-widget'
 5import { useTranslation } from 'react-i18next'
 6import { FC } from 'react'
 7
 8export const DashboardPage: FC = () => {
 9  const { t } = useTranslation()
10  const { data } = useUsersStatsQuery()
11
12  return (
13    <Page className="flex flex-col gap-4 w-full" title={t('home')}>
14      <div className={`grid grid-cols-1 md:grid-cols-12 gap-4`}>
15        <div className={data.total !== 0 ? 'md:col-span-8' : 'md:col-span-12'}>
16          <TotalTrafficsWidget />
17        </div>
18
19        {data.total !== 0 && (
20          <div className="md:col-span-4">
21            <UsersStatsWidget {...data} />
22          </div>
23        )}
24      </div>
25    </Page>
26  )
27}
28
29export const Route = createLazyFileRoute('/_dashboard/')({
30  component: () => <DashboardPage />,
31})