@@ -18,7 +18,11 @@ import {
18
18
AssignmentWish ,
19
19
CodeComment ,
20
20
AssignmentWishesResponse ,
21
- Notification , GroupJoinRequestPolicy , TaskyUser , GroupMembersResponse , AssignmentCompletionsResponse ,
21
+ Notification ,
22
+ GroupJoinRequestPolicy ,
23
+ TaskyUser ,
24
+ GroupMembersResponse ,
25
+ AssignmentCompletionsResponse ,
22
26
} from "@/service/types/tasky" ;
23
27
import { FileStructureTree } from "@/components/FileStructure" ;
24
28
import { Spotlight3Response } from "@/service/types/spotlight" ;
@@ -61,16 +65,34 @@ class ApiService {
61
65
) ;
62
66
}
63
67
64
- public async createGroup ( title : string , join_policy : GroupJoinRequestPolicy ) : Promise < Group > {
65
- return await this . post < Group > ( `/tasky/create_group` , { title, join_policy } ) ;
68
+ public async createGroup (
69
+ title : string ,
70
+ join_policy : GroupJoinRequestPolicy ,
71
+ ) : Promise < Group > {
72
+ return await this . post < Group > ( `/tasky/create_group` , {
73
+ title,
74
+ join_policy,
75
+ } ) ;
66
76
}
67
77
68
- public async updateGroup ( groupId : number , title : string , join_policy : GroupJoinRequestPolicy ) : Promise < Group > {
69
- return await this . post < Group > ( `/tasky/groups/${ groupId } ` , { title, join_policy } ) ;
78
+ public async updateGroup (
79
+ groupId : number ,
80
+ title : string ,
81
+ join_policy : GroupJoinRequestPolicy ,
82
+ ) : Promise < Group > {
83
+ return await this . post < Group > ( `/tasky/groups/${ groupId } ` , {
84
+ title,
85
+ join_policy,
86
+ } ) ;
70
87
}
71
88
72
- public async getGroups ( page ?: number , search ?: string ) : Promise < GroupsResponse > {
73
- return await this . get < GroupsResponse > ( `/tasky/groups?page=${ page ?? 1 } &search=${ search ?? "" } ` ) ;
89
+ public async getGroups (
90
+ page ?: number ,
91
+ search ?: string ,
92
+ ) : Promise < GroupsResponse > {
93
+ return await this . get < GroupsResponse > (
94
+ `/tasky/groups?page=${ page ?? 1 } &search=${ search ?? "" } ` ,
95
+ ) ;
74
96
}
75
97
76
98
public async getMyGroups ( page ?: number ) : Promise < GroupsResponse > {
@@ -117,7 +139,10 @@ class ApiService {
117
139
) ;
118
140
}
119
141
120
- public async removeUserFromGroup ( groupId : number , memberId : number ) : Promise < void > {
142
+ public async removeUserFromGroup (
143
+ groupId : number ,
144
+ memberId : number ,
145
+ ) : Promise < void > {
121
146
await this . delete < any > ( `/tasky/groups/${ groupId } /members/${ memberId } ` ) ;
122
147
}
123
148
@@ -294,7 +319,11 @@ class ApiService {
294
319
}
295
320
296
321
public async getNotifications ( ) : Promise < Notification [ ] > {
297
- return await this . get < Notification [ ] > ( `/tasky/notifications` ) ;
322
+ try {
323
+ return await this . get < Notification [ ] > ( `/tasky/notifications` ) ;
324
+ } catch {
325
+ return [ ] ;
326
+ }
298
327
}
299
328
300
329
public async removeNotificationForUser ( id : number ) : Promise < void > {
@@ -305,8 +334,13 @@ class ApiService {
305
334
await this . delete < any > ( "/tasky/notifications" ) ;
306
335
}
307
336
308
- public async searchUsersToEnlist ( groupId : number , search : string ) : Promise < TaskyUser [ ] > {
309
- return await this . get < TaskyUser [ ] > ( `/tasky/groups/${ groupId } /enlistable?search=${ search } ` ) ;
337
+ public async searchUsersToEnlist (
338
+ groupId : number ,
339
+ search : string ,
340
+ ) : Promise < TaskyUser [ ] > {
341
+ return await this . get < TaskyUser [ ] > (
342
+ `/tasky/groups/${ groupId } /enlistable?search=${ search } ` ,
343
+ ) ;
310
344
}
311
345
312
346
public async enlistUser ( groupId : number , userId : number ) : Promise < void > {
@@ -325,20 +359,35 @@ class ApiService {
325
359
await this . delete < any > ( `/tasky/groups/${ groupId } ` ) ;
326
360
}
327
361
328
- public async getUserSolutions ( id : number , page : number ) : Promise < SolutionsResponse > {
329
- return await this . get < SolutionsResponse > ( `/tasky/user/${ id } /solutions?page=${ page } ` ) ;
362
+ public async getUserSolutions (
363
+ id : number ,
364
+ page : number ,
365
+ ) : Promise < SolutionsResponse > {
366
+ return await this . get < SolutionsResponse > (
367
+ `/tasky/user/${ id } /solutions?page=${ page } ` ,
368
+ ) ;
330
369
}
331
370
332
371
public async getPendingSolutions ( page : number ) : Promise < SolutionsResponse > {
333
- return await this . get < SolutionsResponse > ( `/tasky/tutor_solutions?page=${ page } ` ) ;
372
+ return await this . get < SolutionsResponse > (
373
+ `/tasky/tutor_solutions?page=${ page } ` ,
374
+ ) ;
334
375
}
335
376
336
- public async getPendingWishes ( page : number ) : Promise < AssignmentWishesResponse > {
337
- return await this . get < AssignmentWishesResponse > ( `/tasky/tutor_assignment_wishes?page=${ page } ` ) ;
377
+ public async getPendingWishes (
378
+ page : number ,
379
+ ) : Promise < AssignmentWishesResponse > {
380
+ return await this . get < AssignmentWishesResponse > (
381
+ `/tasky/tutor_assignment_wishes?page=${ page } ` ,
382
+ ) ;
338
383
}
339
384
340
- public async getPendingAssignments ( page : number ) : Promise < AssignmentsResponse > {
341
- return await this . get < AssignmentsResponse > ( `/tasky/student_pending_assignments?page=${ page } ` ) ;
385
+ public async getPendingAssignments (
386
+ page : number ,
387
+ ) : Promise < AssignmentsResponse > {
388
+ return await this . get < AssignmentsResponse > (
389
+ `/tasky/student_pending_assignments?page=${ page } ` ,
390
+ ) ;
342
391
}
343
392
344
393
public async verify ( groupId : number ) : Promise < void > {
@@ -349,28 +398,54 @@ class ApiService {
349
398
await this . post < any > ( `/tasky/groups/${ groupId } /unverify` , { } ) ;
350
399
}
351
400
352
- public async getGroupMembers ( groupId : number , page : number ) : Promise < GroupMembersResponse > {
353
- return await this . get < GroupMembersResponse > ( `/tasky/groups/${ groupId } /members?page=${ page } ` ) ;
401
+ public async getGroupMembers (
402
+ groupId : number ,
403
+ page : number ,
404
+ ) : Promise < GroupMembersResponse > {
405
+ return await this . get < GroupMembersResponse > (
406
+ `/tasky/groups/${ groupId } /members?page=${ page } ` ,
407
+ ) ;
354
408
}
355
409
356
- public async getAssignmentCompletions ( groupId : number , assignmentId : number , page : number ) : Promise < AssignmentCompletionsResponse > {
357
- return await this . get < AssignmentCompletionsResponse > ( `/tasky/groups/${ groupId } /assignments/${ assignmentId } /completions?page=${ page } ` ) ;
410
+ public async getAssignmentCompletions (
411
+ groupId : number ,
412
+ assignmentId : number ,
413
+ page : number ,
414
+ ) : Promise < AssignmentCompletionsResponse > {
415
+ return await this . get < AssignmentCompletionsResponse > (
416
+ `/tasky/groups/${ groupId } /assignments/${ assignmentId } /completions?page=${ page } ` ,
417
+ ) ;
358
418
}
359
419
360
- public async createGroupNotification ( groupId : number , title : string , content : string ) : Promise < void > {
361
- await this . post < any > ( `/tasky/groups/${ groupId } /notifications` , { title, content} )
420
+ public async createGroupNotification (
421
+ groupId : number ,
422
+ title : string ,
423
+ content : string ,
424
+ ) : Promise < void > {
425
+ await this . post < any > ( `/tasky/groups/${ groupId } /notifications` , {
426
+ title,
427
+ content,
428
+ } ) ;
362
429
}
363
430
364
431
public async getSystemWideNotification ( ) : Promise < Notification [ ] > {
365
- return await this . get < Notification [ ] > ( ' /tasky/system_wide_notifications' ) ;
432
+ return await this . get < Notification [ ] > ( " /tasky/system_wide_notifications" ) ;
366
433
}
367
434
368
- public async createSystemWideNotification ( title : string , content : string , show_until : Date ) : Promise < void > {
369
- await this . post < any > ( '/tasky/system_wide_notifications' , { title, content, show_until} ) ;
435
+ public async createSystemWideNotification (
436
+ title : string ,
437
+ content : string ,
438
+ show_until : Date ,
439
+ ) : Promise < void > {
440
+ await this . post < any > ( "/tasky/system_wide_notifications" , {
441
+ title,
442
+ content,
443
+ show_until,
444
+ } ) ;
370
445
}
371
446
372
447
public async deleteSystemWideNotifications ( id : number ) : Promise < void > {
373
- await this . delete < any > ( ' /tasky/system_wide_notifications/' + id , { } ) ;
448
+ await this . delete < any > ( " /tasky/system_wide_notifications/" + id , { } ) ;
374
449
}
375
450
376
451
public async createOrUpdateCodeTests (
0 commit comments