@feardread/feature-factory 5.0.3 → 5.0.5

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": "@feardread/feature-factory",
3
- "version": "5.0.3",
3
+ "version": "5.0.5",
4
4
  "description": "Library to interact with redux toolkit and reduce boilerplate / repeated code",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -102,13 +102,13 @@ export function FeatureFactory(entity, reducers = {}, endpoints = null) {
102
102
  .addCase(action.fulfilled, (state, actionPayload) => {
103
103
  state.loading = false;
104
104
  state.success = true;
105
- state.data = actionPayload.payload.result;
105
+ state.data = actionPayload.payload;
106
106
 
107
107
  // Handle single item for fetchOne operation
108
108
  if (key === 'fetchOne' && Array.isArray(actionPayload.payload)) {
109
- state[sliceName] = actionPayload.payload[0].result;
109
+ state[sliceName] = actionPayload.payload[0];
110
110
  } else if (Array.isArray(actionPayload.payload) && actionPayload.payload.length > 0) {
111
- state[sliceName] = actionPayload.payload[0].result;
111
+ state[sliceName] = actionPayload.payload[0];
112
112
  }
113
113
  })
114
114
  .addCase(action.rejected, (state, actionPayload) => {
@@ -18,7 +18,7 @@ const HTTP_METHODS = {
18
18
  const STANDARD_OPERATIONS = {
19
19
  all: { method: HTTP_METHODS.GET, useParams: false },
20
20
  one: { method: HTTP_METHODS.GET, useParams: false, useIdInUrl: true },
21
- search: { method: HTTP_METHODS.GET, useParams: true },
21
+ search: { method: HTTP_METHODS.POST, useParams: true },
22
22
  new: { method: HTTP_METHODS.POST, useParams: false },
23
23
  create: { method: HTTP_METHODS.POST, useParams: false },
24
24
  update: { method: HTTP_METHODS.PUT, useParams: false, useIdInUrl: true },
@@ -196,7 +196,7 @@ export const ThunkFactory = {
196
196
  post: (entity, prefix) => {
197
197
  return createGenericThunk(entity, prefix, {
198
198
  method: HTTP_METHODS.POST,
199
- useParams: false,
199
+ useParams: true,
200
200
  });
201
201
  },
202
202