Skip to content

Commit 6e562f0

Browse files
committed
Add buttons to refresh progress and view GH profile
1 parent 9e64334 commit 6e562f0

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

src/Dashboard.tsx

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { useMemo } from "react";
1+
import { useCallback, useMemo } from "react";
2+
import { HiOutlineExternalLink } from "react-icons/hi";
3+
import { IoArrowBack } from "react-icons/io5";
4+
import { MdOutlineRefresh } from "react-icons/md";
25
import { Link, useParams } from "react-router";
36
import { ProblemSet, useGetProblemSetsQuery } from "./api/queries/get_problem_sets";
47
import { useGetUserQuery } from "./api/queries/get_user";
@@ -18,6 +21,8 @@ function Dashboard() {
1821
const {
1922
data: userProgress,
2023
isLoading: isUserProgressLoading,
24+
isRefetchError: isUserProgressRefetching,
25+
refetch: refetchUserProgress,
2126
} = useGetUserProgressQuery(user?.id);
2227

2328
const parsedUserProgress = useMemo(() => {
@@ -66,17 +71,29 @@ function Dashboard() {
6671
return sortedGroups
6772
}, [problemSets, isProblemSetsLoading, parsedUserProgress])
6873

74+
const refreshUserProgress = useCallback(async () => {
75+
await refetchUserProgress()
76+
}, [refetchUserProgress])
77+
6978
return (
7079
<div className="lg:w-[40%] my-16 mx-auto md:w-[60%] w-[80%]">
7180
<h3 className="text-2xl font-bold mb-4">Git Mastery Progress Dashboard</h3>
7281
<div className="mb-6">
73-
<Link to="/" className="text-gray-500 italic mb-2">← Back to search</Link>
74-
<h1 className="text-4xl font-bold mb-4">@{username}</h1>
82+
<Link to="/" className="text-gray-500 italic mb-2 flex flex-row gap-2 items-center"><IoArrowBack className="inline-block" /> Back to search</Link>
83+
<div className="flex flex-row justify-between items-center mb-4">
84+
<div className="flex flex-row gap-2 items-center">
85+
<h1 className="text-4xl font-bold">@{username}</h1>
86+
<a target="_blank" className="hover:cursor-pointer text-gray-500" href={`https://github.com/${username}`}>
87+
<HiOutlineExternalLink size={24} />
88+
</a>
89+
</div>
90+
<button type="button" className="hover:cursor-pointer" onClick={refreshUserProgress}><MdOutlineRefresh size={24} color="text-gray-500" /></button>
91+
</div>
7592
<p className="text-gray-700 font-semibold">Find your progress for the various Git Mastery problem sets.</p>
7693
<p className="text-gray-700">To view all problem sets, visit the <a className="text-blue-800 underline" href="https://github.com/git-mastery/problems-directory">problems directory</a>.</p>
7794
</div>
7895
<div>
79-
{(isUserLoading || isUserProgressLoading || isProblemSetsLoading) ? (
96+
{(isUserLoading || isUserProgressLoading || isUserProgressRefetching || isProblemSetsLoading) ? (
8097
<div className="flex justify-center">
8198
<Spinner />
8299
</div>

0 commit comments

Comments
 (0)