Skip to content

Commit

Permalink
fix: catch missing terrain and latin data
Browse files Browse the repository at this point in the history
  • Loading branch information
friedjoff committed Sep 16, 2020
1 parent a111fcd commit e3e6958
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 23 deletions.
49 changes: 27 additions & 22 deletions src/components/ForestTypeDescription/TerrainTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import useIsMobile from '../../hooks/useIsMobile';
function TerrainTab({ data }) {
const isMobile = useIsMobile();
const { t } = useTranslation();
const [c0, c1] = data.carbonate;
const [r0, r1, r2, r3, r4] = data.reliefType;
const [p0, p1, p2, p3] = data.process;
const [g0, g1, g2, g3, g4, g5, g6] = data.geomorphology;
const [w0, w1, w2, w3] = data.water;

return (
<>
Expand All @@ -27,15 +32,15 @@ function TerrainTab({ data }) {
{t('forestType.carbonate.fine')}
</Table.HeaderCell>
<Table.Cell colSpan="2">
{t(`forestType.frequency.${data.carbonate[0]}`)}
{c0 !== null ? t(`forestType.frequency.${c0}`) : '-'}
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.HeaderCell>
{t('forestType.carbonate.rock')}
</Table.HeaderCell>
<Table.Cell colSpan="2">
{t(`forestType.frequency.${data.carbonate[1]}`)}
{c1 !== null ? t(`forestType.frequency.${c1}`) : '-'}
</Table.Cell>
</Table.Row>
<Table.Row>
Expand All @@ -46,39 +51,39 @@ function TerrainTab({ data }) {
{t('forestType.reliefType.centralSlope')}
</Table.HeaderCell>
<Table.Cell colSpan="2">
{t(`forestType.frequency.${data.reliefType[0]}`)}
{r0 !== null ? t(`forestType.frequency.${r0}`) : '-'}
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.HeaderCell>
{t('forestType.reliefType.hollow')}
</Table.HeaderCell>
<Table.Cell colSpan="2">
{t(`forestType.frequency.${data.reliefType[1]}`)}
{r1 !== null ? t(`forestType.frequency.${r1}`) : '-'}
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.HeaderCell>
{t('forestType.reliefType.dome')}
</Table.HeaderCell>
<Table.Cell colSpan="2">
{t(`forestType.frequency.${data.reliefType[2]}`)}
{r2 !== null ? t(`forestType.frequency.${r2}`) : '-'}
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.HeaderCell>
{t('forestType.reliefType.plateau')}
</Table.HeaderCell>
<Table.Cell colSpan="2">
{t(`forestType.frequency.${data.reliefType[3]}`)}
{r3 !== null ? t(`forestType.frequency.${r3}`) : '-'}
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.HeaderCell>
{t('forestType.reliefType.steep')}
</Table.HeaderCell>
<Table.Cell colSpan="2">
{t(`forestType.frequency.${data.reliefType[4]}`)}
{r4 !== null ? t(`forestType.frequency.${r4}`) : '-'}
</Table.Cell>
</Table.Row>
<Table.Row>
Expand All @@ -89,31 +94,31 @@ function TerrainTab({ data }) {
{t('forestType.process.rockfall')}
</Table.HeaderCell>
<Table.Cell colSpan="2">
{t(`forestType.frequency.${data.process[0]}`)}
{p0 !== null ? t(`forestType.frequency.${p0}`) : '-'}
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.HeaderCell>
{t('forestType.process.avalanche')}
</Table.HeaderCell>
<Table.Cell colSpan="2">
{t(`forestType.frequency.${data.process[1]}`)}
{p1 !== null ? t(`forestType.frequency.${p1}`) : '-'}
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.HeaderCell>
{t('forestType.process.landslide')}
</Table.HeaderCell>
<Table.Cell colSpan="2">
{t(`forestType.frequency.${data.process[2]}`)}
{p2 !== null ? t(`forestType.frequency.${p2}`) : '-'}
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.HeaderCell>
{t('forestType.process.erosion')}
</Table.HeaderCell>
<Table.Cell colSpan="2">
{t(`forestType.frequency.${data.process[3]}`)}
{p3 !== null ? t(`forestType.frequency.${p3}`) : '-'}
</Table.Cell>
</Table.Row>
<Table.Row>
Expand All @@ -124,55 +129,55 @@ function TerrainTab({ data }) {
{t('forestType.geomorphology.blockyRockyStrong')}
</Table.HeaderCell>
<Table.Cell colSpan="2">
{t(`forestType.frequency.${data.geomorphology[1]}`)}
{g1 !== null ? t(`forestType.frequency.${g1}`) : '-'}
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.HeaderCell>
{t('forestType.geomorphology.blockyRockyLittle')}
</Table.HeaderCell>
<Table.Cell colSpan="2">
{t(`forestType.frequency.${data.geomorphology[2]}`)}
{g2 !== null ? t(`forestType.frequency.${g2}`) : '-'}
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.HeaderCell>
{t('forestType.geomorphology.rocksStronglyMoved')}
</Table.HeaderCell>
<Table.Cell colSpan="2">
{t(`forestType.frequency.${data.geomorphology[5]}`)}
{g5 !== null ? t(`forestType.frequency.${g5}`) : '-'}
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.HeaderCell>
{t('forestType.geomorphology.rocksModeratelyMoved')}
</Table.HeaderCell>
<Table.Cell colSpan="2">
{t(`forestType.frequency.${data.geomorphology[4]}`)}
{g4 !== null ? t(`forestType.frequency.${g4}`) : '-'}
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.HeaderCell>
{t('forestType.geomorphology.rocksStabilised')}
</Table.HeaderCell>
<Table.Cell colSpan="2">
{t(`forestType.frequency.${data.geomorphology[6]}`)}
{g6 !== null ? t(`forestType.frequency.${g6}`) : '-'}
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.HeaderCell>
{t('forestType.geomorphology.limestonePavement')}
</Table.HeaderCell>
<Table.Cell colSpan="2">
{t(`forestType.frequency.${data.geomorphology[3]}`)}
{g3 !== null ? t(`forestType.frequency.${g3}`) : '-'}
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.HeaderCell>
{t('forestType.geomorphology.rockBand')}
</Table.HeaderCell>
<Table.Cell colSpan="2">
{t(`forestType.frequency.${data.geomorphology[0]}`)}
{g0 !== null ? t(`forestType.frequency.${g0}`) : '-'}
</Table.Cell>
</Table.Row>
<Table.Row>
Expand All @@ -181,26 +186,26 @@ function TerrainTab({ data }) {
</Table.HeaderCell>
<Table.HeaderCell>{t('forestType.water.stream')}</Table.HeaderCell>
<Table.Cell colSpan="2">
{t(`forestType.frequency.${data.water[0]}`)}
{w0 !== null ? t(`forestType.frequency.${w0}`) : '-'}
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.HeaderCell>{t('forestType.water.small')}</Table.HeaderCell>
<Table.Cell colSpan="2">
{t(`forestType.frequency.${data.water[1]}`)}
{w1 !== null ? t(`forestType.frequency.${w1}`) : '-'}
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.HeaderCell>{t('forestType.water.spring')}</Table.HeaderCell>
<Table.Cell colSpan="2">
{t(`forestType.frequency.${data.water[2]}`)}
{w2 !== null ? t(`forestType.frequency.${w2}`) : '-'}
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.HeaderCell />
<Table.HeaderCell>{t('forestType.water.change')}</Table.HeaderCell>
<Table.Cell colSpan="2">
{t(`forestType.frequency.${data.water[3]}`)}
{w3 !== null ? t(`forestType.frequency.${w3}`) : '-'}
</Table.Cell>
</Table.Row>
</Table.Body>
Expand Down
3 changes: 2 additions & 1 deletion src/components/ForestTypeModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ function ForestTypeModal({ data, setIsForestTypeModalOpen }) {
}
header={
<Modal.Header>
{data.code} - {data[i18n.language]} (<i>{data.la}</i>)
{data.code} - {data[i18n.language]}{' '}
{data.la ? <i>{data.la}</i> : null}
</Modal.Header>
}
onClose={(e) => {
Expand Down

0 comments on commit e3e6958

Please sign in to comment.