|
8 | 8 | NumberOutput, |
9 | 9 | Pager, |
10 | 10 | Table, |
| 11 | + TextInput, |
11 | 12 | } from '@ifrc-go/ui'; |
12 | 13 | import { useTranslation } from '@ifrc-go/ui/hooks'; |
13 | 14 | import { |
@@ -111,6 +112,20 @@ export function Component() { |
111 | 112 | EventItem[] | undefined | null |
112 | 113 | >([]); |
113 | 114 |
|
| 115 | + const [positionFilter, setPositionFilter] = useUrlSearchState<string | undefined>( |
| 116 | + 'position', |
| 117 | + (searchValue: string | undefined) => { |
| 118 | + const potentialValue = isDefined(searchValue) |
| 119 | + ? String(searchValue) |
| 120 | + : undefined; |
| 121 | + if (isDefined(potentialValue)) { |
| 122 | + setPage(0); |
| 123 | + } |
| 124 | + return potentialValue; |
| 125 | + }, |
| 126 | + (position: string | undefined) => position, |
| 127 | + ); |
| 128 | + |
114 | 129 | useRequest({ |
115 | 130 | skip: isNotDefined(eventFilter) |
116 | 131 | || (!!eventOptions?.find((event) => event.id === eventFilter)), |
@@ -162,6 +177,7 @@ export function Component() { |
162 | 177 | offset, |
163 | 178 | event: eventFilter, |
164 | 179 | country: countryFilter, |
| 180 | + message__icontains: positionFilter, |
165 | 181 |
|
166 | 182 | // FIXME: this should come from the useFilterState |
167 | 183 | ordering: 'molnix_status,-opens', |
@@ -290,11 +306,19 @@ export function Component() { |
290 | 306 | triggerExportStart( |
291 | 307 | '/api/v2/surge_alert/', |
292 | 308 | surgeResponse?.count, |
293 | | - {}, |
| 309 | + { |
| 310 | + event: eventFilter, |
| 311 | + country: countryFilter, |
| 312 | + message__icontains: positionFilter, |
| 313 | + ordering: 'molnix_status,-opens', |
| 314 | + }, |
294 | 315 | ); |
295 | 316 | }, [ |
296 | 317 | triggerExportStart, |
297 | 318 | surgeResponse?.count, |
| 319 | + eventFilter, |
| 320 | + countryFilter, |
| 321 | + positionFilter, |
298 | 322 | ]); |
299 | 323 |
|
300 | 324 | const heading = resolveToComponent( |
@@ -328,6 +352,13 @@ export function Component() { |
328 | 352 | onOptionsChange={setEventOptions} |
329 | 353 | countryId={countryFilter} |
330 | 354 | /> |
| 355 | + <TextInput |
| 356 | + name="position" |
| 357 | + label={strings.positionFilterLabel} |
| 358 | + placeholder={strings.positionFilterPlaceholder} |
| 359 | + value={positionFilter} |
| 360 | + onChange={setPositionFilter} |
| 361 | + /> |
331 | 362 | </> |
332 | 363 | )} |
333 | 364 | footerActions={( |
|
0 commit comments