mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-29 05:00:43 +10:00
Add category config, read category from publicData in ListingPage
This commit is contained in:
parent
1924fd484b
commit
187d6ce5e3
3 changed files with 14 additions and 9 deletions
|
|
@ -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 ? (
|
||||
<span>
|
||||
<FormattedMessage id={`ListingPage.category.${customAttributes.category}`} />
|
||||
{categoryLabel(config.custom.categories, publicData.category)}
|
||||
<span className={css.separator}>•</span>
|
||||
</span>
|
||||
) : null;
|
||||
|
|
|
|||
|
|
@ -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' },
|
||||
];
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue