datastake-daf 0.6.821 → 0.6.822

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. package/dist/components/index.js +2343 -2337
  2. package/dist/pages/index.js +56 -19
  3. package/dist/utils/index.js +67 -134
  4. package/package.json +1 -1
  5. package/src/@daf/core/components/Screens/Admin/AdminModals/CombineLocation/columns.js +6 -5
  6. package/src/@daf/core/components/Screens/Admin/AdminModals/CombineLocation/index.jsx +161 -73
  7. package/src/@daf/core/components/Screens/Admin/AdminModals/CombineSubjects/columns.js +3 -2
  8. package/src/@daf/core/components/Screens/Admin/AdminModals/CombineSubjects/index.jsx +26 -33
  9. package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/column.js +3 -2
  10. package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/index.jsx +2 -6
  11. package/src/@daf/core/components/Screens/Admin/AdminTables/SubjectsTable/columns.js +1 -2
  12. package/src/@daf/core/components/Screens/Admin/AdminTables/SubjectsTable/index.jsx +2 -6
  13. package/src/@daf/core/components/Screens/Admin/AdminTables/hook.js +0 -1
  14. package/src/@daf/core/components/Screens/Admin/adminRoutes.js +3 -1
  15. package/src/@daf/core/components/ViewForm/content.jsx +2 -0
  16. package/src/@daf/pages/Events/config.js +2 -11
  17. package/src/@daf/pages/Stakeholders/ArmedGroups/config.js +34 -5
  18. package/src/constants/locales/en/translation.js +26 -10
  19. package/src/constants/locales/fr/translation.js +23 -75
  20. package/src/constants/locales/sp/translation.js +20 -61
  21. package/src/helpers/adminLevels.js +4 -0
  22. package/src/@daf/core/components/Screens/Admin/AdminModals/CombineLocation/helper.js +0 -79
  23. package/src/@daf/core/components/Screens/Admin/AdminModals/CombineSubjects/helper.js +0 -21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datastake-daf",
3
- "version": "0.6.821",
3
+ "version": "0.6.822",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.2.5",
6
6
  "@antv/g2": "^5.1.1",
@@ -28,7 +28,8 @@ export const getColumns = ({ t, selectOptions, module, entity }) => {
28
28
  key: "category",
29
29
  show: true,
30
30
  render: (value, all) => {
31
- const label = findOptions(value, selectOptions?.category);
31
+ const categories = [...(selectOptions?.locationCategories || []), ...(selectOptions?.productionSiteCategories || [])];
32
+ const label = findOptions(value, categories);
32
33
  return <Tooltip title={label}>{label}</Tooltip>;
33
34
  },
34
35
  },
@@ -38,7 +39,7 @@ export const getColumns = ({ t, selectOptions, module, entity }) => {
38
39
  key: "country",
39
40
  show: true,
40
41
  render: (value, all) => {
41
- const label = findOptions(value, selectOptions?.country);
42
+ const label = findOptions(value, selectOptions?.countries);
42
43
  return <Tooltip title={label}>{label}</Tooltip>;
43
44
  },
44
45
  },
@@ -47,7 +48,7 @@ export const getColumns = ({ t, selectOptions, module, entity }) => {
47
48
  dataIndex: "administrativeLevel1",
48
49
  key: "administrativeLevel1",
49
50
  ellipsis: true,
50
- show: entity.includes("locations"),
51
+ show: entity?.includes("location"),
51
52
  render: (value, all) => {
52
53
  let label;
53
54
  if(all?.administrativeLevel1 && value === all?.administrativeLevel1) {
@@ -63,7 +64,7 @@ export const getColumns = ({ t, selectOptions, module, entity }) => {
63
64
  title: t("Territory"),
64
65
  dataIndex: "administrativeLevel2",
65
66
  key: "administrativeLevel2",
66
- show: entity.includes("locations"),
67
+ show: entity?.includes("location"),
67
68
  render: (value, all) => {
68
69
  let label;
69
70
  if(all?.administrativeLevel2 && value === all?.administrativeLevel2) {
@@ -76,4 +77,4 @@ export const getColumns = ({ t, selectOptions, module, entity }) => {
76
77
  },
77
78
  },
78
79
  ].filter((c) => c?.show);
79
- };
80
+ };
@@ -3,8 +3,8 @@ import { Form, Input, Select, theme } from "antd";
3
3
  import { Container } from "../CombineModalStyle.js";
4
4
  import DAFTable from "../../../../Table/index.jsx";
5
5
  import { useMemo, useState } from "react";
6
- import { getAdminLevelName } from "../../../../../../../helpers/adminLevels.js";
7
- import { getColumns } from "./helper.js";
6
+ import { getAdminLevel } from "../../../../../../../helpers/adminLevels.js";
7
+ import { getColumns } from "./columns.js";
8
8
 
9
9
  const { useToken } = theme;
10
10
 
@@ -22,6 +22,11 @@ export default function CombineLocationModal({
22
22
  const [MainForm] = Form.useForm();
23
23
  const [isDisabled, setIsDisabled] = useState(true);
24
24
 
25
+ // Watch form values for cross-filtering
26
+ const selectedCountry = Form.useWatch('country', MainForm);
27
+ const selectedProvince = Form.useWatch('administrativeLevel1', MainForm);
28
+ const selectedTerritory = Form.useWatch('administrativeLevel2', MainForm);
29
+
25
30
  const columns = useMemo(() => {
26
31
  return getColumns({
27
32
  t,
@@ -32,6 +37,31 @@ export default function CombineLocationModal({
32
37
  });
33
38
  }, [selectedLocations, t, selectOptions, module, entity]);
34
39
 
40
+ const categories = [...(selectOptions?.locationCategories || []), ...(selectOptions?.productionSiteCategories || [])];
41
+
42
+ const getFilteredLocations = () => {
43
+ return selectedLocations.filter((location) => {
44
+ if (selectedCountry && location.country !== selectedCountry) {
45
+ return false;
46
+ }
47
+ if (selectedProvince) {
48
+ const provinceData = getAdminLevel(location?.linking?.SCL, "level_1") || location?.linking?.SCL?.[location?.administrativeLevel1];
49
+ const provinceCountry = provinceData?.country || location.country;
50
+ if (provinceData?.id !== selectedProvince || (selectedCountry && provinceCountry !== selectedCountry)) {
51
+ return false;
52
+ }
53
+ }
54
+ if (selectedTerritory) {
55
+ const territoryData = getAdminLevel(location?.linking?.SCL, "level_2") || location?.linking?.SCL?.[location?.administrativeLevel2];
56
+ const territoryCountry = territoryData?.country || location.country;
57
+ if (territoryData?.id !== selectedTerritory || (selectedCountry && territoryCountry !== selectedCountry)) {
58
+ return false;
59
+ }
60
+ }
61
+ return true;
62
+ });
63
+ };
64
+
35
65
  const onSubmit = () => {
36
66
  MainForm.validateFields().then((data) => {
37
67
  const ids = selectedLocations.map((location) => location.id);
@@ -105,20 +135,71 @@ export default function CombineLocationModal({
105
135
  {t("admin::merged_output")}
106
136
  </span>
107
137
 
108
- <Form
109
- form={MainForm}
110
- clearOnDestroy={true}
111
- className="select-container"
112
- onValuesChange={() => {
113
- setIsDisabled((prev) => {
114
- const values = MainForm.getFieldsValue();
115
- return Object.keys(values).some((key) => values[key] === undefined);
116
- });
117
- }}
118
- style={{
119
- borderColor: token.baseGray50,
120
- }}
121
- >
138
+ <Form
139
+ form={MainForm}
140
+ clearOnDestroy={true}
141
+ className="select-container"
142
+ onValuesChange={(changedValues) => {
143
+ if (changedValues.country !== undefined) {
144
+ const currentValues = MainForm.getFieldsValue();
145
+ const newCountry = changedValues.country;
146
+
147
+ if (currentValues.administrativeLevel1) {
148
+ const isProvinceValid = selectedLocations.some((location) => {
149
+ const provinceData = location?.linking?.SCL?.[location?.administrativeLevel1];
150
+ return location.country === newCountry && provinceData?.id === currentValues.administrativeLevel1;
151
+ });
152
+ if (!isProvinceValid) {
153
+ MainForm.setFieldsValue({
154
+ administrativeLevel1: undefined,
155
+ administrativeLevel2: undefined,
156
+ });
157
+ }
158
+ }
159
+
160
+ if (currentValues.administrativeLevel2) {
161
+ const isTerritoryValid = selectedLocations.some((location) => {
162
+ const territoryData = getAdminLevel(location?.linking?.SCL, "level_2") || location?.linking?.SCL?.[location?.administrativeLevel2];
163
+ return location.country === newCountry && territoryData?.id === currentValues.administrativeLevel2;
164
+ });
165
+ if (!isTerritoryValid) {
166
+ MainForm.setFieldsValue({
167
+ administrativeLevel2: undefined,
168
+ });
169
+ }
170
+ }
171
+ }
172
+
173
+ if (changedValues.administrativeLevel1 !== undefined) {
174
+ const currentValues = MainForm.getFieldsValue();
175
+ const newProvince = changedValues.administrativeLevel1;
176
+
177
+ if (currentValues.administrativeLevel2) {
178
+ const isTerritoryValid = selectedLocations.some((location) => {
179
+ const provinceData = location?.linking?.SCL?.[location?.administrativeLevel1];
180
+ const territoryData = getAdminLevel(location?.linking?.SCL, "level_2") || location?.linking?.SCL?.[location?.administrativeLevel2];
181
+ return provinceData?.id === newProvince && territoryData?.id === currentValues.administrativeLevel2;
182
+ });
183
+ if (!isTerritoryValid) {
184
+ MainForm.setFieldsValue({
185
+ administrativeLevel2: undefined,
186
+ });
187
+ }
188
+ }
189
+ }
190
+
191
+ setIsDisabled(() => {
192
+ const values = MainForm.getFieldsValue();
193
+ const requiredFields = entity?.includes("location")
194
+ ? ["id", "name", "category", "country", "administrativeLevel1", "administrativeLevel2"]
195
+ : ["id", "name", "category", "country"];
196
+ return requiredFields.some((field) => values[field] === undefined);
197
+ });
198
+ }}
199
+ style={{
200
+ borderColor: token.baseGray50,
201
+ }}
202
+ >
122
203
  <Form.Item className="flex-1" name="id">
123
204
  <Select
124
205
  options={selectedLocations.map((location) => {
@@ -128,6 +209,7 @@ export default function CombineLocationModal({
128
209
  };
129
210
  })}
130
211
  placeholder={t("ID")}
212
+ allowClear
131
213
  ></Select>
132
214
  </Form.Item>
133
215
 
@@ -141,7 +223,7 @@ export default function CombineLocationModal({
141
223
  .map((location) => {
142
224
  return {
143
225
  label:
144
- (selectOptions?.category || []).find(
226
+ (categories || []).find(
145
227
  (option) => option.value === location?.category,
146
228
  )?.label ||
147
229
  location?.category ||
@@ -154,68 +236,74 @@ export default function CombineLocationModal({
154
236
  index === self.findIndex((o) => o.value === option.value),
155
237
  )}
156
238
  placeholder={t("Category")}
239
+ allowClear
157
240
  ></Select>
158
241
  </Form.Item>
159
242
 
160
- <Form.Item className="flex-1" name="country">
161
- <Select
162
- options={selectedLocations
163
- .map((location) => {
164
- return {
165
- label:
166
- (selectOptions?.country || []).find(
167
- (option) => option.value === location?.country,
168
- )?.label ||
169
- location?.country ||
170
- "-",
171
- value: location?.country || "-",
172
- };
173
- })
174
- .filter(
175
- (option, index, self) =>
176
- index === self.findIndex((o) => o.value === option.value),
177
- )}
178
- placeholder={t("admin::country")}
179
- ></Select>
180
- </Form.Item>
243
+ <Form.Item className="flex-1" name="country">
244
+ <Select
245
+ options={getFilteredLocations()
246
+ .map((location) => {
247
+ return {
248
+ label:
249
+ (selectOptions?.countries || []).find(
250
+ (option) => option.value === location?.country,
251
+ )?.label ||
252
+ location?.country ||
253
+ "-",
254
+ value: location?.country || "-",
255
+ };
256
+ })
257
+ .filter(
258
+ (option, index, self) =>
259
+ index === self.findIndex((o) => o.value === option.value),
260
+ )}
261
+ placeholder={t("admin::country")}
262
+ allowClear
263
+ ></Select>
264
+ </Form.Item>
181
265
 
182
266
  {entity?.includes("location") && (
183
267
  <>
184
- <Form.Item className="flex-1" name="administrativeLevel1">
185
- <Select
186
- placeholder={t("Province")}
187
- options={selectedLocations
188
- .map((location) => {
189
- const _data = getAdminLevelName(location?.linking?.SCL, "level_1");
190
- return {
191
- label: _data?.name || "-",
192
- value: _data?.id || "-",
193
- };
194
- })
195
- .filter(
196
- (option, index, self) =>
197
- index === self.findIndex((o) => o.value === option.value),
198
- )}
199
- />
200
- </Form.Item>
201
-
202
- <Form.Item className="flex-1" name="administrativeLevel2">
203
- <Select
204
- placeholder={t("Territory")}
205
- options={selectedLocations
206
- .map((location) => {
207
- const _data = getAdminLevelName(location?.linking?.SCL, "level_2");
208
- return {
209
- label: _data?.name || "-",
210
- value: _data?.id || "-",
211
- };
212
- })
213
- .filter(
214
- (option, index, self) =>
215
- index === self.findIndex((o) => o.value === option.value),
216
- )}
217
- />
218
- </Form.Item>
268
+ <Form.Item className="flex-1" name="administrativeLevel1">
269
+ <Select
270
+ placeholder={t("Province")}
271
+ options={getFilteredLocations()
272
+ .map((location) => {
273
+ const _data = getAdminLevel(location?.linking?.SCL, "level_1") || location?.linking?.SCL?.[location?.administrativeLevel1];
274
+ return {
275
+ label: _data?.name || "-",
276
+ value: _data?.id || "-",
277
+ };
278
+ })
279
+ .filter(
280
+ (option, index, self) =>
281
+ index === self.findIndex((o) => o.value === option.value) &&
282
+ option.value !== "-",
283
+ )}
284
+ allowClear
285
+ />
286
+ </Form.Item>
287
+
288
+ <Form.Item className="flex-1" name="administrativeLevel2">
289
+ <Select
290
+ placeholder={t("Territory")}
291
+ options={getFilteredLocations()
292
+ .map((location) => {
293
+ const _data = getAdminLevel(location?.linking?.SCL, "level_2") || location?.linking?.SCL?.[location?.administrativeLevel2];
294
+ return {
295
+ label: _data?.name || "-",
296
+ value: _data?.id || "-",
297
+ };
298
+ })
299
+ .filter(
300
+ (option, index, self) =>
301
+ index === self.findIndex((o) => o.value === option.value) &&
302
+ option.value !== "-",
303
+ )}
304
+ allowClear
305
+ />
306
+ </Form.Item>
219
307
  </>
220
308
  )}
221
309
  </Form>
@@ -28,7 +28,8 @@ export const getColumns = ({ t, selectOptions, module, entity }) => {
28
28
  key: "category",
29
29
  show: true,
30
30
  render: (value, all) => {
31
- const label = findOptions(value, selectOptions?.category);
31
+ console.log({value, selectOptions})
32
+ const label = findOptions(value, selectOptions?.categoriesOptions || selectOptions?.category || []);
32
33
  return <Tooltip title={label}>{label}</Tooltip>;
33
34
  },
34
35
  },
@@ -38,7 +39,7 @@ export const getColumns = ({ t, selectOptions, module, entity }) => {
38
39
  key: "country",
39
40
  show: true,
40
41
  render: (value, all) => {
41
- const label = findOptions(value, selectOptions?.country);
42
+ const label = findOptions(value, selectOptions?.countries || []);
42
43
  return <Tooltip title={label}>{label}</Tooltip>;
43
44
  },
44
45
  },
@@ -4,7 +4,6 @@ import { Container } from "../CombineModalStyle.js";
4
4
  import { findOptions } from "../../../../../../../helpers/StringHelper.js";
5
5
  import DAFTable from "../../../../Table/index.jsx";
6
6
  import { useMemo, useState } from "react";
7
- import { mapToSelectOptions } from "./helper.js";
8
7
  import { getColumns } from "./columns.js";
9
8
  import { getAdminLevelName } from "../../../../../../../helpers/adminLevels.js";
10
9
 
@@ -34,6 +33,27 @@ export default function CombineSubjectsModal({
34
33
  });
35
34
  }, [selectedSubjects, t, selectOptions, module, entity]);
36
35
 
36
+ const countryOptions = useMemo(() => {
37
+ return [...new Set(selectedSubjects.map((subject) => subject?.country))].map((country) => {
38
+ console.log({country})
39
+ return {
40
+ label: findOptions(country, selectOptions?.countries || []),
41
+ value: country || "-",
42
+ };
43
+ });
44
+ }, [selectedSubjects, selectOptions]);
45
+
46
+ const categoriesOptions = useMemo(() => {
47
+ return [...new Set(selectedSubjects.map((subject) => subject?.category))].map((country) => {
48
+ console.log({country})
49
+ return {
50
+ label: findOptions(country, selectOptions?.categoriesOptions || selectOptions?.category || []),
51
+ value: country || "-",
52
+ };
53
+ });
54
+ }, [selectedSubjects, selectOptions]);
55
+
56
+
37
57
  const onSubmit = () => {
38
58
  MainForm.validateFields().then((data) => {
39
59
  const ids = selectedSubjects.map((subject) => subject.id);
@@ -119,6 +139,7 @@ export default function CombineSubjectsModal({
119
139
  value: s?.id || "-",
120
140
  }))}
121
141
  placeholder={t("ID")}
142
+ allowClear
122
143
  ></Select>
123
144
  </Form.Item>
124
145
 
@@ -128,47 +149,19 @@ export default function CombineSubjectsModal({
128
149
 
129
150
  <Form.Item className="flex-1" name="category">
130
151
  <Select
131
- options={mapToSelectOptions(selectedSubjects, "category", selectOptions, "category")}
152
+ options={categoriesOptions}
132
153
  placeholder={t("Category")}
154
+ allowClear
133
155
  ></Select>
134
156
  </Form.Item>
135
157
 
136
158
  <Form.Item className="flex-1" name="country">
137
159
  <Select
138
- options={mapToSelectOptions(selectedSubjects, "country", selectOptions, "country")}
160
+ options={countryOptions}
139
161
  placeholder={t("admin::country")}
162
+ allowClear
140
163
  ></Select>
141
164
  </Form.Item>
142
-
143
- {entity.includes("location") && (
144
- <>
145
- <Form.Item className="flex-1" name="administrativeLevel1">
146
- <Select
147
- placeholder={t("Province")}
148
- options={mapToSelectOptions(selectedSubjects, null, selectOptions, null, (subject) => {
149
- const _data = getAdminLevelName(subject?.linking?.SCL, "level_1");
150
- return {
151
- label: _data?.name || "-",
152
- value: _data?.id || "-",
153
- };
154
- })}
155
- />
156
- </Form.Item>
157
-
158
- <Form.Item className="flex-1" name="administrativeLevel2">
159
- <Select
160
- placeholder={t("Territory")}
161
- options={mapToSelectOptions(selectedSubjects, null, selectOptions, null, (subject) => {
162
- const _data = getAdminLevelName(subject?.linking?.SCL, "level_2");
163
- return {
164
- label: _data?.name || "-",
165
- value: _data?.id || "-",
166
- };
167
- })}
168
- />
169
- </Form.Item>
170
- </>
171
- )}
172
165
  </Form>
173
166
  </Container>
174
167
  <div style={{ height: 57 }} />
@@ -86,7 +86,8 @@ export const getColumns = ({
86
86
  return <div className="daf-default-cell" />;
87
87
  }
88
88
 
89
- const category = findOptions(value, options?.locationCategories || []) || "--";
89
+ const categories = [...(options?.locationCategories || []), ...(options?.productionSiteCategories || [])];
90
+ const category = findOptions(value, categories) || "-";
90
91
 
91
92
  return <Tooltip title={category}>{category}</Tooltip>;
92
93
  },
@@ -101,7 +102,7 @@ export const getColumns = ({
101
102
  if (all.empty) {
102
103
  return <div className="daf-default-cell" />;
103
104
  }
104
- const country = findOptions(value, selectOptions?.country || []) || "--";
105
+ const country = findOptions(value, selectOptions?.countries || []) || "-";
105
106
 
106
107
  return <Tooltip title={country}>{country}</Tooltip>;
107
108
  },
@@ -116,12 +116,8 @@ export default function LocationTable({
116
116
  });
117
117
 
118
118
  const selectOptions = useMemo(() => {
119
- return {
120
- category: config.options?.category,
121
- country: config.options?.countries,
122
- sources: [],
123
- };
124
- }, [config.options]);
119
+ return options
120
+ }, [options]);
125
121
 
126
122
  const columns = useMemo(() => {
127
123
  return getColumns({
@@ -85,8 +85,7 @@ export const getColumns = ({
85
85
  return <div className="daf-default-cell" />;
86
86
  }
87
87
 
88
- console.log({value, options})
89
- const category = findOptions(value, options?.categoriesOptions || []) || "-";
88
+ const category = findOptions(value, options?.categoriesOptions || options?.category || []) || "-";
90
89
 
91
90
  return <Tooltip title={category}>{category}</Tooltip>;
92
91
  },
@@ -113,12 +113,8 @@ export default function SubjectsTable({
113
113
  });
114
114
 
115
115
  const selectOptions = useMemo(() => {
116
- return {
117
- category: config.options?.category,
118
- country: config.options?.countries,
119
- sources: [],
120
- };
121
- }, [config.options]);
116
+ return options;
117
+ }, [options]);
122
118
 
123
119
  const columns = useMemo(() => {
124
120
  return getColumns({
@@ -32,7 +32,6 @@ export function useAdminTable({
32
32
  defaultPageSize: defaultPageSize || 20,
33
33
  getRedirectLink,
34
34
  });
35
- console.log(filter, "filter.activeFilters");
36
35
 
37
36
  const activeTab = useMemo(() => filter.activeFilters.activeTab, [filter.activeFilters]);
38
37
 
@@ -17,7 +17,7 @@ export function getAdminRoutes(config) {
17
17
  useAdminAccountsViewConfig,
18
18
  useAdminSubjectsConfig,
19
19
  useAdminLocationConfig,
20
-
20
+
21
21
  useAdminDocumentsConfig,
22
22
  useAdminEventsConfig,
23
23
  userIsAdmin,
@@ -25,6 +25,8 @@ export function getAdminRoutes(config) {
25
25
 
26
26
  const APP_PREFIX = `APP_${appName.toUpperCase()}`;
27
27
 
28
+ console.log({useAdminEventsConfig})
29
+
28
30
  function DashboardWrapper() {
29
31
  const dashboardConfig = useAdminDashboardConfig();
30
32
  return <AdminDashboardScreen config={dashboardConfig} />;
@@ -130,6 +130,8 @@ const Content = ({
130
130
  return all;
131
131
  }, {});
132
132
 
133
+ console.log({groups, singleGroupsKeys, addedContent, _length, groupped})
134
+
133
135
  return Object.keys(groupped).map((key) => {
134
136
  const groups = groupped[key];
135
137
 
@@ -77,16 +77,7 @@ export const getFiltersConfig = ({t}) => {
77
77
  style: { flex: 1 },
78
78
  labelStyle: { flex: 1 },
79
79
  },
80
- subCategory: {
81
- type: 'select',
82
- label: 'Category',
83
- placeholder: (t) => `${t('Filter by')} ${t('Category').toLowerCase()}`,
84
- style: { flex: 1 },
85
- labelStyle: { flex: 1 },
86
- getLabel: (option) => option.label,
87
- getValue: (option) => option.value,
88
- },
89
- category:{
80
+ eventCategory:{
90
81
  type: 'select',
91
82
  label: 'Category',
92
83
  placeholder: (t) => `${t('Filter by')} ${t('Category').toLowerCase()}`,
@@ -125,7 +116,7 @@ export const getFilterOptions = (options, t) => {
125
116
  return {
126
117
  timeframe: timeframe,
127
118
  country: countries || [],
128
- category: catOptions || [],
119
+ eventCategory: catOptions || [],
129
120
  status: [
130
121
  {
131
122
  value: "submitted",
@@ -2,6 +2,15 @@ import { getStatusOptions } from '../../../utils/filters';
2
2
 
3
3
  export const getFiltersConfig = ({t}) => {
4
4
  return {
5
+ country: {
6
+ type: 'select',
7
+ label: 'Country',
8
+ placeholder: () => `${t('Filter by')} ${t('Country').toLowerCase()}`,
9
+ style: { flex: 1 },
10
+ labelStyle: { flex: 1 },
11
+ getLabel: (option) => option.label,
12
+ getValue: (option) => option.value,
13
+ },
5
14
  status: {
6
15
  type: "select",
7
16
  label: "Status",
@@ -11,18 +20,38 @@ export const getFiltersConfig = ({t}) => {
11
20
  getLabel: (option) => option.label,
12
21
  getValue: (option) => option.value,
13
22
  },
14
- timeframe: {
15
- type: "timeframe",
16
- label: "Timeframe",
23
+ subCategory: {
24
+ type: 'select',
25
+ label: 'Sub Category',
26
+ placeholder: () => `${t('Filter by')} ${t('Sub Category').toLowerCase()}`,
17
27
  style: { flex: 1 },
18
- },
28
+ labelStyle: { flex: 1 },
29
+ getLabel: (option) => option.label,
30
+ getValue: (option) => option.value,
31
+ filterOptions: (val) => {
32
+ if (val) {
33
+ const { option, filters } = val
34
+ if (filters && option) {
35
+ const { filters: optionFilters } = option;
36
+ if (Array.isArray(optionFilters) && optionFilters.length) {
37
+ const { value, condition } = optionFilters[0];
38
+ if (condition === 'includes') {
39
+ return value.includes('nonStateArmedGroup');
40
+ }
41
+ }
42
+ }
43
+ }
44
+ return true;
45
+ },
46
+ },
19
47
  }
20
48
  }
21
49
 
22
50
  export const getFilterOptions = (options, t) => {
23
51
  const _default = {
24
52
  status: getStatusOptions(t) || [],
25
- timeframe: [],
53
+ country: options.countries || [],
54
+ subCategory: options.subCategory || [],
26
55
  }
27
56
 
28
57
  return _default;