@@ -5,15 +5,15 @@ import { useRouter } from 'next/navigation'
55import { Header } from '@/components/layout/Header'
66import { PoliticianEvaluation } from '@/components/evaluation/PoliticianEvaluation'
77import { useEvaluationSession } from '@/contexts/EvaluationSessionContext'
8- import { Loader } from '@/components/ui/Spinner'
8+ import { CenteredCard } from '@/components/ui/CenteredCard'
9+ import { Button } from '@/components/ui/Button'
10+ import { Spinner } from '@/components/ui/Spinner'
911import { useTutorial } from '@/contexts/TutorialContext'
1012import { useUserPreferences } from '@/contexts/UserPreferencesContext'
11- import Link from 'next/link'
1213
1314export default function EvaluatePage ( ) {
1415 const router = useRouter ( )
15- const { currentPolitician, loading, loadPoliticians, isSessionComplete, enrichmentMeta } =
16- useEvaluationSession ( )
16+ const { currentPolitician, loading, isSessionComplete, enrichmentMeta } = useEvaluationSession ( )
1717 const { completeBasicTutorial, completeAdvancedTutorial } = useTutorial ( )
1818 const { isAdvancedMode } = useUserPreferences ( )
1919
@@ -33,44 +33,61 @@ export default function EvaluatePage() {
3333 }
3434 } , [ isSessionComplete , router ] )
3535
36- return (
37- < >
38- < Header />
36+ // Determine if we're in a loading state (fetching or waiting for enrichment)
37+ const isWaitingForData =
38+ loading || ( enrichmentMeta ?. has_enrichable_politicians !== false && ! currentPolitician )
3939
40- { currentPolitician ? (
40+ // All caught up: no politician and nothing left to enrich
41+ const isAllCaughtUp =
42+ ! currentPolitician && ! loading && enrichmentMeta ?. has_enrichable_politicians === false
43+
44+ if ( currentPolitician ) {
45+ return (
46+ < >
47+ < Header />
4148 < PoliticianEvaluation key = { currentPolitician . id } politician = { currentPolitician } />
42- ) : (
43- < main className = "bg-gray-50 grid place-items-center py-12 px-4 sm:px-6 lg:px-8 min-h-0 overflow-y-auto" >
44- < div className = "text-center max-w-2xl" >
45- { loading || enrichmentMeta ?. is_enriching ? (
46- < Loader
47- message = {
48- enrichmentMeta ?. is_enriching
49- ? 'Enriching politician data...'
50- : 'Loading politician data...'
51- }
52- />
53- ) : (
54- < div className = "bg-gray-50 border border-gray-200 rounded-md p-4" >
55- < p className = "text-gray-600" >
56- No politicians available for your current filters. You can change your{ ' ' }
57- < Link href = "/" className = "text-gray-700 hover:text-gray-900 underline" >
58- filters
59- </ Link >
60- , or{ ' ' }
61- < button
62- onClick = { loadPoliticians }
63- className = "text-gray-700 hover:text-gray-900 underline cursor-pointer bg-transparent border-0 p-0 font-inherit"
64- >
65- reload
66- </ button >
67- .
68- </ p >
69- </ div >
70- ) }
49+ </ >
50+ )
51+ }
52+
53+ if ( isAllCaughtUp ) {
54+ return (
55+ < >
56+ < Header />
57+ < CenteredCard emoji = "🎉" title = "You're all caught up!" >
58+ < p className = "mb-6" >
59+ No more politicians to evaluate for your current filters. Try different filters to
60+ continue contributing.
61+ </ p >
62+ < Button href = "/" size = "large" >
63+ Start New Session
64+ </ Button >
65+ </ CenteredCard >
66+ </ >
67+ )
68+ }
69+
70+ if ( isWaitingForData ) {
71+ return (
72+ < >
73+ < Header />
74+ < CenteredCard emoji = "🔍" title = "Finding politicians..." >
75+ < div className = "flex justify-center" >
76+ < Spinner />
7177 </ div >
72- </ main >
73- ) }
78+ </ CenteredCard >
79+ </ >
80+ )
81+ }
82+
83+ return (
84+ < >
85+ < Header />
86+ < CenteredCard emoji = "🔍" title = "Loading..." >
87+ < div className = "flex justify-center" >
88+ < Spinner />
89+ </ div >
90+ </ CenteredCard >
7491 </ >
7592 )
7693}
0 commit comments