mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-26 06:47:17 +10:00
Fix relationships format
This commit is contained in:
parent
7490c676f0
commit
2624b3bb9c
2 changed files with 5 additions and 5 deletions
|
|
@ -84,10 +84,10 @@ export const denormalisedEntities = (entities, type, ids) => {
|
|||
// A relationship reference can be either a single object or
|
||||
// an array of objects. We want to keep that form in the final
|
||||
// result.
|
||||
const hasMultipleRefs = Array.isArray(relRef);
|
||||
const refs = hasMultipleRefs ? relRef : [relRef];
|
||||
const relIds = refs.map(ref => ref.data.id);
|
||||
const relType = refs[0].data.type;
|
||||
const hasMultipleRefs = Array.isArray(relRef.data);
|
||||
const refs = hasMultipleRefs ? relRef.data : [relRef.data];
|
||||
const relIds = refs.map(ref => ref.id);
|
||||
const relType = refs[0].type;
|
||||
const rels = denormalisedEntities(entities, relType, relIds);
|
||||
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
|
|
|
|||
|
|
@ -255,7 +255,7 @@ describe('data utils', () => {
|
|||
const listing1 = createListing('listing1');
|
||||
const listing1Relationships = {
|
||||
author: { data: user1 },
|
||||
images: [{ data: image1 }, { data: image2 }],
|
||||
images: { data: [image1, image2] },
|
||||
};
|
||||
const listing1WithRelationships = { ...listing1, relationships: listing1Relationships };
|
||||
const listing2 = createListing('listing2');
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue