Skip to content

Commit

Permalink
Merge pull request #47 from dabapps/fix-add-collections-item
Browse files Browse the repository at this point in the history
Fix addCollectionItem
  • Loading branch information
JakeSidSmith authored Sep 5, 2019
2 parents a71d42b + 04c2247 commit 9b49099
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dabapps/redux-api-collections",
"version": "0.4.4",
"version": "0.4.5",
"description": "Type-safe helpers for dealing with Rest-Framework backed collections in Typescript",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/collections/reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export function addCollectionItem<T extends IdKeyedMap<T>>(
subgroup
);
const results = existingCollection.results.concat([
recordBuilder(action.payload),
recordBuilder(action.payload.data),
]);
const updatedCollection = {
...existingCollection,
Expand Down
8 changes: 5 additions & 3 deletions tests/collections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,11 @@ describe('Collections', () => {
const data2 = collections.reducers.collectionsReducer(
data,
addItemSuccess('llamas', '', {
furLength: 10,
id: '2',
name: 'Pajama',
data: {
furLength: 10,
id: '2',
name: 'Pajama',
},
})
);
const subCollection = getCollectionByName(data2, 'llamas');
Expand Down

0 comments on commit 9b49099

Please sign in to comment.