Skip to content

Commit b4ab59a

Browse files
committed
resolved build issues
1 parent 50597d3 commit b4ab59a

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

client-test/src/components/Admin/AdminChallenges.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use client";
22

33
import { AnimatePresence, motion } from "framer-motion";
4-
import { Toast } from "react-hot-toast";
4+
import { toast } from "react-hot-toast";
55
import {
66
Calendar,
77
ChevronDown,
@@ -22,7 +22,6 @@ import React, {
2222
} from "react";
2323
import { useNavigate } from 'react-router-dom';
2424
import { useAdminStore } from "@/context/AdminContext";
25-
import { solvedChallenges } from "@/lib/potdchallenge";
2625

2726
// Interfaces
2827
interface Challenge {
@@ -248,7 +247,6 @@ SkeletonLoader.displayName = "SkeletonLoader";
248247
const 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: "",

client-test/src/components/Admin/Dashboard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ export default function Dashboard() {
465465
position: 'right',
466466
fill: '#666',
467467
fontSize: 12,
468-
formatter: (value: { users: number }) => value.user
468+
formatter: (value: { users: number }) => value.users
469469
}}
470470
/>
471471
</BarChart>

0 commit comments

Comments
 (0)