@@ -94,6 +94,7 @@ const Challenges: React.FC = () => {
9494 setIsDailyLoading ( true ) ;
9595 const params = user ? { userId : user . _id } : { } ;
9696 const res = await axios . get ( `${ import . meta. env . VITE_API_BASE_URL } /api/challenges/daily` , { params } ) ;
97+
9798 if ( res . data ) {
9899 const challenge = res . data ;
99100 const formattedChallenge : Challenge = {
@@ -115,9 +116,16 @@ const Challenges: React.FC = () => {
115116
116117 setDailyProblem ( formattedChallenge ) ;
117118 setIsSolved ( challenge . isSolved || false ) ;
119+ } else {
120+ // No daily challenge data
121+ setDailyProblem ( null ) ;
122+ setIsSolved ( false ) ;
118123 }
119124 } catch ( error ) {
120125 console . error ( "Failed to fetch daily challenge:" , error ) ;
126+ // Backend returns 404 when no challenge is posted for today
127+ setDailyProblem ( null ) ;
128+ setIsSolved ( false ) ;
121129 } finally {
122130 setIsDailyLoading ( false ) ;
123131 }
@@ -219,6 +227,16 @@ const Challenges: React.FC = () => {
219227 }
220228 } , [ user , activeTab ] ) ;
221229
230+ // Show toast when user is not logged in
231+ useEffect ( ( ) => {
232+ if ( ! user ) {
233+ toast . error ( "Sign in to view status and solutions" , {
234+ duration : 2000 ,
235+ position : 'bottom-right' ,
236+ } ) ;
237+ }
238+ } , [ user ] ) ;
239+
222240 // Reset to page 1 when filters change
223241 useEffect ( ( ) => {
224242 if ( filterOptions . categories . length > 0 ) {
@@ -386,9 +404,9 @@ const Challenges: React.FC = () => {
386404 < h3 className = "text-xl sm:text-2xl font-bold text-gray-200 dark:text-gray-800 line-clamp-1" >
387405 { dailyProblem . title }
388406 </ h3 >
389- < p className = "text-gray-400 dark:text-gray-600 text-sm line-clamp-2" >
407+ { /* <p className="text-gray-400 dark:text-gray-600 text-sm line-clamp-2">
390408 {dailyProblem.description}
391- </ p >
409+ </p> */ }
392410 < div className = "flex flex-wrap gap-2" >
393411 { dailyProblem . categories . map ( ( cat : any ) => (
394412 < Badge
@@ -439,7 +457,21 @@ const Challenges: React.FC = () => {
439457 </ span >
440458 </ div >
441459 </ div >
442- ) : null }
460+ ) : (
461+ < div className = "mt-6 bg-gray-800 dark:bg-muted rounded-xl p-4 sm:p-6 flex flex-col items-center justify-center text-center space-y-4 h-40" >
462+ < div className = "bg-amber-500/20 dark:bg-amber-500/30 p-3 rounded-full" >
463+ < Clock className = "h-8 w-8 text-amber-500" />
464+ </ div >
465+ < div className = "space-y-2" >
466+ < h3 className = "text-lg font-semibold text-gray-200 dark:text-gray-800" >
467+ No Problem Posted Today
468+ </ h3 >
469+ < p className = "text-gray-400 dark:text-gray-600 text-sm" >
470+ Please wait until a new daily challenge is posted. Check back soon!
471+ </ p >
472+ </ div >
473+ </ div >
474+ ) }
443475 </ CardContent >
444476 </ Card >
445477
@@ -625,7 +657,7 @@ const Challenges: React.FC = () => {
625657 < Calendar className = "h-3 w-3 mr-1" /> { problem . date }
626658 </ div >
627659 < h3 className = "text-lg font-bold text-foreground" > { problem . title } </ h3 >
628- < p className = "text-muted-foreground text-sm line-clamp-2" > { problem . description } </ p >
660+ { /* <p className="text-muted-foreground text-sm line-clamp-2">{problem.description}</p> */ }
629661 < div className = "flex flex-wrap gap-1.5" >
630662 { problem . categories . map ( ( cat : any ) => (
631663 < Badge
0 commit comments