@@ -62,7 +62,7 @@ export const useUserCommentStore = defineComponentStore(
62
62
headerSrOnly : false ,
63
63
} ,
64
64
{
65
- header : t ( 'manager.userComment.reason' ) ,
65
+ header : t ( 'manager.userComment.report. reason' ) ,
66
66
headerSrOnly : false ,
67
67
} ,
68
68
{
@@ -150,12 +150,12 @@ export const useUserCommentStore = defineComponentStore(
150
150
label : t ( 'common.delete' ) ,
151
151
isWarnable : true ,
152
152
callback : async ( close ) => {
153
- const { apiUrl} = useUrl (
154
- `comments/${ report . userCommentId } /reports/${ report . id } ` ,
153
+ const { isSuccess, fetch : deleteReport } = useFetch (
154
+ `${ apiUrl . value } /${ report . userCommentId } /reports/${ report . id } ` ,
155
+ {
156
+ method : 'DELETE' ,
157
+ } ,
155
158
) ;
156
- const { isSuccess, fetch : deleteReport } = useFetch ( apiUrl , {
157
- method : 'DELETE' ,
158
- } ) ;
159
159
160
160
await deleteReport ( ) ;
161
161
@@ -322,9 +322,12 @@ export const useUserCommentStore = defineComponentStore(
322
322
label : t ( 'common.delete' ) ,
323
323
isWarnable : true ,
324
324
callback : async ( close ) => {
325
- const { isSuccess, fetch} = useFetch ( apiUrl , {
326
- method : 'DELETE' ,
327
- } ) ;
325
+ const { isSuccess, fetch} = useFetch (
326
+ `${ apiUrl . value } /${ comment . id } ` ,
327
+ {
328
+ method : 'DELETE' ,
329
+ } ,
330
+ ) ;
328
331
await fetch ( ) ;
329
332
if ( isSuccess . value ) {
330
333
pkp . eventBus . $emit (
@@ -348,6 +351,26 @@ export const useUserCommentStore = defineComponentStore(
348
351
} ) ;
349
352
}
350
353
354
+ /**
355
+ * Get the options for comment types(approved, needs approval, reported), to select from to view comments
356
+ */
357
+ const commentTypeOptions = computed ( ( ) => {
358
+ return [
359
+ {
360
+ label : t ( 'manager.userComment.approved' ) ,
361
+ value : 'approved' ,
362
+ } ,
363
+ {
364
+ label : t ( 'manager.userComment.needsApproval' ) ,
365
+ value : 'needsApproval' ,
366
+ } ,
367
+ {
368
+ label : t ( 'manager.userComment.reported' ) ,
369
+ value : 'reported' ,
370
+ } ,
371
+ ] ;
372
+ } ) ;
373
+
351
374
/**
352
375
* Open the report detail modal for a specific report.
353
376
* @param {object } report - The report to open in detail view.
@@ -359,6 +382,25 @@ export const useUserCommentStore = defineComponentStore(
359
382
comment : comments . value . find ( ( c ) => c . id === report . userCommentId ) ,
360
383
} ) ;
361
384
}
385
+
386
+ /**
387
+ * Get the status text for a comment.
388
+ * @param comment
389
+ * @returns {string }
390
+ */
391
+ function getCommentStatusText ( comment ) {
392
+ const status = [ ] ;
393
+ if ( comment . isApproved ) {
394
+ status . push ( 'Approved' ) ;
395
+ } else {
396
+ status . push ( 'Hidden/Needs Approval' ) ;
397
+ }
398
+ if ( comment . isReported ) {
399
+ status . push ( 'Reported' ) ;
400
+ }
401
+ return status . join ( ', ' ) ;
402
+ }
403
+
362
404
return {
363
405
reportDelete,
364
406
toggleCommentApproval,
@@ -371,6 +413,7 @@ export const useUserCommentStore = defineComponentStore(
371
413
setCurrentReportsPage,
372
414
fetchReportsPaginated : fetchCommentReports ,
373
415
openReport,
416
+ getCommentStatusText,
374
417
commentApprovalOptions,
375
418
selectedCommentStatus,
376
419
itemsPerPage,
@@ -380,6 +423,7 @@ export const useUserCommentStore = defineComponentStore(
380
423
currentCommentReports,
381
424
currentCommentReportsPagination,
382
425
reportsTableColumns,
426
+ commentTypeOptions,
383
427
} ;
384
428
} ,
385
429
) ;
0 commit comments