Skip to content

Commit 66ea3be

Browse files
committed
fixed potd issue
1 parent 7f2f853 commit 66ea3be

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

client-test/src/components/Challenges/index.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -272,16 +272,21 @@ const Challenges: React.FC = () => {
272272
const checkPotdSolved = async () => {
273273
setIsRefreshing(true);
274274
try {
275-
await fetchDailyChallenge();
275+
const response = await axios.post(`${import.meta.env.VITE_API_BASE_URL}/api/challenges/check-potd-status`, {
276+
dailyChallengeId: dailyProblem?._id
277+
}, {
278+
withCredentials: true
279+
});
280+
const { message, isSolved } = response.data;
276281
if (isSolved) {
277-
toast.success("Problem of the Day is Solved!");
278-
}
279-
else {
280-
toast.error("Haven't solved the Problem of the Day yet.");
282+
window.location.reload();
283+
toast.success(message || "Problem of the Day marked as solved!");
284+
} else {
285+
toast.error(message || "Haven't solved the Problem of the Day yet.");
281286
}
282-
} catch (error) {
287+
} catch (error: any) {
283288
console.error("Error updating POTD status:", error);
284-
toast.error("Error Checking for Status");
289+
toast.error("Challenge NOT solved Today");
285290
} finally {
286291
setIsRefreshing(false);
287292
}

client-test/src/components/ProfilePage/index.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,7 @@ export default function ProfilePage() {
583583
handle: profileUser.leetCode?.username || "-",
584584
solved: profileUser.leetCode?.solved,
585585
rating: profileUser.leetCode?.rating,
586+
rank: profileUser.leetCode?.rank,
586587
color: "#FFA116",
587588
type: "leetcode",
588589
},
@@ -591,6 +592,7 @@ export default function ProfilePage() {
591592
handle: profileUser.codeforces?.username || "-",
592593
solved: profileUser.codeforces?.solved,
593594
rating: profileUser.codeforces?.rating,
595+
rank: profileUser.codeforces?.rank,
594596
color: "#318CE7",
595597
type: "codeforces",
596598
},
@@ -607,11 +609,11 @@ export default function ProfilePage() {
607609
<div className="text-xs text-muted-foreground">@{platform.handle}</div>
608610
</div>
609611
<div className="flex flex-col items-end space-y-1 text-right">
610-
{platform.solved !== undefined && platform.type !== "codechef" && (
612+
{platform.rank !== undefined && (
611613
<div className="text-xs">
612-
<span className="text-muted-foreground">Solved:</span>{" "}
614+
<span className="text-muted-foreground">Rank:</span>{" "}
613615
{platform.handle !== "-" ? (
614-
<span className="font-semibold">{platform.solved}</span>
616+
<span className="font-semibold">{platform.rank}</span>
615617
) : (
616618
<span className="font-semibold">--</span>
617619
)}

client-test/src/components/ProfilePage/platform-verification.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,10 @@ export function PlatformVerification({ platformType, isLinked, username, stats,
159159
<div className="text-xs text-muted-foreground">@{username}</div>
160160
</div>
161161
<div className="flex flex-col items-end space-y-1 text-right">
162-
{stats?.solved !== undefined && platformType !== "codechef" && (
162+
{stats?.rank !== undefined && (
163163
<div className="text-xs">
164-
<span className="text-muted-foreground">Solved:</span>{" "}
165-
<span className="font-semibold">{stats.solved}</span>
164+
<span className="text-muted-foreground">Rank:</span>{" "}
165+
<span className="font-semibold">{stats.rank}</span>
166166
</div>
167167
)}
168168
{platformType === "codechef" && stats?.rating !== undefined && (

0 commit comments

Comments
 (0)