@@ -27,7 +27,7 @@ import { InView } from "react-intersection-observer";
27
27
import useRepo , { Prob , repoQueryOptions , Sol } from "../hooks/useRepo" ;
28
28
import useSearch from "../hooks/useSearch" ;
29
29
30
- export default function ResultSection ( ) {
30
+ export default function SearchResultSection ( ) {
31
31
const { subtleBg } = useColor ( ) ;
32
32
33
33
return (
@@ -67,11 +67,11 @@ function TableHeader() {
67
67
}
68
68
69
69
function TableContent ( ) {
70
- const { repoQuery } = useRepo ( ) ;
70
+ const { probsQuery } = useRepo ( ) ;
71
71
const { result } = useSearch ( ) ;
72
72
const [ itemsInViewLength , setItemsInViewLength ] = useState ( 30 ) ;
73
73
74
- if ( repoQuery . isLoading ) {
74
+ if ( probsQuery . isLoading ) {
75
75
return (
76
76
< Flex
77
77
h = "200px"
@@ -87,19 +87,26 @@ function TableContent() {
87
87
</ Flex >
88
88
) ;
89
89
}
90
- if ( repoQuery . isError ) return null ;
90
+ if ( probsQuery . isError ) return null ;
91
91
92
92
if ( result . keyword !== "" && result . probs . length === 0 ) {
93
93
return (
94
- < Center h = "60px" px = "20px" >
94
+ < Center h = "60px" px = "20px" pb = "20px" >
95
95
< Text > 일치하는 문제가 없어요</ Text >
96
96
</ Center >
97
97
) ;
98
98
}
99
99
100
- const items = (
101
- result . keyword === "" ? repoQuery . data . probs : result . probs
102
- ) . slice ( ) ;
100
+ if ( result . selectedLangs ?. length === 0 ) {
101
+ return (
102
+ < Center h = "60px" px = "20px" pb = "20px" >
103
+ < Text > 언어를 선택해주세요</ Text >
104
+ </ Center >
105
+ ) ;
106
+ }
107
+ const items = ( result . keyword === "" ? probsQuery . data : result . probs )
108
+ . slice ( )
109
+ . sort ( ( a , b ) => b . solvedCount - a . solvedCount ) ;
103
110
104
111
return (
105
112
< >
@@ -130,8 +137,12 @@ function TableContent() {
130
137
}
131
138
132
139
function TableRow ( { probData : { title, id } } : { probData : Prob } ) {
133
- const { repoQuery } = useRepo ( ) ;
134
- const solutions = repoQuery . data ?. sols . filter ( s => s . probId === id ) ;
140
+ const { solsQuery } = useRepo ( ) ;
141
+ const { result } = useSearch ( ) ;
142
+ const solutions = solsQuery . data ?. filter (
143
+ s => s . probId === id && result . selectedLangs ?. includes ( s . lang )
144
+ ) ;
145
+
135
146
const { getCountColor } = useColor ( ) ;
136
147
137
148
return (
@@ -167,24 +178,32 @@ function TableRow({ probData: { title, id } }: { probData: Prob }) {
167
178
) ;
168
179
}
169
180
170
- function Solutions ( { solData : { author, code } } : { solData : Sol } ) {
181
+ function Solutions ( { solData : { author, code, lang } } : { solData : Sol } ) {
171
182
const toast = useToast ( ) ;
172
-
183
+ const { getLangColor } = useColor ( ) ;
173
184
return (
174
185
< Flex direction = "column" gap = "20px" >
175
- < Link href = { `https://github.com/${ author } ` } target = "_blank" >
176
- < Button
177
- h = "64px"
178
- w = "full"
179
- textAlign = "left"
180
- justifyContent = "left"
181
- gap = "20px"
182
- variant = "ghost"
183
- >
184
- < Avatar src = { `https://github.com/${ author } .png` } />
185
- < Text fontWeight = "bold" > { author } </ Text >
<
72A8
td data-grid-cell-id="diff-59205f50442f9c2173f953cde81a3d8eb5494b7c806a869e107dde6dd40d35f5-186-185-0" data-selected="false" role="gridcell" style="background-color:var(--diffBlob-deletionNum-bgColor, var(--diffBlob-deletion-bgColor-num));text-align:center" tabindex="-1" valign="top" class="focusable-grid-cell diff-line-number position-relative left-side">186
- </ Button >
187
- </ Link >
186
+ < Flex align = "center" justify = "space-between" >
187
+ < Link href = { `https://github.com/${ author } ` } target = "_blank" >
188
+ < Button
189
+ h = "64px"
190
+ w = "full"
191
+ textAlign = "left"
192
+ justifyContent = "left"
193
+ gap = "20px"
194
+ variant = "ghost"
195
+ >
196
+ < Avatar src = { `https://github.com/${ author } .png` } />
197
+ < Text fontWeight = "bold" > { author } </ Text >
198
+ </ Button >
199
+ </ Link >
200
+ < Center bg = { getLangColor ( lang ) } px = "12px" h = "30px" rounded = "4px" >
201
+ < Text fontWeight = "extrabold" color = "black" >
202
+ { lang }
203
+ </ Text >
204
+ </ Center >
205
+ </ Flex >
206
+
188
207
< Box as = "pre" w = "full" overflow = "hidden" pos = "relative" >
189
208
< IconButton
190
209
icon = { < Icon as = { FontAwesomeIcon } icon = { faCopy } /> }
@@ -221,7 +240,8 @@ function Solutions({ solData: { author, code } }: { solData: Sol }) {
221
240
222
241
export async function getServerSideProps ( ) {
223
242
const queryClient = new QueryClient ( ) ;
224
- await queryClient . prefetchQuery ( repoQueryOptions . all ) ;
243
+ await queryClient . prefetchQuery ( repoQueryOptions . probs ) ;
244
+ await queryClient . prefetchQuery ( repoQueryOptions . sols ) ;
225
245
226
246
const props : CustomAppProps [ "pageProps" ] = {
227
247
dehydratedState : dehydrate ( queryClient )
0 commit comments