diff --git a/src/containers/ListingPage/ListingPage.js b/src/containers/ListingPage/ListingPage.js index 61218e44..3ae299d6 100644 --- a/src/containers/ListingPage/ListingPage.js +++ b/src/containers/ListingPage/ListingPage.js @@ -145,6 +145,11 @@ const gotoListingTab = (history, listing) => { ); }; +const categoryLabel = (categories, key) => { + const cat = categories.find(c => c.key === key); + return cat ? cat.label : key; +}; + // TODO: price unit (per x), custom fields, contact, reviews // N.B. All the presentational content needs to be extracted to their own components export class ListingPageComponent extends Component { @@ -261,13 +266,10 @@ export class ListingPageComponent extends Component { publicData, } = currentListing.attributes; - const { customAttributes } = currentListing.attributes; - const hasCategoryConfig = config.customAttributes && config.customAttributes.category; - const hasCategoryAttribute = customAttributes && customAttributes.category; const category = - hasCategoryConfig && hasCategoryAttribute ? ( + publicData && publicData.category ? ( - + {categoryLabel(config.custom.categories, publicData.category)} ) : null; diff --git a/src/marketplace-custom-config.js b/src/marketplace-custom-config.js index 05f8dba0..320420df 100644 --- a/src/marketplace-custom-config.js +++ b/src/marketplace-custom-config.js @@ -36,3 +36,10 @@ export const amenities = [ label: 'Own food allowed', }, ]; + +export const categories = [ + { key: 'road', label: 'Road' }, + { key: 'mountain', label: 'Mountain' }, + { key: 'track', label: 'Track' }, + { key: 'other', label: 'Other' }, +]; diff --git a/src/translations/en.json b/src/translations/en.json index 31325e87..aba440e7 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -255,10 +255,6 @@ "ListingPage.bookingHelp": "Start by choosing your dates.", "ListingPage.bookingHelpClosedListing": "Sorry, this listing has been closed.", "ListingPage.bookingTitle": "Book {title}", - "ListingPage.category.mountain": "Mountain", - "ListingPage.category.other": "Other", - "ListingPage.category.road": "Road", - "ListingPage.category.track": "Track", "ListingPage.closedListing": "This listing has been closed and can't be booked.", "ListingPage.closedListingButtonText": "Sorry, this listing has been closed.", "ListingPage.contactUser": "Contact",