1
1
"use client" ;
2
2
import Header from "@/components/Header/header" ;
3
- import { Col , Layout , message , PaginationProps , Row , Table } from "antd" ;
3
+ import { Col , Layout , message , PaginationProps , Row , Spin , Table } from "antd" ;
4
4
import { Content } from "antd/es/layout/layout" ;
5
5
import { CodeOutlined , HistoryOutlined } from "@ant-design/icons" ;
6
6
import "./styles.scss" ;
@@ -65,6 +65,7 @@ export default function QuestionPage() {
65
65
useState < History [ ] > ( ) ;
66
66
const [ submission , setSubmission ] = useState < Submission > ( ) ;
67
67
const [ isHistoryLoading , setIsHistoryLoading ] = useState < boolean > ( true ) ;
68
+ const [ isSubmissionLoading , setIsSubmissionLoading ] = useState < boolean > ( true ) ;
68
69
const [ currentSubmissionId , setCurrentSubmissionId ] = useState <
69
70
string | undefined
70
71
> ( historyDocRefId == "" ? undefined : historyDocRefId ) ;
@@ -156,24 +157,28 @@ export default function QuestionPage() {
156
157
parent : editorRef . current || undefined ,
157
158
} ) ;
158
159
159
- GetHistory ( currentSubmissionId ) . then ( ( data : any ) => {
160
- const submittedAt = new Date ( data . createdAt ) ;
161
- setSubmission ( {
162
- submittedAt : submittedAt . toLocaleString ( "en-US" ) ,
163
- language : data . language ,
164
- matchedUser :
165
- username == data . matchedUser ? data . user : data . matchedUser ,
166
- otherUser : data . user ,
167
- historyDocRefId : data . historyDocRefId ,
168
- code : data . code ,
169
- } ) ;
160
+ setIsSubmissionLoading ( true ) ;
161
+ GetHistory ( currentSubmissionId )
162
+ . then ( ( data : any ) => {
163
+ const submittedAt = new Date ( data . createdAt ) ;
164
+ setSubmission ( {
165
+ submittedAt : submittedAt . toLocaleString ( "en-US" ) ,
166
+ language : data . language ,
167
+ matchedUser :
168
+ username == data . matchedUser ? data . user : data . matchedUser ,
169
+ otherUser : data . user ,
170
+ historyDocRefId : data . historyDocRefId ,
171
+ code : data . code ,
172
+ } ) ;
173
+ setIsSubmissionLoading ( false ) ;
170
174
171
- view . dispatch (
172
- state . update ( {
173
- changes : { from : 0 , to : state . doc . length , insert : data . code } ,
174
- } )
175
- ) ;
176
- } ) ;
175
+ view . dispatch (
176
+ state . update ( {
177
+ changes : { from : 0 , to : state . doc . length , insert : data . code } ,
178
+ } )
179
+ ) ;
180
+ } )
181
+ . finally ( ( ) => { } ) ;
177
182
178
183
return ( ) => {
179
184
// Cleanup on component unmount
@@ -258,7 +263,25 @@ export default function QuestionPage() {
258
263
{ currentSubmissionId && (
259
264
< Row className = "code-row" >
260
265
< div className = "code-container" >
261
- < >
266
+ { isSubmissionLoading && (
267
+ < div
268
+ style = { {
269
+ display : "flex" ,
270
+ justifyContent : "center" ,
271
+ alignItems : "center" ,
272
+ height : "100%" ,
273
+ } }
274
+ >
275
+ < Spin />
276
+ </ div >
277
+ ) }
278
+ < div
279
+ style = { {
280
+ visibility : `${
281
+ isSubmissionLoading ? "hidden" : "visible"
282
+ } `,
283
+ } }
284
+ >
262
285
< div className = "code-top-container" >
263
286
< div className = "code-title" >
264
287
< CodeOutlined className = "title-icons" />
@@ -271,23 +294,34 @@ export default function QuestionPage() {
271
294
style = { {
272
295
margin : "10px" ,
273
296
display : "flex" ,
297
+ justifyContent : "space-between" ,
274
298
flexDirection : "row" ,
275
299
} }
276
300
>
277
301
< div className = "submission-header-detail" >
278
- Submitted at: { submission ?. submittedAt || "-" }
302
+ < div style = { { fontWeight : "bold" } } >
303
+ Submitted at:
304
+ </ div >
305
+ < div > { submission ?. submittedAt || "-" } </ div >
279
306
</ div >
280
307
< div className = "submission-header-detail" >
281
- Language: { submission ?. language || "-" }
308
+ < div style = { { fontWeight : "bold" } } >
309
+ Language:
310
+ </ div >
311
+ < div > { submission ?. language || "-" } </ div >
282
312
</ div >
283
313
< div className = "submission-header-detail" >
284
- Matched with:{ " " }
285
- { submission ?. matchedUser
286
- ? // Check to ensure that matched user is correct, otherwise swap with otherUser
287
- username == submission . matchedUser
288
- ? submission . otherUser
289
- : submission . matchedUser
290
- : "-" }
314
+ < div style = { { fontWeight : "bold" } } >
315
+ Matched with:
316
+ </ div >
317
+ < div >
318
+ { submission ?. matchedUser
319
+ ? // Check to ensure that matched user is correct, otherwise swap with otherUser
320
+ username == submission . matchedUser
321
+ ? submission . otherUser
322
+ : submission . matchedUser
323
+ : "-" }
324
+ </ div >
291
325
</ div >
292
326
</ div >
293
327
@@ -307,7 +341,7 @@ export default function QuestionPage() {
307
341
} }
308
342
> </ div >
309
343
</ div >
310
- </ >
344
+ </ div >
311
345
</ div >
312
346
</ Row >
313
347
) }
0 commit comments