Skip to content

Commit 7d7935a

Browse files
committed
fix: Merge branch 'main' of github.com:boundlessfi/boundless into production
2 parents 5d96e88 + 5c81ec0 commit 7d7935a

4 files changed

Lines changed: 59 additions & 31 deletions

File tree

app/(landing)/organizations/[id]/hackathons/[hackathonId]/judging/page.tsx

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,10 @@ export default function JudgingPage() {
103103
'date'
104104
);
105105
const [viewMode, setViewMode] = useState<'detailed' | 'compact'>('detailed');
106-
const [currentPage, setCurrentPage] = useState(1);
107-
const [totalPages, setTotalPages] = useState(1);
106+
const [submissionsPage, setSubmissionsPage] = useState(1);
107+
const [submissionsTotalPages, setSubmissionsTotalPages] = useState(1);
108+
const [resultsPage, setResultsPage] = useState(1);
109+
const [resultsTotalPages, setResultsTotalPages] = useState(1);
108110
const [isFetchingSubmissions, setIsFetchingSubmissions] = useState(false);
109111

110112
// Debounce search term
@@ -235,7 +237,7 @@ export default function JudgingPage() {
235237
const res = await getJudgingResults(
236238
organizationId,
237239
hackathonId,
238-
currentPage,
240+
resultsPage,
239241
10,
240242
submissionSearchTerm,
241243
sortBy,
@@ -247,7 +249,7 @@ export default function JudgingPage() {
247249
setJudgingSummary(res.data);
248250

249251
if (res.data.pagination?.totalPages) {
250-
setTotalPages(res.data.pagination.totalPages);
252+
setResultsTotalPages(res.data.pagination.totalPages);
251253
}
252254

253255
lastFetchedRef.current['results'] = now;
@@ -277,7 +279,7 @@ export default function JudgingPage() {
277279
setIsFetchingResults(false);
278280
}
279281
},
280-
[organizationId, hackathonId]
282+
[organizationId, hackathonId, resultsPage, submissionSearchTerm, sortBy]
281283
);
282284

283285
const fetchWinners = useCallback(
@@ -319,7 +321,7 @@ export default function JudgingPage() {
319321
setIsFetchingWinners(false);
320322
}
321323
},
322-
[organizationId, hackathonId]
324+
[organizationId, hackathonId, submissionSearchTerm]
323325
);
324326

325327
const fetchData = useCallback(async () => {
@@ -334,7 +336,7 @@ export default function JudgingPage() {
334336
// Use the new optimized endpoint that returns submissions, criteria and myScore in one go
335337
const submissionsRes = await getJudgingSubmissionsForJudge(
336338
hackathonId,
337-
currentPage,
339+
submissionsPage,
338340
12,
339341
submissionSearchTerm,
340342
sortBy,
@@ -357,9 +359,9 @@ export default function JudgingPage() {
357359
setCriteria(critData || []);
358360

359361
if (pagination?.totalPages) {
360-
setTotalPages(pagination.totalPages);
362+
setSubmissionsTotalPages(pagination.totalPages);
361363
} else if (pagination?.total) {
362-
setTotalPages(Math.ceil(pagination.total / 12));
364+
setSubmissionsTotalPages(Math.ceil(pagination.total / 12));
363365
}
364366
} else {
365367
setSubmissions([]);
@@ -379,7 +381,7 @@ export default function JudgingPage() {
379381
}, [
380382
organizationId,
381383
hackathonId,
382-
currentPage,
384+
submissionsPage,
383385
submissionSearchTerm,
384386
fetchJudges,
385387
fetchResults,
@@ -449,8 +451,14 @@ export default function JudgingPage() {
449451
const filteredAndSortedSubmissions = submissions;
450452

451453
const handlePageChange = (newPage: number) => {
452-
if (newPage >= 1 && newPage <= totalPages) {
453-
setCurrentPage(newPage);
454+
if (activeTab === 'overview') {
455+
if (newPage >= 1 && newPage <= submissionsTotalPages) {
456+
setSubmissionsPage(newPage);
457+
}
458+
} else if (activeTab === 'results') {
459+
if (newPage >= 1 && newPage <= resultsTotalPages) {
460+
setResultsPage(newPage);
461+
}
454462
}
455463
};
456464

@@ -530,8 +538,8 @@ export default function JudgingPage() {
530538
/>
531539
<MetricsCard
532540
title='Graded / Shortlisted'
533-
value={`${gradedCount} / ${submissions.length}`}
534-
subtitle={`${submissions.length > 0 ? Math.round((gradedCount / submissions.length) * 100) : 0}% Completion`}
541+
value={`${gradedCount} / ${totalPossibleSubmissions}`}
542+
subtitle={`${totalPossibleSubmissions > 0 ? Math.round((gradedCount / totalPossibleSubmissions) * 100) : 0}% Completion`}
535543
// icon={<Star className='h-4 w-4 text-amber-400' />}
536544
className='min-w-[200px] border-gray-900 bg-white/5'
537545
/>
@@ -555,6 +563,7 @@ export default function JudgingPage() {
555563
onValueChange={value => {
556564
setActiveTab(value);
557565
if (value === 'results') {
566+
setSortBy('score'); // Show auto-rank by default
558567
fetchResults(false);
559568
fetchWinners(false);
560569
}
@@ -604,7 +613,8 @@ export default function JudgingPage() {
604613
value={searchQuery}
605614
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
606615
setSearchQuery(e.target.value);
607-
setCurrentPage(1);
616+
if (activeTab === 'overview') setSubmissionsPage(1);
617+
if (activeTab === 'results') setResultsPage(1);
608618
}}
609619
/>
610620
</div>
@@ -616,7 +626,8 @@ export default function JudgingPage() {
616626
value={sortBy}
617627
onValueChange={(value: any) => {
618628
setSortBy(value);
619-
setCurrentPage(1);
629+
if (activeTab === 'overview') setSubmissionsPage(1);
630+
if (activeTab === 'results') setResultsPage(1);
620631
}}
621632
>
622633
<SelectTrigger className='h-9 w-[130px] border-gray-900 bg-black text-xs'>
@@ -698,26 +709,28 @@ export default function JudgingPage() {
698709
</div>
699710

700711
{/* Pagination Controls */}
701-
{totalPages > 1 && (
712+
{submissionsTotalPages > 1 && (
702713
<div className='mt-8 flex items-center justify-center gap-4'>
703714
<Button
704715
variant='outline'
705716
size='sm'
706-
disabled={currentPage === 1 || isLoading}
707-
onClick={() => handlePageChange(currentPage - 1)}
717+
disabled={submissionsPage === 1 || isLoading}
718+
onClick={() => handlePageChange(submissionsPage - 1)}
708719
className='border-gray-900 bg-black hover:bg-white/5'
709720
>
710721
<ChevronLeft className='mr-1 h-4 w-4' />
711722
Previous
712723
</Button>
713724
<span className='text-sm text-gray-500'>
714-
Page {currentPage} of {totalPages}
725+
Page {submissionsPage} of {submissionsTotalPages}
715726
</span>
716727
<Button
717728
variant='outline'
718729
size='sm'
719-
disabled={currentPage === totalPages || isLoading}
720-
onClick={() => handlePageChange(currentPage + 1)}
730+
disabled={
731+
submissionsPage === submissionsTotalPages || isLoading
732+
}
733+
onClick={() => handlePageChange(submissionsPage + 1)}
721734
className='border-gray-900 bg-black hover:bg-white/5'
722735
>
723736
Next
@@ -991,28 +1004,29 @@ export default function JudgingPage() {
9911004
/>
9921005

9931006
{/* Pagination Controls for Results */}
994-
{totalPages > 1 && (
1007+
{resultsTotalPages > 1 && (
9951008
<div className='mt-8 flex items-center justify-center gap-4'>
9961009
<Button
9971010
variant='outline'
9981011
size='sm'
999-
disabled={currentPage === 1 || isFetchingResults}
1000-
onClick={() => handlePageChange(currentPage - 1)}
1012+
disabled={resultsPage === 1 || isFetchingResults}
1013+
onClick={() => handlePageChange(resultsPage - 1)}
10011014
className='border-gray-900 bg-black hover:bg-white/5'
10021015
>
10031016
<ChevronLeft className='mr-1 h-4 w-4' />
10041017
Previous
10051018
</Button>
10061019
<span className='text-sm text-gray-500'>
1007-
Page {currentPage} of {totalPages}
1020+
Page {resultsPage} of {resultsTotalPages}
10081021
</span>
10091022
<Button
10101023
variant='outline'
10111024
size='sm'
10121025
disabled={
1013-
currentPage === totalPages || isFetchingResults
1026+
resultsPage === resultsTotalPages ||
1027+
isFetchingResults
10141028
}
1015-
onClick={() => handlePageChange(currentPage + 1)}
1029+
onClick={() => handlePageChange(resultsPage + 1)}
10161030
className='border-gray-900 bg-black hover:bg-white/5'
10171031
>
10181032
Next

components/organization/cards/JudgingParticipant.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ const JudgingParticipant = ({
239239
<span className='h-1 w-1 rounded-full bg-gray-700' />
240240
<button
241241
onClick={() => setShowBreakdown(!showBreakdown)}
242-
className='hover:text-primary flex items-center gap-1 text-xs text-white transition-colors'
242+
className='hover:text-primary text-primary flex items-center gap-1 text-xs transition-colors'
243243
>
244244
{localAverageScore !== null ? (
245245
<>Score: {Number(localAverageScore).toFixed(1)}</>

components/organization/hackathons/judging/JudgingResultsTable.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,21 @@ const JudgingResultsTable = ({
169169
>
170170
<TableCell className='font-medium text-white'>
171171
<div className='flex items-center gap-2'>
172-
{getRankIcon(index)}
173-
<span>#{result.rank ?? index + 1}</span>
172+
{getRankIcon(result.rank ? result.rank - 1 : index)}
173+
<div className='flex flex-col'>
174+
{result.rank ? (
175+
<span className='text-[10px] tracking-wider text-amber-500/70 uppercase'>
176+
Final
177+
</span>
178+
) : (
179+
<span className='text-[10px] tracking-wider text-gray-500 uppercase'>
180+
Auto
181+
</span>
182+
)}
183+
<span className='text-sm font-bold'>
184+
#{result.rank ?? result.computedRank ?? index + 1}
185+
</span>
186+
</div>
174187
</div>
175188
</TableCell>
176189
<TableCell className='font-medium text-white'>

lib/api/hackathons/judging.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export interface JudgingResult {
7777
variance: number;
7878
}>;
7979
rank: number;
80+
computedRank?: number;
8081
isComplete: boolean;
8182
isPending: boolean;
8283
hasDisagreement: boolean;

0 commit comments

Comments
 (0)