1
1
'use client' ;
2
2
3
- import { type ComponentType } from 'react' ;
4
3
import { useEffect } from 'react' ;
5
4
6
- import { type LucideProps , MoreHorizontal } from 'lucide-react' ;
5
+ import { MoreHorizontal } from 'lucide-react' ;
7
6
8
7
import { useShallowStore } from '~/store' ;
9
8
@@ -43,17 +42,6 @@ import { cn } from '~/lib/utils';
43
42
import { binaryFilters , inequalityFilters } from '~/settings/filter' ;
44
43
import { Checkbox } from '../ui/checkbox' ;
45
44
import { type SportType } from '~/server/db/schema' ;
46
- import { type CheckedState } from '@radix-ui/react-checkbox' ;
47
-
48
- type DropdownProps = {
49
- title : string ;
50
- values : Record < SportType , CheckedState > ;
51
- Icon : ComponentType < LucideProps > ;
52
- color : string ;
53
- onToggle : ( ) => void ;
54
- onChange : ( value : SportType ) => void ;
55
- active : boolean ;
56
- } ;
57
45
58
46
export function CategoryFilter ( ) {
59
47
const { sportType, sportGroup, setSportGroup, setSportType } =
@@ -69,6 +57,19 @@ export function CategoryFilter() {
69
57
) ;
70
58
71
59
useEffect ( ( ) => {
60
+ const doSingleClickThing = ( ) => {
61
+ if ( key ) setSportGroup ( ( group ) => ( { ...group , [ key ] : ! group [ key ] } ) ) ;
62
+ } ;
63
+
64
+ const doDoubleClickThing = ( ) => {
65
+ if ( key )
66
+ setSportGroup (
67
+ ( group ) =>
68
+ Object . fromEntries (
69
+ Object . keys ( group ) . map ( ( k ) => [ k , k === key ] ) ,
70
+ ) as Record < keyof typeof categorySettings , boolean > ,
71
+ ) ;
72
+ } ;
72
73
let singleClickTimer : NodeJS . Timeout ;
73
74
if ( clicks === 1 ) {
74
75
singleClickTimer = setTimeout ( function ( ) {
@@ -80,21 +81,7 @@ export function CategoryFilter() {
80
81
setClicks ( 0 ) ;
81
82
}
82
83
return ( ) => clearTimeout ( singleClickTimer ) ;
83
- } , [ clicks ] ) ;
84
-
85
- const doSingleClickThing = ( ) => {
86
- if ( key ) setSportGroup ( ( group ) => ( { ...group , [ key ] : ! group [ key ] } ) ) ;
87
- } ;
88
-
89
- const doDoubleClickThing = ( ) => {
90
- if ( key )
91
- setSportGroup (
92
- ( group ) =>
93
- Object . fromEntries (
94
- Object . keys ( group ) . map ( ( k ) => [ k , k === key ] ) ,
95
- ) as Record < keyof typeof categorySettings , boolean > ,
96
- ) ;
97
- } ;
84
+ } , [ clicks , key , setSportGroup ] ) ;
98
85
99
86
return (
100
87
< SidebarMenu >
@@ -184,7 +171,7 @@ export function InequalityFilter({
184
171
...prev ,
185
172
[ name ] : input === '' ? undefined : { value : transformed , operator } ,
186
173
} ) ) ;
187
- } , [ operator , value , input , name ] ) ;
174
+ } , [ operator , value , input , name , setValues ] ) ;
188
175
189
176
return (
190
177
< SidebarMenuItem >
@@ -279,7 +266,7 @@ export function BinaryFilter({ name }: { name: keyof typeof binaryFilters }) {
279
266
{ binaryFilters [ name ] . label }
280
267
</ label >
281
268
< Checkbox
282
- checked = { binary === undefined ? 'indeterminate' : binary }
269
+ checked = { binary ?? 'indeterminate' }
283
270
onCheckedChange = { handleChange }
284
271
/>
285
272
</ SidebarMenuItem >
0 commit comments