@@ -40,7 +40,7 @@ interface CollaborationProps {}
40
40
41
41
export default function CollaborationPage ( props : CollaborationProps ) {
42
42
const router = useRouter ( ) ;
43
- // const providerRef = useRef<WebrtcProvider | null>(null);
43
+ const providerRef = useRef < WebrtcProvider | null > ( null ) ;
44
44
45
45
const editorRef = useRef < CollaborativeEditorHandle > ( null ) ;
46
46
@@ -54,7 +54,9 @@ export default function CollaborationPage(props: CollaborationProps) {
54
54
const [ questionTitle , setQuestionTitle ] = useState < string | undefined > (
55
55
undefined
56
56
) ;
57
- const [ questionDocRefId , setQuestionDocRefId ] = useState < string | undefined > ( undefined ) ;
57
+ const [ questionDocRefId , setQuestionDocRefId ] = useState < string | undefined > (
58
+ undefined
59
+ ) ;
58
60
const [ complexity , setComplexity ] = useState < string | undefined > ( undefined ) ;
59
61
const [ categories , setCategories ] = useState < string [ ] > ( [ ] ) ; // Store the selected filter categories
60
62
const [ description , setDescription ] = useState < string | undefined > ( undefined ) ;
@@ -71,7 +73,9 @@ export default function CollaborationPage(props: CollaborationProps) {
71
73
return storedTime ? parseInt ( storedTime ) : 0 ;
72
74
} ) ; // State for count-up timer (TODO: currently using localstorage to store time, change to db stored time in the future)
73
75
const stopwatchRef = useRef < NodeJS . Timeout | null > ( null ) ;
74
- const [ matchedTopics , setMatchedTopics ] = useState < string [ ] | undefined > ( undefined ) ;
76
+ const [ matchedTopics , setMatchedTopics ] = useState < string [ ] | undefined > (
77
+ undefined
78
+ ) ;
75
79
76
80
// Chat states
77
81
const [ messageToSend , setMessageToSend ] = useState < string | undefined > (
@@ -142,31 +146,34 @@ export default function CollaborationPage(props: CollaborationProps) {
142
146
throw new Error ( "Provider not initialized" ) ;
143
147
}
144
148
providerRef . current . awareness . setLocalStateField ( "codeSavedStatus" , true ) ;
145
- }
149
+ } ;
146
150
147
151
const handleSubmitCode = async ( ) => {
148
152
if ( ! collaborationId ) {
149
153
throw new Error ( "Collaboration ID not found" ) ;
150
154
}
151
- const data = await CreateOrUpdateHistory ( {
152
- title : questionTitle ?? "" ,
153
- code : code ,
154
- language : selectedLanguage ,
155
- user : currentUser ?? "" ,
156
- matchedUser : matchedUser ?? "" ,
157
- matchId : collaborationId ?? "" ,
158
- matchedTopics : matchedTopics ?? [ ] ,
159
- questionDocRefId : questionDocRefId ?? "" ,
160
- questionDifficulty : complexity ?? "" ,
161
- questionTopics : categories ,
162
- } , collaborationId ) ;
155
+ const data = await CreateOrUpdateHistory (
156
+ {
157
+ title : questionTitle ?? "" ,
158
+ code : code ,
159
+ language : selectedLanguage ,
160
+ user : currentUser ?? "" ,
161
+ matchedUser : matchedUser ?? "" ,
162
+ matchId : collaborationId ?? "" ,
163
+ matchedTopics : matchedTopics ?? [ ] ,
164
+ questionDocRefId : questionDocRefId ?? "" ,
165
+ questionDifficulty : complexity ?? "" ,
166
+ questionTopics : categories ,
167
+ } ,
168
+ collaborationId
169
+ ) ;
163
170
successMessage ( "Code saved successfully!" ) ;
164
171
sendCodeSavedStatusToMatchedUser ( ) ;
165
- }
172
+ } ;
166
173
167
174
const handleCodeChange = ( code : string ) => {
168
175
setCode ( code ) ;
169
- }
176
+ } ;
170
177
171
178
// Fetch the question on initialisation
172
179
useEffect ( ( ) => {
@@ -175,11 +182,13 @@ export default function CollaborationPage(props: CollaborationProps) {
175
182
}
176
183
177
184
// Retrieve details from localstorage
178
- const questionDocRefId : string = localStorage . getItem ( "questionDocRefId" ) ?? "" ;
185
+ const questionDocRefId : string =
186
+ localStorage . getItem ( "questionDocRefId" ) ?? "" ;
179
187
const collabId : string = localStorage . getItem ( "collabId" ) ?? "" ;
180
188
const matchedUser : string = localStorage . getItem ( "matchedUser" ) ?? "" ;
181
189
const currentUser : string = localStorage . getItem ( "user" ) ?? "" ;
182
- const matchedTopics : string [ ] = localStorage . getItem ( "matchedTopics" ) ?. split ( "," ) ?? [ ] ;
190
+ const matchedTopics : string [ ] =
191
+ localStorage . getItem ( "matchedTopics" ) ?. split ( "," ) ?? [ ] ;
183
192
184
193
// Set states from localstorage
185
194
setCollaborationId ( collabId ) ;
@@ -377,10 +386,10 @@ export default function CollaborationPage(props: CollaborationProps) {
377
386
Code
378
387
</ div >
379
388
{ /* TODO: Link to execution service for code submission */ }
380
- < Button
381
- icon = { < SendOutlined /> }
382
- iconPosition = "end"
383
- onClick = { ( ) => handleSubmitCode ( ) }
389
+ < Button
390
+ icon = { < SendOutlined /> }
391
+ iconPosition = "end"
392
+ onClick = { ( ) => handleSubmitCode ( ) }
384
393
>
385
394
Submit
386
395
</ Button >
0 commit comments