1
1
import { useMemo } from "react" ;
2
2
3
3
import { useLocale } from "@calcom/lib/hooks/useLocale" ;
4
- import { trpc } from "@calcom/trpc" ;
5
4
import type { IconName } from "@calcom/ui" ;
6
5
import {
7
6
Dropdown ,
@@ -23,31 +22,10 @@ type Option = {
23
22
StartIcon : IconName ;
24
23
} ;
25
24
26
- export const FilterType = ( { showRoutingFilters = false } : { showRoutingFilters ?: boolean } ) => {
25
+ export const FilterType = ( ) => {
27
26
const { t } = useLocale ( ) ;
28
27
const { filter, setConfigFilters } = useFilterContext ( ) ;
29
- const { selectedFilter, selectedUserId, selectedTeamId, selectedRoutingFormId, isAll, initialConfig } =
30
- filter ;
31
- const initialConfigIsReady = ! ! ( initialConfig ?. teamId || initialConfig ?. userId || initialConfig ?. isAll ) ;
32
-
33
- // Dynamically load filters if showRoutingFilters is set to true
34
- // Query routing form field options when showRoutingFilters is true
35
- const { data : routingFormFieldOptions } = trpc . viewer . insights . getRoutingFormFieldOptions . useQuery (
36
- {
37
- userId : selectedUserId ?? - 1 ,
38
- teamId : selectedTeamId ?? - 1 ,
39
- isAll : ! ! isAll ,
40
- routingFormId : selectedRoutingFormId ?? undefined ,
41
- } ,
42
- {
43
- enabled : showRoutingFilters && initialConfigIsReady ,
44
- trpc : {
45
- context : {
46
- skipBatch : true ,
47
- } ,
48
- } ,
49
- }
50
- ) ;
28
+ const { selectedFilter, selectedUserId } = filter ;
51
29
52
30
const filterOptions = useMemo ( ( ) => {
53
31
let options : Option [ ] = [
@@ -58,46 +36,19 @@ export const FilterType = ({ showRoutingFilters = false }: { showRoutingFilters?
58
36
} ,
59
37
] ;
60
38
61
- // Add routing forms filter options
62
- if ( showRoutingFilters ) {
63
- options . push ( {
64
- label : t ( "routing_forms" ) ,
65
- value : "routing_forms" as FilterType ,
66
- StartIcon : "calendar-check-2" as IconName ,
67
- } ) ;
68
-
69
- options . push ( {
70
- label : t ( "booking_status" ) ,
71
- value : "booking_status" as FilterType ,
72
- StartIcon : "circle" as IconName ,
73
- } ) ;
74
-
75
- // Add dynamic routing form field options
76
- if ( routingFormFieldOptions ?. length ) {
77
- options = [
78
- ...options ,
79
- ...routingFormFieldOptions . map ( ( option ) => ( {
80
- label : option . label ,
81
- value : `rf_${ option . id } ` as FilterType ,
82
- StartIcon : "layers" as IconName ,
83
- } ) ) ,
84
- ] ;
85
- }
86
- } else {
87
- options . push ( {
88
- label : t ( "event_type" ) ,
89
- value : "event-type" ,
90
- StartIcon : "link" ,
91
- } ) ;
92
- }
39
+ options . push ( {
40
+ label : t ( "event_type" ) ,
41
+ value : "event-type" ,
42
+ StartIcon : "link" ,
43
+ } ) ;
93
44
94
45
if ( selectedUserId ) {
95
46
// remove user option from filterOptions
96
47
options = options . filter ( ( option ) => option . value !== "user" ) ;
97
48
}
98
49
99
50
return options ;
100
- } , [ t , showRoutingFilters , routingFormFieldOptions , selectedUserId ] ) ;
51
+ } , [ t , selectedUserId ] ) ;
101
52
102
53
return (
103
54
< Dropdown >
0 commit comments