11"use client" ;
22
33import { AnimatePresence , motion } from "framer-motion" ;
4- import { Toast } from "react-hot-toast" ;
4+ import { toast } from "react-hot-toast" ;
55import {
66 Calendar ,
77 ChevronDown ,
@@ -22,7 +22,6 @@ import React, {
2222} from "react" ;
2323import { useNavigate } from 'react-router-dom' ;
2424import { useAdminStore } from "@/context/AdminContext" ;
25- import { solvedChallenges } from "@/lib/potdchallenge" ;
2625
2726// Interfaces
2827interface Challenge {
@@ -248,7 +247,6 @@ SkeletonLoader.displayName = "SkeletonLoader";
248247const ProblemCard = memo (
249248 ( { challenge, isToday = false } : { challenge : Challenge ; isToday ?: boolean } ) => {
250249 const [ isLoading , setIsLoading ] = useState ( false ) ;
251- const { fetchChallenges } = useAdminStore ( ) ;
252250 const [ stats , setStats ] = useState ( { usersCount : 0 , challengesCount : 0 , solvedChallenges : 0 } ) ;
253251
254252 useEffect ( ( ) => {
@@ -269,7 +267,9 @@ const ProblemCard = memo(
269267 const handleUpdatePOTD = useCallback ( ( ) => {
270268 // Navigate to AddChallenge page and just send a flag
271269 setIsLoading ( true ) ;
272- setTimeout ( 50000 )
270+ setTimeout ( ( ) => {
271+ setIsLoading ( false ) ;
272+ } , 1000 ) ;
273273 navigate ( "/codingclubadmin/addchallenge" , {
274274 state : { fromAdmin : true } ,
275275 } ) ;
@@ -296,14 +296,18 @@ const ProblemCard = memo(
296296 } ) ;
297297 } ;
298298
299+ const solvedPercentage = challenge . solvedUsersCount && stats . usersCount > 0
300+ ? ( challenge . solvedUsersCount / stats . usersCount ) * 100
301+ : 0 ;
302+
299303 return (
300304 < >
301305 < div className = "overflow-hidden px-1" >
302306 < div className = "h-1 rounded-full overflow-hidden" >
303307 < div
304- style = { { width : `${ challenge . solvedPercentage / stats . usersCount } %` } }
308+ style = { { width : `${ solvedPercentage } %` } }
305309 className = "h-2 bg-blue-600 dark:bg-blue-500"
306- aria-label = { `${ challenge . solvedPercentage / stats . usersCount } % solved` }
310+ aria-label = { `${ solvedPercentage } % solved` }
307311 />
308312 </ div >
309313 </ div >
@@ -381,7 +385,7 @@ const ProblemCard = memo(
381385 </ span >
382386 </ div >
383387 < span className = "text-sm font-medium text-blue-400 dark:text-blue-600" >
384- { challenge . solvedUsersCount / stats . usersCount || 0 } %
388+ { solvedPercentage . toFixed ( 2 ) } %
385389 </ span >
386390 </ div >
387391 </ div >
@@ -472,7 +476,7 @@ const AdminChallenges: React.FC = () => {
472476 fetchStats ( ) ;
473477 } , [ ] ) ;
474478
475- const [ statistics , setStatistics ] = useState < Statistics > ( {
479+ const [ statistics ] = useState < Statistics > ( {
476480 totalProblems : 0 ,
477481 averageSolveRate : 0 ,
478482 topPerformer : "" ,
0 commit comments