datastake-daf 0.6.738 → 0.6.739

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.
@@ -7094,7 +7094,7 @@ const getAjaxData = async ({
7094
7094
  apiUrl,
7095
7095
  app
7096
7096
  }) => {
7097
- const noQuerryApps = ["nashiriki", "straatos"];
7097
+ const noQuerryApps = ["nashiriki", "straatos", "wazi", "hatua"];
7098
7098
  const data = await axios__default["default"].post(noQuerryApps.includes(app) ? "/query" : "/query/options", {
7099
7099
  entity,
7100
7100
  method,
@@ -5316,7 +5316,7 @@ const getAjaxData = async ({
5316
5316
  apiUrl,
5317
5317
  app
5318
5318
  }) => {
5319
- const noQuerryApps = ["nashiriki", "straatos"];
5319
+ const noQuerryApps = ["nashiriki", "straatos", "wazi", "hatua"];
5320
5320
  const data = await axios__default["default"].post(noQuerryApps.includes(app) ? "/query" : "/query/options", {
5321
5321
  entity,
5322
5322
  method,
@@ -16183,7 +16183,144 @@ const getFiltersConfig$4 = ({
16183
16183
  return {
16184
16184
  country: {
16185
16185
  type: 'select',
16186
- placeholder: t('Country'),
16186
+ label: 'Country',
16187
+ placeholder: t => `${t('Filter by')} ${t('Country').toLowerCase()}`,
16188
+ style: {
16189
+ flex: 1
16190
+ },
16191
+ labelStyle: {
16192
+ flex: 1
16193
+ },
16194
+ getLabel: option => option.label,
16195
+ getValue: option => option.value
16196
+ },
16197
+ administrativeLevel1: {
16198
+ type: 'ajaxSelect',
16199
+ label: ({
16200
+ t = s => s,
16201
+ options = {},
16202
+ filters = {},
16203
+ language = 'en'
16204
+ }) => {
16205
+ const {
16206
+ administrativeLevel1
16207
+ } = options;
16208
+ if (administrativeLevel1) {
16209
+ if (options.country) {
16210
+ const _item = administrativeLevel1[filters.country];
16211
+ if (_item) {
16212
+ if (_item[language]) {
16213
+ return _item[language];
16214
+ }
16215
+ }
16216
+ }
16217
+ }
16218
+ return t('Province');
16219
+ },
16220
+ placeholder: t => `${t('Filter by')} ${t('Province').toLowerCase()}`,
16221
+ filters: data => ({
16222
+ country: data.country,
16223
+ level: 'level_1'
16224
+ }),
16225
+ show: data => !data.country,
16226
+ disabled: data => !data.country,
16227
+ mapper: {
16228
+ label: "name",
16229
+ value: "id"
16230
+ },
16231
+ method: 'getOptions',
16232
+ entity: 'AdministrativeLevel',
16233
+ style: {
16234
+ flex: 1
16235
+ },
16236
+ labelStyle: {
16237
+ flex: 1
16238
+ }
16239
+ },
16240
+ administrativeLevel2: {
16241
+ type: 'ajaxSelect',
16242
+ label: ({
16243
+ t = s => s,
16244
+ options = {},
16245
+ filters = {},
16246
+ language = 'en'
16247
+ }) => {
16248
+ const {
16249
+ administrativeLevel2
16250
+ } = options;
16251
+ if (administrativeLevel2) {
16252
+ if (options.country) {
16253
+ const _item = administrativeLevel2[filters.country];
16254
+ if (_item) {
16255
+ if (_item[language]) {
16256
+ return _item[language];
16257
+ }
16258
+ }
16259
+ }
16260
+ }
16261
+ return t('Province');
16262
+ },
16263
+ show: data => !(data.country && data.administrativeLevel1),
16264
+ placeholder: t => `${t('Filter by')} ${t('Territory').toLowerCase()}`,
16265
+ filters: data => ({
16266
+ country: data.country,
16267
+ level: 'level_2',
16268
+ administrativeLevel1: data.administrativeLevel1
16269
+ }),
16270
+ disabled: data => !(data.country && data.administrativeLevel1),
16271
+ mapper: {
16272
+ label: "name",
16273
+ value: "id"
16274
+ },
16275
+ method: 'getOptions',
16276
+ entity: 'AdministrativeLevel',
16277
+ style: {
16278
+ flex: 1
16279
+ },
16280
+ labelStyle: {
16281
+ flex: 1
16282
+ }
16283
+ },
16284
+ subCategory: {
16285
+ type: 'select',
16286
+ label: 'Sub Category',
16287
+ placeholder: t => `${t('Filter by')} ${t('Sub Category').toLowerCase()}`,
16288
+ style: {
16289
+ flex: 1
16290
+ },
16291
+ labelStyle: {
16292
+ flex: 1
16293
+ },
16294
+ getLabel: option => option.label,
16295
+ getValue: option => option.value,
16296
+ filterOptions: val => {
16297
+ if (val) {
16298
+ const {
16299
+ option,
16300
+ filters
16301
+ } = val;
16302
+ if (filters && option) {
16303
+ const {
16304
+ filters: optionFilters
16305
+ } = option;
16306
+ if (Array.isArray(optionFilters) && optionFilters.length) {
16307
+ const {
16308
+ value,
16309
+ condition
16310
+ } = optionFilters[0];
16311
+ if (condition === 'includes') {
16312
+ return value.includes('corporation');
16313
+ }
16314
+ }
16315
+ }
16316
+ }
16317
+ return true;
16318
+ }
16319
+ },
16320
+ positionInTheMineralSupplyChain: {
16321
+ type: 'select',
16322
+ label: 'Position',
16323
+ placeholder: t => `${t('Filter by')} ${t('Position').toLowerCase()}`,
16187
16324
  style: {
16188
16325
  flex: 1
16189
16326
  },
@@ -16192,6 +16329,19 @@ const getFiltersConfig$4 = ({
16192
16329
  },
16193
16330
  getLabel: option => option.label,
16194
16331
  getValue: option => option.value
16332
+ },
16333
+ status: {
16334
+ type: "select",
16335
+ label: "Status",
16336
+ placeholder: t => `${t("Filter by")} ${t("Status").toLowerCase()}`,
16337
+ style: {
16338
+ flex: 1
16339
+ },
16340
+ labelStyle: {
16341
+ fley: 1
16342
+ },
16343
+ getLabel: option => option.label,
16344
+ getValue: option => option.value
16195
16345
  }
16196
16346
  };
16197
16347
  };
@@ -16201,10 +16351,32 @@ const filtersConfig$4 = {
16201
16351
  };
16202
16352
  const getFilterOptions$4 = (options, t) => {
16203
16353
  const {
16204
- countries
16354
+ statusOptions = [],
16355
+ categoryOptions = [],
16356
+ countries = [],
16357
+ subCategory = [],
16358
+ subCategoriesOptions,
16359
+ stakeholderCategoryOptions,
16360
+ stakeholderSubCategoriesOptions,
16361
+ administrativeLevel1,
16362
+ administrativeLevel2
16205
16363
  } = options || {};
16364
+ console.log({
16365
+ options
16366
+ });
16206
16367
  const _default = {
16207
- country: countries
16368
+ category: stakeholderCategoryOptions || categoryOptions,
16369
+ country: countries,
16370
+ administrativeLevel1,
16371
+ administrativeLevel2,
16372
+ subCategory: subCategoriesOptions,
16373
+ status: [{
16374
+ value: "submitted",
16375
+ label: "Submitted"
16376
+ }, {
16377
+ value: "private",
16378
+ label: "Private"
16379
+ }]
16208
16380
  };
16209
16381
  return _default;
16210
16382
  };
@@ -20238,7 +20410,7 @@ function Geolocation({
20238
20410
  }
20239
20411
 
20240
20412
  const noDafApps = ['tif', 'cukura']; //PACKAGE_CHANGE_LATER (remove sbg)
20241
- const packageApps$1 = ["kota", "sbg", "nashiriki", "straatos"]; //PACKAGE_CHANGE_LATER (add sbg)
20413
+ const packageApps$1 = ["kota", "sbg", "nashiriki", "straatos", "wazi", "hatua"]; //PACKAGE_CHANGE_LATER (add sbg)
20242
20414
 
20243
20415
  function useAjaxModal$1({
20244
20416
  name = {},
@@ -24639,7 +24811,7 @@ function convertUndefinedToNull(obj) {
24639
24811
  return obj;
24640
24812
  }
24641
24813
 
24642
- const packageApps = ["kota", "sbg", "nashiriki", "straatos"]; //PACKAGE_CHANGE_LATER (add sbg)
24814
+ const packageApps = ["kota", "sbg", "nashiriki", "straatos", "wazi", "hatua"]; //PACKAGE_CHANGE_LATER (add sbg)
24643
24815
 
24644
24816
  function useAjaxModal({
24645
24817
  name = {},
@@ -29961,7 +30133,10 @@ const StakeholdersCreate$2 = ({
29961
30133
  className: "daf-create-form",
29962
30134
  children: /*#__PURE__*/jsxRuntime.jsx(DynamicForm, {
29963
30135
  form: form,
29964
- data: data,
30136
+ data: {
30137
+ ...defaultData,
30138
+ ...data
30139
+ },
29965
30140
  showSaveAndNext: false,
29966
30141
  module: APP,
29967
30142
  onCancel: onCancel,
@@ -30036,7 +30211,8 @@ const OperatorsTable = ({
30036
30211
  formData = {},
30037
30212
  formValue = {},
30038
30213
  form = {},
30039
- extendingFilters = {}
30214
+ extendingFilters = {},
30215
+ createDefaultValues = {}
30040
30216
  }) => {
30041
30217
  const [selectOptions, setSelectOptions] = React.useState();
30042
30218
  const [activeTab, setActiveTab] = React.useState();
@@ -30061,32 +30237,26 @@ const OperatorsTable = ({
30061
30237
  } = useGetQueryParams({
30062
30238
  location
30063
30239
  });
30064
- const filters = React.useMemo(() => {
30240
+ React.useMemo(() => {
30065
30241
  return {
30066
30242
  ...otherParams,
30067
30243
  ...extendingFilters
30068
30244
  };
30069
30245
  }, [otherParams, extendingFilters]);
30070
30246
  React.useEffect(() => {
30071
- console.log("fetching data");
30072
30247
  getData({
30073
30248
  pagination: paginationQuery,
30074
- ...(Object.keys(filters).length > 0 && {
30075
- filters: filters
30076
- }),
30077
30249
  ...(Object.keys(searchParams).length > 0 && {
30078
30250
  search: searchParams
30079
30251
  }),
30252
+ ...otherParams,
30080
30253
  tab: activeTab,
30081
30254
  sortBy: {
30082
30255
  [sortBy || "updatedAt"]: sortDir ? sortDir === "ascend" ? 1 : -1 : -1
30083
- }
30256
+ },
30257
+ ...extendingFilters
30084
30258
  }, 'operators');
30085
- console.log("data fetched");
30086
30259
  }, [location.search, activeTab, JSON.stringify(extendingFilters)]);
30087
- console.log({
30088
- data
30089
- });
30090
30260
  const selectFiltersConfig = React.useMemo(() => {
30091
30261
  return getFiltersConfig$4({
30092
30262
  t
@@ -30128,6 +30298,7 @@ const OperatorsTable = ({
30128
30298
  children: ({
30129
30299
  onDrawerClose
30130
30300
  }) => /*#__PURE__*/jsxRuntime.jsx(StakeholdersCreate$2, {
30301
+ defaultData: createDefaultValues,
30131
30302
  t: t,
30132
30303
  goTo: goTo,
30133
30304
  user: user,
@@ -1439,14 +1439,6 @@ class LinkedSubjectsService extends BaseService {
1439
1439
  }
1440
1440
  var LinkedSubjects = createLazyService(LinkedSubjectsService);
1441
1441
 
1442
- const namespaceEnums = {
1443
- scl: "location",
1444
- workers: "worker",
1445
- operators: "operator",
1446
- testimonials: "nashirikiEvent",
1447
- armedGroups: "armed-groups",
1448
- conflictAreas: "location"
1449
- };
1450
1442
  class OperatorService extends BaseService {
1451
1443
  get(params) {
1452
1444
  return this.apiGet({
@@ -1457,7 +1449,7 @@ class OperatorService extends BaseService {
1457
1449
  }
1458
1450
  getForm(scope = "create", language = "en") {
1459
1451
  return this.apiGet({
1460
- url: `/forms/${namespaceEnums["operators"]}`,
1452
+ url: `/forms/stakeholder`,
1461
1453
  isApp: true,
1462
1454
  params: {
1463
1455
  scope,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datastake-daf",
3
- "version": "0.6.738",
3
+ "version": "0.6.739",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.2.5",
6
6
  "@antv/g2": "^5.1.1",
@@ -5,7 +5,7 @@ import { getToken } from "../../../../../../helpers/Token";
5
5
  import { noDafApps } from "../../../ViewForm/components/DataLink/useAjaxModal";
6
6
  import { sortForm } from "../../../../../../helpers/Forms";
7
7
 
8
- const packageApps = ["kota", "sbg", "nashiriki", "straatos"]; //PACKAGE_CHANGE_LATER (add sbg)
8
+ const packageApps = ["kota", "sbg", "nashiriki", "straatos", "wazi", "hatua"]; //PACKAGE_CHANGE_LATER (add sbg)
9
9
 
10
10
  export default function useAjaxModal({
11
11
  name = {},
@@ -16,7 +16,7 @@ const getAjaxData = async ({
16
16
  apiUrl,
17
17
  app,
18
18
  }) => {
19
- const noQuerryApps = ["nashiriki","straatos"];
19
+ const noQuerryApps = ["nashiriki","straatos", "wazi", "hatua"];
20
20
  const data = await axios.post(
21
21
  noQuerryApps.includes(app) ? "/query" : "/query/options",
22
22
  {
@@ -4,7 +4,7 @@ import { getToken } from "../../../../../helpers/Token";
4
4
  import { noDafApps } from "../../ViewForm/components/DataLink/useAjaxModal";
5
5
  import { sortForm } from "../../../../../helpers/Forms";
6
6
 
7
- const packageApps = ["kota", "sbg", "nashiriki", "straatos"]; //PACKAGE_CHANGE_LATER (add sbg)
7
+ const packageApps = ["kota", "sbg", "nashiriki", "straatos", "wazi", "hatua"]; //PACKAGE_CHANGE_LATER (add sbg)
8
8
 
9
9
  export default function useAjaxModal({
10
10
  name = {},
@@ -3,7 +3,7 @@ import axios from "axios";
3
3
  import { sortForm } from "../../../../../../helpers/Forms";
4
4
 
5
5
  export const noDafApps = ['tif', 'cukura']; //PACKAGE_CHANGE_LATER (remove sbg)
6
- const packageApps = ["kota", "sbg", "nashiriki", "straatos"]; //PACKAGE_CHANGE_LATER (add sbg)
6
+ const packageApps = ["kota", "sbg", "nashiriki", "straatos", "wazi", "hatua"]; //PACKAGE_CHANGE_LATER (add sbg)
7
7
 
8
8
  export default function useAjaxModal({
9
9
  name = {},
@@ -5,15 +5,121 @@ export const checkboxConfig = {
5
5
 
6
6
  export const getFiltersConfig = ({t}) => {
7
7
  return {
8
- country: {
9
- type: 'select',
10
- placeholder: t('Country'),
11
- style: { flex: 1 },
12
- labelStyle: { flex: 1 },
13
- getLabel: (option) => option.label,
14
- getValue: (option) => option.value,
8
+ country: {
9
+ type: 'select',
10
+ label: 'Country',
11
+ placeholder: (t) => `${t('Filter by')} ${t('Country').toLowerCase()}`,
12
+ style: { flex: 1 },
13
+ labelStyle: { flex: 1 },
14
+ getLabel: (option) => option.label,
15
+ getValue: (option) => option.value,
15
16
  },
16
- }
17
+ administrativeLevel1: {
18
+ type: 'ajaxSelect',
19
+ label: ({ t = (s) => s, options = {}, filters = {}, language = 'en' }) => {
20
+ const { administrativeLevel1 } = options;
21
+
22
+ if (administrativeLevel1) {
23
+ if (options.country) {
24
+ const _item = administrativeLevel1[filters.country];
25
+ if (_item) {
26
+ if (_item[language]) {
27
+ return _item[language]
28
+ }
29
+ }
30
+ }
31
+ }
32
+
33
+ return t('Province');
34
+ },
35
+ placeholder: (t) => `${t('Filter by')} ${t('Province').toLowerCase()}`,
36
+ filters: (data) => ({
37
+ country: data.country,
38
+ level: 'level_1',
39
+ }),
40
+ show: (data) => !data.country,
41
+ disabled: (data) => !data.country,
42
+ mapper: { label: "name", value: "id" },
43
+ method: 'getOptions',
44
+ entity: 'AdministrativeLevel',
45
+ style: { flex: 1 },
46
+ labelStyle: { flex: 1 },
47
+ },
48
+ administrativeLevel2: {
49
+ type: 'ajaxSelect',
50
+ label: ({ t = (s) => s, options = {}, filters = {}, language = 'en' }) => {
51
+ const { administrativeLevel2 } = options;
52
+
53
+ if (administrativeLevel2) {
54
+ if (options.country) {
55
+ const _item = administrativeLevel2[filters.country];
56
+ if (_item) {
57
+ if (_item[language]) {
58
+ return _item[language]
59
+ }
60
+ }
61
+ }
62
+ }
63
+
64
+ return t('Province');
65
+ },
66
+ show: (data) => !(data.country && data.administrativeLevel1),
67
+ placeholder: (t) => `${t('Filter by')} ${t('Territory').toLowerCase()}`,
68
+ filters: (data) => ({
69
+ country: data.country,
70
+ level: 'level_2',
71
+ administrativeLevel1: data.administrativeLevel1,
72
+ }),
73
+ disabled: (data) => !(data.country && data.administrativeLevel1),
74
+ mapper: { label: "name", value: "id" },
75
+ method: 'getOptions',
76
+ entity: 'AdministrativeLevel',
77
+ style: { flex: 1 },
78
+ labelStyle: { flex: 1 },
79
+ },
80
+ subCategory: {
81
+ type: 'select',
82
+ label: 'Sub Category',
83
+ placeholder: (t) => `${t('Filter by')} ${t('Sub Category').toLowerCase()}`,
84
+ style: { flex: 1 },
85
+ labelStyle: { flex: 1 },
86
+ getLabel: (option) => option.label,
87
+ getValue: (option) => option.value,
88
+ filterOptions: (val) => {
89
+ if (val) {
90
+ const { option, filters } = val
91
+ if (filters && option) {
92
+ const { filters: optionFilters } = option;
93
+ if (Array.isArray(optionFilters) && optionFilters.length) {
94
+ const { value, condition } = optionFilters[0];
95
+ if (condition === 'includes') {
96
+ return value.includes('corporation');
97
+ }
98
+ }
99
+ }
100
+ }
101
+ return true;
102
+ },
103
+ },
104
+ positionInTheMineralSupplyChain: {
105
+ type: 'select',
106
+ label: 'Position',
107
+ placeholder: (t) => `${t('Filter by')} ${t('Position').toLowerCase()}`,
108
+ style: { flex: 1 },
109
+ labelStyle: { flex: 1 },
110
+ getLabel: (option) => option.label,
111
+ getValue: (option) => option.value,
112
+ },
113
+ status: {
114
+ type: "select",
115
+ label: "Status",
116
+ placeholder: (t) => `${t("Filter by")} ${t("Status").toLowerCase()}`,
117
+ style: { flex: 1 },
118
+ labelStyle: { fley: 1 },
119
+ getLabel: (option) => option.label,
120
+ getValue: (option) => option.value,
121
+ },
122
+ }
17
123
  }
18
124
 
19
125
  export const filtersConfig = {
@@ -22,9 +128,35 @@ export const filtersConfig = {
22
128
  };
23
129
 
24
130
  export const getFilterOptions = (options, t) => {
25
- const { countries } = options || {};
131
+ const {
132
+ statusOptions = [],
133
+ categoryOptions = [],
134
+ countries = [],
135
+ subCategory = [],
136
+ subCategoriesOptions,
137
+ stakeholderCategoryOptions,
138
+ stakeholderSubCategoriesOptions,
139
+ administrativeLevel1,
140
+ administrativeLevel2,
141
+ } = options || {};
142
+ console.log({options})
143
+
26
144
  const _default = {
145
+ category: stakeholderCategoryOptions || categoryOptions,
27
146
  country: countries,
147
+ administrativeLevel1,
148
+ administrativeLevel2,
149
+ subCategory: subCategoriesOptions,
150
+ status: [
151
+ {
152
+ value: "submitted",
153
+ label: "Submitted",
154
+ },
155
+ {
156
+ value: "private",
157
+ label: "Private",
158
+ },
159
+ ],
28
160
  }
29
161
 
30
162
  return _default;
@@ -51,7 +51,7 @@ const StakeholdersCreate = ({
51
51
  <div className="daf-create-form">
52
52
  <DynamicForm
53
53
  form={form}
54
- data={data}
54
+ data={{...defaultData, ...data}}
55
55
  showSaveAndNext={false}
56
56
  module={APP}
57
57
  onCancel={onCancel}
@@ -33,6 +33,7 @@ const OperatorsTable = ({
33
33
  formValue = {},
34
34
  form = {},
35
35
  extendingFilters = {},
36
+ createDefaultValues = {},
36
37
  }) => {
37
38
  const [selectOptions, setSelectOptions] = useState();
38
39
  const [activeTab, setActiveTab] = useState();
@@ -61,21 +62,18 @@ const OperatorsTable = ({
61
62
  }, [otherParams, extendingFilters])
62
63
 
63
64
  useEffect(() => {
64
- console.log("fetching data")
65
65
  getData({
66
66
  pagination: paginationQuery,
67
- ...(Object.keys(filters).length > 0 && { filters: filters }),
68
67
  ...(Object.keys(searchParams).length > 0 && { search: searchParams }),
68
+ ...otherParams,
69
69
  tab: activeTab,
70
70
  sortBy: {
71
71
  [sortBy || "updatedAt"]: sortDir ? (sortDir === "ascend" ? 1 : -1) : -1,
72
- }
72
+ },
73
+ ...extendingFilters
73
74
  }, 'operators')
74
- console.log("data fetched")
75
75
  }, [location.search, activeTab, JSON.stringify(extendingFilters)]);
76
76
 
77
- console.log({data})
78
-
79
77
  const selectFiltersConfig = useMemo(() => {
80
78
  return getFiltersConfig({t});
81
79
  }, [t]);
@@ -119,6 +117,7 @@ const OperatorsTable = ({
119
117
  >
120
118
  {({onDrawerClose}) => (
121
119
  <StakeholdersCreate
120
+ defaultData={createDefaultValues}
122
121
  t={t}
123
122
  goTo={goTo}
124
123
  user={user}
@@ -23,7 +23,7 @@ class OperatorService extends BaseService {
23
23
 
24
24
  getForm(scope = "create", language = "en") {
25
25
  return this.apiGet({
26
- url: `/forms/${namespaceEnums["operators"]}`,
26
+ url: `/forms/stakeholder`,
27
27
  isApp: true,
28
28
  params: { scope, language },
29
29
  });