@@ -42,7 +42,6 @@ class SearchRefrech extends React.Component<SearchRefrechProps, SearchRefrechSta
42
42
fontSize : 'medium' ,
43
43
color : '#787878' ,
44
44
fontWeight : 600 ,
45
- marginRight : '10px' ,
46
45
} ;
47
46
48
47
const onBackClick = ( ) => {
@@ -51,6 +50,10 @@ class SearchRefrech extends React.Component<SearchRefrechProps, SearchRefrechSta
51
50
this . props . setIsSearching ( false ) ;
52
51
} ;
53
52
53
+ const onRefrechClick = ( ) => {
54
+ searchData ( ) ;
55
+ } ;
56
+
54
57
const onSearchClick = ( ) => {
55
58
this . setState ( { isSearching : true } ) ;
56
59
this . props . setIsSearching ( true ) ;
@@ -65,22 +68,26 @@ class SearchRefrech extends React.Component<SearchRefrechProps, SearchRefrechSta
65
68
}
66
69
} ;
67
70
68
- const onRefrechClick = ( ) => {
69
- if ( this . state . query ) {
70
- searchData ( this . state . query ) ;
71
+ const getEndPoint = ( params : string ) => {
72
+ let endPoint = '' ;
73
+ if ( this . props . searchType === 'lead' ) {
74
+ endPoint = api . Leads ;
75
+ } else if ( this . props . searchType === 'task' ) {
76
+ endPoint = api . Tasks ;
77
+ } else {
78
+ endPoint = api . Tickets ;
71
79
}
80
+ return endPoint + `/${ params } ` ;
72
81
} ;
73
82
74
- const searchData = async ( query : string ) => {
83
+ const searchData = async ( query ? : string ) => {
75
84
this . props . setIsLoading ( true ) ;
76
85
77
86
let endPoint = '' ;
78
- if ( this . props . searchType === 'lead' ) {
79
- endPoint = api . getLeads ;
80
- } else if ( this . props . searchType === 'task' ) {
81
- endPoint = api . getTasks ;
87
+ if ( query ) {
88
+ endPoint = getEndPoint ( 'search' ) ;
82
89
} else {
83
- endPoint = api . getTickets ;
90
+ endPoint = getEndPoint ( 'refresh' ) ;
84
91
}
85
92
86
93
try {
@@ -89,7 +96,7 @@ class SearchRefrech extends React.Component<SearchRefrechProps, SearchRefrechSta
89
96
api . baseURL + endPoint ,
90
97
ContentType . Json ,
91
98
this . context . getConnectionToken ( ) ,
92
- { query : query , partner_id : this . props . partner . id } ,
99
+ { query : query , partner : this . props . partner } ,
93
100
true ,
94
101
) ;
95
102
@@ -160,7 +167,7 @@ class SearchRefrech extends React.Component<SearchRefrechProps, SearchRefrechSta
160
167
}
161
168
162
169
let refrechButton = null ;
163
- if ( this . state . isSearching ) {
170
+ if ( ! this . state . isSearching ) {
164
171
refrechButton = (
165
172
< TooltipHost content = { _t ( 'Refresh search' ) } >
166
173
< div className = "odoo-muted-button" onClick = { onRefrechClick } style = { { border : 'none' } } >
@@ -174,8 +181,8 @@ class SearchRefrech extends React.Component<SearchRefrechProps, SearchRefrechSta
174
181
< div style = { broadCampStyle } >
175
182
{ backButton }
176
183
{ searchButton }
177
- { searchBar }
178
184
{ refrechButton }
185
+ { searchBar }
179
186
</ div >
180
187
) ;
181
188
}
0 commit comments