1- import { FC , useState } from "react"
1+ import { useState } from "react" ;
22import { getMessage } from "../../utils" ;
3- import { COMMENT_STATUS } from '../../utils/constants' ;
4- import { SingleSelect , SingleSelectOption } from '@strapi/design-system' ;
3+ import { COMMENT_STATUS } from "../../utils/constants" ;
4+ import { SingleSelect , SingleSelectOption } from "@strapi/design-system" ;
5+ import { useQueryParams } from "@strapi/strapi/admin" ;
56
67const COMMENT_OPTIONS = [
78 COMMENT_STATUS . OPEN ,
@@ -10,61 +11,51 @@ const COMMENT_OPTIONS = [
1011 COMMENT_STATUS . APPROVED ,
1112 COMMENT_STATUS . REJECTED ,
1213 COMMENT_STATUS . PENDING ,
13- ]
14+ ] ;
1415
1516const getFilter = ( filterName : string | undefined ) => {
16- switch ( filterName ) {
17+ switch ( filterName ) {
1718 case COMMENT_STATUS . BLOCKED :
1819 return {
19- $or : [
20- { blocked : { $eq : true } } ,
21- { blockedThread : { $eq : true } } ,
22- ] ,
23- }
20+ $or : [ { blocked : { $eq : true } } , { blockedThread : { $eq : true } } ] ,
21+ } ;
2422 case COMMENT_STATUS . REMOVED :
2523 return {
26- $or : [
27- { blocked : { $eq : true } } ,
28- { blockedThread : { $eq : true } } ,
29- ] ,
30- }
24+ $or : [ { blocked : { $eq : true } } , { blockedThread : { $eq : true } } ] ,
25+ } ;
3126 case COMMENT_STATUS . OPEN :
3227 return {
3328 approvalStatus : { $null : true } ,
34- }
29+ } ;
3530 case undefined :
36- return { }
31+ return { } ;
3732 default :
3833 return {
3934 approvalStatus : { $eq : filterName } ,
40- }
35+ } ;
4136 }
42- }
43-
44- type CommentStatusFiltersProps = {
45- setQueryParams : ( nextParams : object , method ?: "push" | "remove" , replace ?: boolean ) => void ;
4637} ;
4738
48- export const CommentsStatusFilters : FC < CommentStatusFiltersProps > = ( { setQueryParams } ) => {
39+ export const CommentsStatusFilters = ( ) => {
40+ const [ _ , setQueryParams ] = useQueryParams ( ) ;
4941 const [ currentFilter , setCurrentFilter ] = useState < string > ( ) ;
5042
5143 const handleChange = ( filter : string | undefined ) => {
52- setCurrentFilter ( filter )
44+ setCurrentFilter ( filter ) ;
5345 setQueryParams ( {
5446 page : { } ,
55- pageSize : { } ,
56- filters : getFilter ( filter )
47+ filters : getFilter ( filter ) ,
5748 } ) ;
58- }
49+ } ;
5950
6051 return (
6152 < SingleSelect
62- placeholder = { getMessage ( ' page.common.item.status.setFilter' ) }
53+ placeholder = { getMessage ( " page.common.item.status.setFilter" ) }
6354 value = { currentFilter }
6455 onClear = { ( ) => handleChange ( undefined ) }
6556 onChange = { handleChange }
6657 >
67- { COMMENT_OPTIONS . map ( option => (
58+ { COMMENT_OPTIONS . map ( ( option ) => (
6859 < SingleSelectOption value = { option } >
6960 { getMessage ( `page.common.item.status.${ option } ` ) }
7061 </ SingleSelectOption >
0 commit comments