@truedat/cx 5.6.2 → 5.6.4

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/cx",
3
- "version": "5.6.2",
3
+ "version": "5.6.4",
4
4
  "description": "Truedat Web Connectors",
5
5
  "sideEffects": false,
6
6
  "jsnext:main": "src/index.js",
@@ -34,7 +34,7 @@
34
34
  "@testing-library/jest-dom": "^5.16.5",
35
35
  "@testing-library/react": "^12.0.0",
36
36
  "@testing-library/user-event": "^13.2.1",
37
- "@truedat/test": "5.6.2",
37
+ "@truedat/test": "5.6.4",
38
38
  "babel-jest": "^28.1.0",
39
39
  "babel-plugin-dynamic-import-node": "^2.3.3",
40
40
  "babel-plugin-lodash": "^3.3.4",
@@ -91,7 +91,7 @@
91
91
  },
92
92
  "dependencies": {
93
93
  "@apollo/client": "^3.7.1",
94
- "@truedat/core": "5.6.2",
94
+ "@truedat/core": "5.6.4",
95
95
  "lodash": "^4.17.21",
96
96
  "match-sorter": "^6.3.1",
97
97
  "moment": "^2.29.4",
@@ -112,5 +112,5 @@
112
112
  "react-dom": ">= 16.8.6 < 17",
113
113
  "semantic-ui-react": ">= 2.0.3 < 2.2"
114
114
  },
115
- "gitHead": "a667767fbb979e9c12142aabad58f49d3fb68fea"
115
+ "gitHead": "fbecd33735354811f674678337ae16aaa15b4794"
116
116
  }
@@ -13,6 +13,7 @@ import {
13
13
  getJobSelectedFilterActiveValues,
14
14
  getJobSelectedFilters,
15
15
  getJobSelectedFilterValues,
16
+ getJobFilterTypes,
16
17
  } from "../selectors";
17
18
 
18
19
  export const mapStateToProps = (state) => {
@@ -24,6 +25,7 @@ export const mapStateToProps = (state) => {
24
25
  )(state);
25
26
  return {
26
27
  loading,
28
+ filterTypes: getJobFilterTypes(state),
27
29
  selectedFilter,
28
30
  selectedFilters: getJobSelectedFilters(state),
29
31
  selectedFilterActiveValues: getJobSelectedFilterActiveValues(state),
@@ -16,18 +16,15 @@ describe("reducers: jobFilters", () => {
16
16
  );
17
17
  });
18
18
 
19
- it("should handle the fetchJobFilters.REQUEST action", () => {
20
- expect(jobFilters(fooState, { type: fetchJobFilters.REQUEST })).toEqual(
21
- initialState
22
- );
23
- });
24
-
25
19
  it("should handle the fetchJobFilters.SUCCESS action", () => {
26
- const data = { filter1: ["value1", "value2"], filter2: ["value1"] };
20
+ const data = {
21
+ filter1: { values: ["value1", "value2"] },
22
+ filter2: { values: ["value1"] },
23
+ };
27
24
  expect(
28
25
  jobFilters(fooState, {
29
26
  type: fetchJobFilters.SUCCESS,
30
- payload: { data: { data } }
27
+ payload: { data: { data } },
31
28
  })
32
29
  ).toEqual(data);
33
30
  });
@@ -20,5 +20,5 @@ export {
20
20
  jobSelectedFilter,
21
21
  jobs,
22
22
  jobsLoading,
23
- jobsPageSize
23
+ jobsPageSize,
24
24
  };
@@ -7,10 +7,11 @@ const jobFilters = (state = initialState, { type, payload }) => {
7
7
  switch (type) {
8
8
  case clearJobFilters.TRIGGER:
9
9
  return initialState;
10
- case fetchJobFilters.REQUEST:
11
- return initialState;
12
10
  case fetchJobFilters.SUCCESS:
13
- return _.flow(_.propOr({}, "data.data"), _.omitBy(_.isEmpty))(payload);
11
+ return _.flow(
12
+ _.propOr({}, "data.data"),
13
+ _.omitBy(_.flow(_.getOr([], "values"), _.isEmpty))
14
+ )(payload);
14
15
  default:
15
16
  return state;
16
17
  }
@@ -1,9 +1,9 @@
1
1
  import { getJobAvailableFilters } from "..";
2
2
 
3
- const foo = ["foo1", "foo2"];
4
- const bar = ["bar1", "bar2"];
5
- const bay = ["bay1"];
6
- const baz = ["baz1", "baz2"];
3
+ const foo = { values: ["foo1", "foo2"] };
4
+ const bar = { values: ["bar1", "bar2"] };
5
+ const bay = { values: ["bay1"] };
6
+ const baz = { values: ["baz1", "baz2"] };
7
7
 
8
8
  describe("selectors: getJobAvailableFilters", () => {
9
9
  const jobFilters = { foo, bar, bay, baz };
@@ -1,8 +1,8 @@
1
1
  import { getJobSelectedFilterValues } from "..";
2
2
 
3
- const foo = ["foo1", "foo2"];
4
- const bar = ["bar1", "bar2"];
5
- const baz = ["baz1", "baz2"];
3
+ const foo = { values: ["foo1", "foo2"] };
4
+ const bar = { values: ["bar1", "bar2"] };
5
+ const baz = { values: ["baz1", "baz2"] };
6
6
 
7
7
  describe("selectors: getJobSelectedFilterValues", () => {
8
8
  const jobFilters = { foo, bar, baz };
@@ -10,6 +10,6 @@ describe("selectors: getJobSelectedFilterValues", () => {
10
10
  const state = { jobFilters, jobSelectedFilter };
11
11
 
12
12
  it("should return the values of the currently selected job filters", () => {
13
- expect(getJobSelectedFilterValues(state)).toEqual(foo);
13
+ expect(getJobSelectedFilterValues(state)).toEqual(foo.values);
14
14
  });
15
15
  });
@@ -8,7 +8,7 @@ export const getJobAvailableFilters = createSelector(
8
8
  [getJobFilters, getJobSelectedFilters],
9
9
  (jobFilters, jobSelectedFilters) =>
10
10
  _.flow(
11
- _.omitBy(values => _.size(values) < 2),
11
+ _.omitBy(({ values }) => _.size(values) < 2),
12
12
  _.keys,
13
13
  _.without(jobSelectedFilters)
14
14
  )(jobFilters)
@@ -0,0 +1,7 @@
1
+ import _ from "lodash/fp";
2
+ import { createSelector } from "reselect";
3
+
4
+ export const getJobFilterTypes = createSelector(
5
+ _.prop("jobFilters"),
6
+ _.mapValues("type")
7
+ );
@@ -1,7 +1,12 @@
1
1
  import _ from "lodash/fp";
2
2
  import { createSelector } from "reselect";
3
+ import { formatFilterValues } from "@truedat/core/services/filters";
3
4
 
4
5
  export const getJobSelectedFilterValues = createSelector(
5
6
  [_.prop("jobSelectedFilter"), _.prop("jobFilters")],
6
- (jobSelectedFilter, jobFilters) => _.propOr([], jobSelectedFilter)(jobFilters)
7
+ (jobSelectedFilter, jobFilters) =>
8
+ _.flow(
9
+ _.propOr({ values: [] }, jobSelectedFilter),
10
+ formatFilterValues
11
+ )(jobFilters)
7
12
  );
@@ -1,4 +1,5 @@
1
1
  export { getJobAvailableFilters } from "./getJobAvailableFilters";
2
+ export { getJobFilterTypes } from "./getJobFilterTypes";
2
3
  export { getJobSelectedFilterActiveValues } from "./getJobSelectedFilterActiveValues";
3
4
  export { getJobSelectedFilters } from "./getJobSelectedFilters";
4
5
  export { getJobSelectedFilterValues } from "./getJobSelectedFilterValues";