File tree Expand file tree Collapse file tree 3 files changed +6
-4
lines changed
Expand file tree Collapse file tree 3 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,8 @@ export default function Header() {
2424 const totalSolvedQuestions = data . me . submissionStatistics . solvedQuestions ;
2525 const totalAttemptedQuestions = data . me . submissionStatistics . attemptedQuestions ;
2626
27+ const completedPercentage = totalQuestions > 0 ? ( totalSolvedQuestions / totalQuestions ) * 100 : 0 ;
28+
2729 return (
2830 < header className = "flex items-center justify-between pb-6" >
2931 < div className = "space-y-1 tracking-wide" >
@@ -51,7 +53,7 @@ export default function Header() {
5153 variant = "primary"
5254 cols = { 10 }
5355 rows = { 4 }
54- progress = { ( totalSolvedQuestions / totalQuestions ) * 100 }
56+ progress = { completedPercentage }
5557 />
5658 </ div >
5759 </ header >
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ export default function CompletedQuestionsPercentage() {
2828
2929 const totalQuestions = data . me . submissionStatistics . totalQuestions ;
3030 const solvedQuestions = data . me . submissionStatistics . solvedQuestions ;
31- const completedPercentage = ( solvedQuestions / totalQuestions ) * 100 ;
31+ const completedPercentage = totalQuestions > 0 ? ( solvedQuestions / totalQuestions ) * 100 : 0 ;
3232
3333 return (
3434 < >
Original file line number Diff line number Diff line change @@ -20,12 +20,12 @@ export default function ResolvedQuestions() {
2020 const { data } = useSuspenseQuery ( RESOLVED_QUESTIONS ) ;
2121 const totalQuestions = data . me . submissionStatistics . totalQuestions ;
2222 const solvedQuestions = data . me . submissionStatistics . solvedQuestions ;
23- const resolvedQuestions = solvedQuestions / totalQuestions * 100 ;
23+ const resolvedQuestions = totalQuestions > 0 ? ( solvedQuestions / totalQuestions ) * 100 : 0 ;
2424
2525 return (
2626 < div className = "flex flex-col gap-1" >
2727 你攻克了 { resolvedQuestions . toFixed ( 0 ) } % 的題目!
28- < Progress className = "max-w-[50%]" value = { resolvedQuestions * 100 } />
28+ < Progress className = "max-w-[50%]" value = { resolvedQuestions } />
2929 </ div >
3030 ) ;
3131}
You can’t perform that action at this time.
0 commit comments