mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-26 06:47:17 +10:00
Handle missing attributes for listing or its author
This commit is contained in:
parent
1278f24b1a
commit
1cfbd46913
2 changed files with 5 additions and 3 deletions
|
|
@ -6,9 +6,11 @@ import css from './ListingCard.css';
|
|||
const ListingCard = props => {
|
||||
const { listing } = props;
|
||||
const id = listing.id.uuid;
|
||||
const { title, description, address } = listing.attributes;
|
||||
const { title = '', description = '', address = '' } = listing.attributes || {};
|
||||
const slug = encodeURIComponent(title.split(' ').join('-'));
|
||||
const authorName = `${listing.author.attributes.profile.firstName} ${listing.author.attributes.profile.lastName}`;
|
||||
const authorName = listing.author && listing.author.attributes
|
||||
? `${listing.author.attributes.profile.firstName} ${listing.author.attributes.profile.lastName}`
|
||||
: '';
|
||||
|
||||
// TODO: these are not yet present in the API data, figure out what
|
||||
// to do with them
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import css from './ListingCardSmall.css';
|
|||
|
||||
const ListingCardSmall = props => {
|
||||
const { listing } = props;
|
||||
const title = listing.attributes.title;
|
||||
const { title = '' } = listing.attributes || {};
|
||||
const id = listing.id.uuid;
|
||||
const slug = encodeURIComponent(title.split(' ').join('-'));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue