/*
Copyright (C) 2023-2026 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
For commercial licensing, please contact support@quantumnous.com
*/
import { useNavigate, useSearch } from '@tanstack/react-router'
import { useTranslation } from 'react-i18next'
import { Skeleton } from '@/components/ui/skeleton'
import { PublicLayout } from '@/components/layout'
import { PageTransition } from '@/components/page-transition'
import {
MarketShareSection,
ModelsSection,
PulseSection,
RankingsHero,
} from './components'
import { useRankings } from './hooks/use-rankings'
import type { RankingPeriod } from './types'
const VALID_PERIODS: RankingPeriod[] = ['today', 'week', 'month', 'year', 'all']
export function Rankings() {
const { t } = useTranslation()
const search = useSearch({ from: '/rankings/' })
const navigate = useNavigate()
const period: RankingPeriod = VALID_PERIODS.includes(
search.period as RankingPeriod
)
? (search.period as RankingPeriod)
: 'week'
const rankingsQuery = useRankings(period)
const snapshot = rankingsQuery.data?.data
const handlePeriodChange = (next: RankingPeriod) => {
navigate({
to: '/rankings',
search: (prev) => ({ ...prev, period: next }),
})
}
return (
{rankingsQuery.isLoading ? (
) : !snapshot ? (
) : (
<>
>
)}
)
}
function RankingsLoading() {
return (
)
}
function RankingsError(props: { message: string }) {
const { t } = useTranslation()
return (
{t('Unable to load rankings')}
{props.message}
)
}