@@ -5,6 +5,7 @@ import PropTypes from "prop-types";
5
5
import { Accordion , Card } from "react-bootstrap" ;
6
6
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome" ;
7
7
import Swal from "sweetalert2" ;
8
+ import { setSearchTypeAction } from "store/actions/search" ;
8
9
9
10
const SearchLibrary = ( props ) => {
10
11
const {
@@ -44,6 +45,8 @@ const SearchLibrary = (props) => {
44
45
noWords,
45
46
setisLoader,
46
47
activeModel,
48
+ searchTypeNew,
49
+ setSearchActivityNew,
47
50
} = props ;
48
51
49
52
const onSubmit = async ( ) => {
@@ -54,10 +57,10 @@ const SearchLibrary = (props) => {
54
57
setActiveTab ( fromTeam ? "projects" : "Independent activities" ) ;
55
58
if ( searchInput ?. length > 255 ) {
56
59
Swal . fire ( "Character limit should be less than 255." ) ;
57
- } else if (
58
- activeMainSearchType === "Projects" ||
59
- activeMainSearchType === "projects"
60
- ) {
60
+ return ;
61
+ }
62
+
63
+ if ( true ) {
61
64
// Swal.fire({
62
65
// title: 'Searching...', // add html attribute if you want or remove
63
66
// html: 'We are fetching results for you!',
@@ -66,28 +69,33 @@ const SearchLibrary = (props) => {
66
69
// Swal.showLoading();
67
70
// },
68
71
// });
69
- const dataSend = {
70
- phrase : searchInput ?. trim ( ) ,
72
+ let dataSend ;
73
+ // eslint-disable-next-line prefer-const
74
+ dataSend = {
75
+ query : searchInput ?. trim ( ) ,
71
76
subjectArray : activeSubject ,
72
77
gradeArray : activeEducation ,
73
78
authorTagsArray : activeAuthorTag ,
79
+ authors : authorName || undefined ,
74
80
standardArray : activeType ,
75
- author : authorName || undefined ,
76
- fromDate : fromdate || undefined ,
77
- toDate : todate || undefined ,
78
- type : searchType ,
79
81
from : 0 ,
82
+ model :
83
+ activeModel === "total"
84
+ ? undefined
85
+ : activeModel || undefined ,
80
86
size : 20 ,
81
- model : "projects" ,
82
87
no_words : noWords || undefined ,
83
88
} ;
84
- console . log ( "dataSend" , dataSend ) ;
85
- const result = await dispatch ( simpleSearchAction ( dataSend ) ) ;
86
- setTotalCount ( result . meta ?. projects ) ;
89
+ const result = await dispatch (
90
+ searchIndependentActivitiesAction (
91
+ dataSend ,
92
+ "showcase_activities"
93
+ )
94
+ ) ;
95
+ setTotalCount ( result ?. meta ?. total ) ;
87
96
const tempEducation = [ ] ;
88
97
const tempSubject = [ ] ;
89
98
const tempTag = [ ] ;
90
- const tempAuthor = [ ] ;
91
99
if ( activeEducation ) {
92
100
activeEducation . forEach ( ( edu ) => {
93
101
if ( String ( edu ) . includes ( "&" ) ) {
@@ -114,12 +122,12 @@ const SearchLibrary = (props) => {
114
122
activeAuthorTag . forEach ( ( sub ) => {
115
123
if ( String ( sub ) . includes ( "&" ) ) {
116
124
const temp = String ( sub ) . replace ( "&" , "and" ) ;
117
- tempAuthor . push ( temp ) ;
125
+ tempTag . push ( temp ) ;
118
126
} else {
119
- tempAuthor . push ( sub ) ;
127
+ tempTag . push ( sub ) ;
120
128
}
121
129
} ) ;
122
- setActiveAuthorTag ( tempAuthor ) ;
130
+ setActiveAuthorTag ( tempTag ) ;
123
131
}
124
132
if ( ! fromTeam ) {
125
133
// eslint-disable-next-line max-len
@@ -129,7 +137,9 @@ const SearchLibrary = (props) => {
129
137
// }/search?q=${searchInput.trim()}&type=${searchType}&grade=${tempSubject}&education=${tempEducation}&authorTag=${tempTag}&h5p=${activeType}&author=${authorName}`,
130
138
// );
131
139
}
132
- } else if ( activeMainSearchType === "Independent activities" ) {
140
+ }
141
+
142
+ if ( true ) {
133
143
// Swal.fire({
134
144
// title: 'Searching...', // add html attribute if you want or remove
135
145
// html: 'We are fetching results for you!',
@@ -138,33 +148,33 @@ const SearchLibrary = (props) => {
138
148
// Swal.showLoading();
139
149
// },
140
150
// });
141
- let dataSend ;
142
- // eslint-disable-next-line prefer-const
143
- dataSend = {
144
- query : searchInput ?. trim ( ) ,
151
+ const dataSend = {
152
+ phrase : searchInput ?. trim ( ) ,
145
153
subjectArray : activeSubject ,
146
154
gradeArray : activeEducation ,
147
155
authorTagsArray : activeAuthorTag ,
148
- authors : authorName || undefined ,
149
156
standardArray : activeType ,
157
+ author : authorName || undefined ,
158
+ fromDate : fromdate || undefined ,
159
+ toDate : todate || undefined ,
160
+ type : "projects" ,
150
161
from : 0 ,
151
- model :
152
- activeModel === "total"
153
- ? undefined
154
- : activeModel || undefined ,
155
162
size : 20 ,
163
+ model : "projects" ,
156
164
no_words : noWords || undefined ,
157
165
} ;
158
- const result = await dispatch (
159
- searchIndependentActivitiesAction (
160
- dataSend ,
161
- "showcase_activities" ,
162
- ) ,
163
- ) ;
164
- setTotalCount ( result ?. meta ?. total ) ;
166
+ //if (searchTypeNew === "Independent activities") {
167
+ dispatch ( setSearchTypeAction ( "projects" ) ) ;
168
+ // } else {
169
+ // dispatch(setSearchTypeAction("Independent activities"));
170
+ // }
171
+
172
+ const result = await dispatch ( simpleSearchAction ( dataSend ) ) ;
173
+ setTotalCount ( result . meta ?. projects ) ;
165
174
const tempEducation = [ ] ;
166
175
const tempSubject = [ ] ;
167
176
const tempTag = [ ] ;
177
+ const tempAuthor = [ ] ;
168
178
if ( activeEducation ) {
169
179
activeEducation . forEach ( ( edu ) => {
170
180
if ( String ( edu ) . includes ( "&" ) ) {
@@ -191,12 +201,12 @@ const SearchLibrary = (props) => {
191
201
activeAuthorTag . forEach ( ( sub ) => {
192
202
if ( String ( sub ) . includes ( "&" ) ) {
193
203
const temp = String ( sub ) . replace ( "&" , "and" ) ;
194
- tempTag . push ( temp ) ;
204
+ tempAuthor . push ( temp ) ;
195
205
} else {
196
- tempTag . push ( sub ) ;
206
+ tempAuthor . push ( sub ) ;
197
207
}
198
208
} ) ;
199
- setActiveAuthorTag ( tempTag ) ;
209
+ setActiveAuthorTag ( tempAuthor ) ;
200
210
}
201
211
if ( ! fromTeam ) {
202
212
// eslint-disable-next-line max-len
@@ -207,26 +217,25 @@ const SearchLibrary = (props) => {
207
217
// );
208
218
}
209
219
}
220
+ dispatch ( setSearchTypeAction ( "Independent activities" ) ) ;
210
221
// setModalShow(true);
211
222
} ;
212
223
213
224
const clearFilters = async ( ) => {
214
225
setSearchInput ( "" ) ;
215
226
setNoWords ( "" ) ;
216
227
setAuthor ( "" ) ;
228
+ setSearch ( [ ] ) ;
229
+ setSearchActivityNew ( [ ] ) ;
217
230
setActiveEducation ( [ ] ) ;
218
231
setActiveSubject ( [ ] ) ;
219
232
setActiveAuthorTag ( [ ] ) ;
220
233
setActiveType ( [ ] ) ;
221
234
// onSubmit();
222
- const result = await dispatch ( simpleSearchAction ( { } ) ) ;
223
- const result1 = await dispatch (
224
- searchIndependentActivitiesAction (
225
- { } ,
226
- "showcase_activities" ,
227
- ) ,
228
- ) ;
229
-
235
+ // const result = await dispatch(simpleSearchAction({}));
236
+ // const result1 = await dispatch(
237
+ // searchIndependentActivitiesAction({}, "showcase_activities")
238
+ // );
230
239
} ;
231
240
return (
232
241
< Accordion defaultActiveKey = "0" >
@@ -311,11 +320,29 @@ const SearchLibrary = (props) => {
311
320
} }
312
321
/>
313
322
</ div >
314
- < div style = { { display : "flex" , justifyContent : "space-between" , color : "#1E68BF" , alignItem : "center" , alignItems : "center" } } >
315
- < div style = { { cursor : "pointer" , textDecoration : "underline" } } onClick = { ( ) => clearFilters ( ) } >
323
+ < div
324
+ style = { {
325
+ display : "flex" ,
326
+ justifyContent : "space-between" ,
327
+ color : "#1E68BF" ,
328
+ alignItem : "center" ,
329
+ alignItems : "center" ,
330
+ } }
331
+ >
332
+ < div
333
+ style = { {
334
+ cursor : "pointer" ,
335
+ textDecoration : "underline" ,
336
+ } }
337
+ onClick = { ( ) => clearFilters ( ) }
338
+ >
316
339
Clear All
317
340
</ div >
318
- < div className = "src-btn" style = { { marginBottom : "unset" } } onClick = { ( ) => onSubmit ( ) } >
341
+ < div
342
+ className = "src-btn"
343
+ style = { { marginBottom : "unset" } }
344
+ onClick = { ( ) => onSubmit ( ) }
345
+ >
319
346
< FontAwesomeIcon icon = "search" />
320
347
Search
321
348
</ div >
0 commit comments