@@ -9,6 +9,7 @@ import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover
99import { Skeleton } from '@/components/ui/skeleton'
1010import { AnalyticsCharts } from '@/components/dashboard/AnalyticsCharts'
1111import { useCompanyContext } from '@/contexts/CompanyContext'
12+ import { usePendingInvitationRedirect } from '@/lib/hooks/usePendingInvitationRedirect'
1213import { CompanyAnalytics } from '@/types/company'
1314import { format , subDays , startOfMonth , endOfMonth , subMonths } from 'date-fns'
1415import { CalendarIcon , AlertCircle , TrendingUp } from 'lucide-react'
@@ -25,6 +26,7 @@ export default function AnalyticsPage() {
2526 const params = useParams ( )
2627 const companySlug = params ?. slug as string
2728 const { currentCompany, loading : companyLoading } = useCompanyContext ( )
29+ const isPendingInvitation = usePendingInvitationRedirect ( )
2830
2931 const [ analytics , setAnalytics ] = useState < CompanyAnalytics [ ] > ( [ ] )
3032 const [ loading , setLoading ] = useState ( true )
@@ -67,6 +69,14 @@ export default function AnalyticsPage() {
6769 }
6870 } , [ currentCompany , fetchAnalytics ] )
6971
72+ if ( companyLoading || isPendingInvitation ) {
73+ return (
74+ < div className = "flex items-center justify-center min-h-[60vh]" >
75+ < div className = "animate-spin rounded-full h-8 w-8 border-b-2 border-primary" > </ div >
76+ </ div >
77+ )
78+ }
79+
7080 const handlePresetChange = ( preset : PresetRange ) => {
7181 setSelectedPreset ( preset )
7282 const today = new Date ( )
0 commit comments