11import { Center , Flex , Text } from '@devup-ui/react'
22import { ComponentProps } from 'react'
33
4+ interface CompetitorStatProps {
5+ label : string
6+ total : number
7+ fail : number
8+ braillifyPercent : number
9+ showTotal : boolean
10+ }
11+
12+ function CompetitorStat ( {
13+ label,
14+ total,
15+ fail,
16+ braillifyPercent,
17+ showTotal,
18+ } : CompetitorStatProps ) {
19+ const success = total - fail
20+ const percent = Math . round ( ( success / total ) * 100 )
21+
22+ return (
23+ < Center bg = "#2B2B2B" borderRadius = "10px" gap = "10px" px = "16px" py = "10px" >
24+ < Text color = "#888" typography = "progress" >
25+ { label }
26+ </ Text >
27+ { showTotal && (
28+ < Text color = "#888" typography = "progress" >
29+ 전체 { total . toLocaleString ( ) }
30+ </ Text >
31+ ) }
32+ < Text color = "#888" typography = "progress" >
33+ 성공 { success . toLocaleString ( ) }
34+ </ Text >
35+ < Text color = "$error" typography = "progress" >
36+ 실패 { fail . toLocaleString ( ) }
37+ </ Text >
38+ < Text
39+ color = { percent < braillifyPercent ? '$error' : '$text' }
40+ typography = "progress"
41+ >
42+ ({ percent } %)
43+ </ Text >
44+ </ Center >
45+ )
46+ }
47+
448interface TestCaseStatProps extends ComponentProps < typeof Center < 'div' > > {
549 showTotal ?: boolean
650 total : number
751 success : number
852 fail : number
953 worldTotal ?: number
1054 worldFail ?: number
55+ jeomsarangTotal ?: number
56+ jeomsarangFail ?: number
1157}
1258
1359export function TestCaseStat ( {
@@ -17,19 +63,23 @@ export function TestCaseStat({
1763 fail,
1864 worldTotal,
1965 worldFail,
66+ jeomsarangTotal,
67+ jeomsarangFail,
2068 ...props
2169} : TestCaseStatProps ) {
2270 const hasFail = fail > 0
2371 const braillifyPercent = Math . round ( ( success / total ) * 100 )
2472
2573 const hasWorld = worldTotal != null && worldTotal > 0
26- const worldSuccess = hasWorld ? worldTotal - worldFail ! : 0
27- const worldPercent = hasWorld
28- ? Math . round ( ( worldSuccess / worldTotal ) * 100 )
29- : 0
74+ const hasJeomsarang = jeomsarangTotal != null && jeomsarangTotal > 0
3075
3176 return (
32- < Flex alignItems = "center" gap = "8px" styleOrder = { 1 } >
77+ < Flex
78+ alignItems = "center"
79+ flexWrap = "wrap"
80+ gap = "8px"
81+ styleOrder = { 1 }
82+ >
3383 < Center
3484 bg = "$menuHover"
3585 borderRadius = "10px"
@@ -57,34 +107,22 @@ export function TestCaseStat({
57107 </ Text >
58108 </ Center >
59109 { hasWorld && (
60- < Center
61- bg = "#2B2B2B"
62- borderRadius = "10px"
63- gap = "10px"
64- px = "16px"
65- py = "10px"
66- >
67- < Text color = "#888" typography = "progress" >
68- 점자세상
69- </ Text >
70- { showTotal && (
71- < Text color = "#888" typography = "progress" >
72- 전체 { worldTotal . toLocaleString ( ) }
73- </ Text >
74- ) }
75- < Text color = "#888" typography = "progress" >
76- 성공 { worldSuccess . toLocaleString ( ) }
77- </ Text >
78- < Text color = "$error" typography = "progress" >
79- 실패 { worldFail ! . toLocaleString ( ) }
80- </ Text >
81- < Text
82- color = { worldPercent < braillifyPercent ? '$error' : '$text' }
83- typography = "progress"
84- >
85- ({ worldPercent } %)
86- </ Text >
87- </ Center >
110+ < CompetitorStat
111+ braillifyPercent = { braillifyPercent }
112+ fail = { worldFail ! }
113+ label = "점자세상"
114+ showTotal = { showTotal }
115+ total = { worldTotal }
116+ />
117+ ) }
118+ { hasJeomsarang && (
119+ < CompetitorStat
120+ braillifyPercent = { braillifyPercent }
121+ fail = { jeomsarangFail ! }
122+ label = "점사랑"
123+ showTotal = { showTotal }
124+ total = { jeomsarangTotal }
125+ />
88126 ) }
89127 </ Flex >
90128 )
0 commit comments