Skip to content

Commit ccce62f

Browse files
authored
Merge branch 'main' into fix/remove_team_from_judge
2 parents a297eee + c6f43fe commit ccce62f

File tree

4 files changed

+16
-21
lines changed

4 files changed

+16
-21
lines changed

app/(pages)/_hooks/useJudgeSubmissions.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,19 @@ import Submission from '@typeDefs/submission';
88
import Team from '@typeDefs/team';
99
import { HttpError } from '@utils/response/Errors';
1010

11-
export function useJudgeSubmissions(judge_id: string) {
11+
export function useJudgeSubmissions(judge_id: string | undefined) {
1212
const [loading, setLoading] = useState<boolean>(true);
1313
const [submissions, setSubmissions] = useState<any>(null);
1414
const [teams, setTeams] = useState<any>(null);
1515
const [scoredTeams, setScoredTeams] = useState<any>(null);
1616
const [unscoredTeams, setUnscoredTeams] = useState<any>(null);
1717
const [error, setError] = useState<string | null>(null);
1818

19-
const updateSubmissions = useCallback(async (judge_id: string) => {
19+
const fetchSubmissions = useCallback(async () => {
20+
setLoading(true);
21+
if (judge_id === undefined) {
22+
return;
23+
}
2024
try {
2125
const submissionsRes = await getManySubmissions({
2226
judge_id: {
@@ -102,11 +106,11 @@ export function useJudgeSubmissions(judge_id: string) {
102106
setError(error.message);
103107
setLoading(false);
104108
}
105-
}, []);
109+
}, [judge_id]);
106110

107111
useEffect(() => {
108-
updateSubmissions(judge_id);
109-
}, [judge_id, updateSubmissions]);
112+
fetchSubmissions();
113+
}, [judge_id, fetchSubmissions]);
110114

111115
return {
112116
submissions,
@@ -115,6 +119,6 @@ export function useJudgeSubmissions(judge_id: string) {
115119
unscoredTeams,
116120
loading,
117121
error,
118-
updateSubmissions,
122+
fetchSubmissions,
119123
};
120124
}

app/(pages)/judges/_components/Projects/ProjectPage.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ const ProjectPage = () => {
3737
);
3838
const { data: session } = useSession();
3939
const user = session?.user;
40-
const userId = user?.id ?? '';
40+
const userId = user?.id;
4141

42-
const { scoredTeams, unscoredTeams, loading, error, updateSubmissions } =
42+
const { scoredTeams, unscoredTeams, loading, error, fetchSubmissions } =
4343
useJudgeSubmissions(userId);
4444

4545
if (loading) {
@@ -51,7 +51,7 @@ const ProjectPage = () => {
5151
}
5252

5353
return (
54-
<div className="flex flex-col h-full bg-[#F2F2F7]">
54+
<div className="flex flex-col h-full">
5555
<Link
5656
href="/judges"
5757
className="flex items-center ml-[20px] gap-[12px] mt-[59px]"
@@ -90,7 +90,7 @@ const ProjectPage = () => {
9090
) : selectedButton === 'Unjudged' ? (
9191
<UnscoredPage
9292
teams={unscoredTeams}
93-
revalidateData={() => updateSubmissions(userId)}
93+
revalidateData={() => fetchSubmissions()}
9494
/>
9595
) : (
9696
<ScoredPage teams={scoredTeams} />

app/(pages)/judges/_components/Projects/ScoredPage.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import Link from 'next/link';
21
import Team from '@typeDefs/team';
32
import ProjectTab from './ProjectTab';
43
import ProjectsEmptyState from './EmptyState';
@@ -17,15 +16,7 @@ const ScoredPage = ({ teams }: ScoredPageProps) => {
1716
}
1817
/>
1918
) : (
20-
teams.map((team) => (
21-
<Link
22-
key={team._id}
23-
href={`/judges/project/${team._id}`}
24-
className="block"
25-
>
26-
<ProjectTab team={team} />
27-
</Link>
28-
))
19+
teams.map((team) => <ProjectTab key={team._id} team={team} />)
2920
)}
3021
</div>
3122
);

app/(pages)/judges/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default function JudgeBaseLayout({
44
children: React.ReactNode;
55
}) {
66
return (
7-
<div className="max-w-[500px] min-w-[370px] ml-auto mr-auto">
7+
<div className="min-h-screen max-w-[500px] min-w-[370px] ml-auto mr-auto bg-[#F2F2F7]">
88
{children}
99
</div>
1010
);

0 commit comments

Comments
 (0)