Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | import React, { FC } from 'react';
import { useTranslation } from 'react-i18next';
const styles = require('./ProductDescription.module.css');
export const ProductDescription: FC<{
description?: string;
attrs?: { key: string, value: string }[]
}> = ({ description, attrs, children }) => {
const { t } = useTranslation();
return <>
{description ? <div
className={styles.Description}
dangerouslySetInnerHTML={{ __html: description }}
/> : null}
{attrs && attrs.length ? <div className={styles.DescriptionAttributes}>
{['openingHours', 'address', 'distance', 'hint', 'baggageHint'].map((key, index) => {
const item = attrs.find(attr => attr.key === key);
return item ? (
<p className={styles.DescriptionProp} key={index}>
<span className={styles.DescriptionPropName}>{t(`product.attributes.${key}`)}</span><br />
<span className={styles.DescriptionPropValue}>{item.value}</span>
</p>
) : null
})}
</div> : null}
{children}
</>
};
|