44// This is the heart of our app, designed to be simple but powerful
55
66import { useState , useCallback , useEffect , useMemo , memo } from 'react' ;
7- import { useUser } from '@auth0/nextjs-auth0/client' ;
87import dynamic from 'next/dynamic' ;
98import { motion , AnimatePresence } from 'framer-motion' ;
109import { toast } from 'sonner' ;
@@ -14,7 +13,6 @@ import type { SlidePresentation, ThemeVariant, PresentationFormat } from '@/type
1413
1514// Custom hooks for features
1615import { useKeyboardShortcuts , SHORTCUTS } from '@/hooks/useKeyboardShortcuts' ;
17- import ClientOnly from '@/components/ClientOnly' ;
1816
1917// UI Components
2018import ProgressBar from '@/components/ui/ProgressBar' ;
@@ -72,18 +70,17 @@ const useTheme = () => {
7270 if ( savedTheme ) {
7371 setTheme ( savedTheme ) ;
7472 } else {
75- // Detect system preference
76- const prefersDark = window . matchMedia ( '(prefers-color-scheme: dark)' ) . matches ;
77- setTheme ( prefersDark ? 'dark' : 'light' ) ;
73+ // Default to dark theme to prevent hydration mismatch
74+ setTheme ( 'dark' ) ;
7875 }
7976 }
8077 } , [ ] ) ;
8178
8279 // Apply theme changes
8380 useEffect ( ( ) => {
84- document . documentElement . classList . toggle ( 'dark' , theme === 'dark' ) ;
85- document . documentElement . classList . toggle ( 'light' , theme === 'light' ) ;
8681 if ( typeof window !== 'undefined' ) {
82+ document . documentElement . classList . toggle ( 'dark' , theme === 'dark' ) ;
83+ document . documentElement . classList . toggle ( 'light' , theme === 'light' ) ;
8784 window . localStorage . setItem ( 'theme' , theme ) ;
8885 }
8986 } , [ theme ] ) ;
@@ -92,88 +89,19 @@ const useTheme = () => {
9289} ;
9390
9491/**
95- * Simple Auth Header component with hydration-safe rendering
92+ * Simple Header component - static text only
9693 */
97- const AuthHeader = memo < { user : any } > ( ( { user } ) => (
94+ const SimpleHeader = memo ( ( ) => (
9895 < div className = "fixed top-4 right-4 z-50" >
99- { user ? (
100- < div className = "flex items-center space-x-3 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 px-4 py-2 rounded-lg shadow" >
101- { user . picture && (
102- < img
103- src = { user . picture }
104- alt = "Profile"
105- className = "w-8 h-8 rounded-full"
106- />
107- ) }
108- < span className = "text-sm text-gray-900 dark:text-white" >
109- { user . name || user . email || "User" }
110- </ span >
111- < a
112- href = "/api/auth/logout"
113- className = "text-sm text-gray-500 hover:text-gray-700 transition-colors"
114- >
115- Sign out
116- </ a >
117- </ div >
118- ) : (
119- < a
120- href = "/api/auth/login"
121- className = "bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-lg text-sm transition-colors"
122- >
123- Sign in
124- </ a >
125- ) }
126- </ div >
127- ) ) ;
128-
129- AuthHeader . displayName = 'AuthHeader' ;
130-
131- /**
132- * Simple loading state component
133- */
134- const LoadingState = memo ( ( ) => (
135- < div className = "min-h-screen bg-white dark:bg-gray-900 flex items-center justify-center" >
136- < div className = "text-center" >
137- < div className = "w-8 h-8 border-2 border-gray-300 border-t-blue-500 rounded-full animate-spin mx-auto mb-4" />
138- < h2 className = "text-xl text-gray-900 dark:text-white" > Loading...</ h2 >
96+ < div className = "bg-white/90 dark:bg-gray-800/90 backdrop-blur border border-gray-200 dark:border-gray-700 px-4 py-2 rounded-lg shadow" >
97+ < span className = "text-sm text-gray-900 dark:text-white font-medium" >
98+ ✨ Snap2Slides
99+ </ span >
139100 </ div >
140101 </ div >
141102) ) ;
142103
143- LoadingState . displayName = 'LoadingState' ;
144-
145- /**
146- * Memoized error state component
147- */
148- const ErrorState = memo < { error : string } > ( ( { error } ) => (
149- < div className = "min-h-screen relative overflow-hidden bg-white dark:bg-black" >
150- < MinimalBackground />
151- < div className = "relative z-10 min-h-screen flex flex-col items-center justify-center p-6" >
152- < motion . div
153- initial = { { opacity : 0 , scale : 0.95 } }
154- animate = { { opacity : 1 , scale : 1 } }
155- transition = { { duration : 0.6 , ease : [ 0.16 , 1 , 0.3 , 1 ] } }
156- className = "backdrop-blur-xl bg-white/80 dark:bg-gray-900/80 border border-gray-200 dark:border-gray-700 p-8 rounded-3xl shadow-2xl text-center max-w-md"
157- >
158- < div className = "w-16 h-16 bg-red-100 dark:bg-red-900/20 rounded-full flex items-center justify-center mx-auto mb-6" >
159- < svg className = "w-8 h-8 text-red-500" fill = "none" stroke = "currentColor" viewBox = "0 0 24 24" >
160- < path strokeLinecap = "round" strokeLinejoin = "round" strokeWidth = "2" d = "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z" />
161- </ svg >
162- </ div >
163- < h2 className = "text-2xl font-semibold mb-4 text-gray-900 dark:text-white" > Authentication Error</ h2 >
164- < p className = "text-gray-600 dark:text-gray-300 mb-6" > { error } </ p >
165- < button
166- onClick = { ( ) => window . location . href = '/api/auth/login' }
167- className = "bg-blue-500 hover:bg-blue-600 text-white px-6 py-2 rounded-xl transition-all duration-200"
168- >
169- Try Again
170- </ button >
171- </ motion . div >
172- </ div >
173- </ div >
174- ) ) ;
175-
176- ErrorState . displayName = 'ErrorState' ;
104+ SimpleHeader . displayName = 'SimpleHeader' ;
177105
178106// Simple dropzone component
179107const EnhancedDropzone : React . FC < {
@@ -464,18 +392,6 @@ const OutputFormatSelector: React.FC<{
464392} ;
465393
466394export default function HomePage ( ) {
467- return (
468- < ClientOnly fallback = { < LoadingState /> } >
469- < AuthenticatedApp />
470- </ ClientOnly >
471- ) ;
472- }
473-
474- // Separate component that handles authentication
475- function AuthenticatedApp ( ) {
476- // Auth state - now safely in client-only component
477- const { user, error : userError , isLoading : userLoading } = useUser ( ) ;
478-
479395 // Form state
480396 const [ selectedFile , setSelectedFile ] = useState < File | null > ( null ) ;
481397 const [ prompt , setPrompt ] = useState < string > ( '' ) ;
@@ -782,16 +698,12 @@ function AuthenticatedApp() {
782698 [ SHORTCUTS . HELP ] : ( ) => setShowHelpModal ( true )
783699 } , { enabled : ! isAnalyzing } ) ;
784700
785- // Loading and error states
786- if ( userLoading ) return < LoadingState /> ;
787- if ( userError ) return < ErrorState error = { ( userError as Error ) ?. message || 'An error occurred' } /> ;
788-
789701 // Editor view - Apple-style presentation editor
790702 if ( viewMode === 'editor' && currentPresentation ) {
791703 return (
792704 < div className = "min-h-screen bg-white dark:bg-black transition-colors duration-500" >
793705 < MinimalBackground />
794- < AuthHeader user = { user } />
706+ < SimpleHeader />
795707
796708 { /* Header */ }
797709 < div className = "bg-white/80 dark:bg-black/80 backdrop-blur-xl border-b border-gray-200/50 dark:border-gray-700/50 p-3 sm:p-4" >
@@ -859,7 +771,7 @@ function AuthenticatedApp() {
859771 return (
860772 < div className = "min-h-screen bg-white dark:bg-black transition-colors duration-500" >
861773 < MinimalBackground />
862- < AuthHeader user = { user } />
774+ < SimpleHeader />
863775
864776 { /* Main Content */ }
865777 < main className = "relative z-10 min-h-screen flex flex-col items-center justify-start px-4 sm:px-6 py-6 sm:py-12 md:py-20" >
0 commit comments