Skip to content

Commit

Permalink
climbing: Add climbing restriction
Browse files Browse the repository at this point in the history
  • Loading branch information
jvaclavik committed Jul 7, 2024
1 parent e8a1ea0 commit 61a0e5d
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/components/FeaturePanel/Climbing/ClimbingPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { SuggestEdit } from '../SuggestEdit';
import { PanelContent, PanelSidePadding } from '../../utils/PanelHelpers';
import { FeatureHeading } from '../FeatureHeading';
import { ParentLink } from '../ParentLink';
import { ClimbingRestriction } from './ClimbingRestriction';

export const ClimbingPanel = ({ footer, showTagsTable }) => {
const { feature } = useFeatureContext();
Expand All @@ -27,6 +28,7 @@ export const ClimbingPanel = ({ footer, showTagsTable }) => {
<PanelSidePadding>
<FeatureHeading />
<ParentLink />
<ClimbingRestriction />
</PanelSidePadding>
<ImageSlider />
<OsmError />
Expand Down
25 changes: 25 additions & 0 deletions src/components/FeaturePanel/Climbing/ClimbingRestriction.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from 'react';
import { Alert, AlertTitle } from '@mui/material';
import { useFeatureContext } from '../../utils/FeatureContext';
import { t } from '../../../services/intl';

export const ClimbingRestriction = () => {
const { feature } = useFeatureContext();

const restriction = feature.tags['climbing:restriction'];
const restrictionTimeDescription =
feature.tags['climbing:restriction:time_description'];
if (!feature.tags.climbing || (!restriction && !restrictionTimeDescription)) {
return null;
}

return (
<Alert
severity={restriction === 'yes' ? 'error' : 'warning'}
sx={{ mt: 2 }}
>
<AlertTitle>{t('featurepanel.climbing_restriction')}</AlertTitle>
{restrictionTimeDescription}
</Alert>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const osmToClimbingRoutes = (feature: Feature): Array<ClimbingRoute> => {
difficulty: getDifficulty(route.tags),
paths,
photoToKeyMap,
author: route.tags.author,
feature: route,
};
});
Expand Down
1 change: 1 addition & 0 deletions src/components/FeaturePanel/Climbing/utils/emptyRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ClimbingRoute } from '../types';
export const emptyRoute: ClimbingRoute = {
id: '',
name: '',
author: '',
difficulty: { grade: '', gradeSystem: 'uiaa' },
length: '',
paths: {},
Expand Down
3 changes: 3 additions & 0 deletions src/components/FeaturePanel/FeaturePanelInner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { ImageSlider } from './ImagePane/ImageSlider';
import { SuggestEdit } from './SuggestEdit';
import { FeatureOpenPlaceGuideLink } from './FeatureOpenPlaceGuideLink';
import { CragsInArea } from './CragsInArea';
import { ClimbingRestriction } from './Climbing/ClimbingRestriction';

const Flex = styled.div`
flex: 1;
Expand Down Expand Up @@ -100,6 +101,8 @@ export const FeaturePanelInner = () => {
<FeatureHeading />
<ParentLink />

<ClimbingRestriction />

<OsmError />
<CragsInArea />
</PanelSidePadding>
Expand Down
8 changes: 4 additions & 4 deletions src/components/FeaturePanel/OsmError.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,31 @@ export const OsmError = () => {

if (code === 'unknown') {
return (
<Alert variant="outlined" severity="warning">
<Alert variant="outlined" severity="warning" sx={{ mb: 2 }}>
{t('featurepanel.error_unknown')}
</Alert>
);
}

if (code === 'network') {
return (
<Alert variant="outlined" severity="warning">
<Alert variant="outlined" severity="warning" sx={{ mb: 2 }}>
{t('featurepanel.error_network')}
</Alert>
);
}

if (code) {
return (
<Alert variant="outlined" severity="warning">
<Alert variant="outlined" severity="warning" sx={{ mb: 2 }}>
{t('featurepanel.error', { code })}
</Alert>
);
}

if (Object.keys(feature.tags).length === 0 && !feature.point) {
return (
<Alert variant="outlined" severity="info">
<Alert variant="outlined" severity="info" sx={{ mb: 2 }}>
{t('featurepanel.info_no_tags')}
</Alert>
);
Expand Down
1 change: 1 addition & 0 deletions src/locales/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export default {
'featurepanel.uncertain_image': 'Je zobrazena nejbližší fotka uliční úrovně. Může ukazovat jiný objekt.',
'featurepanel.inline_edit_title': 'Upravit',
'featurepanel.objects_around': 'Objekty v okolí',
'featurepanel.climbing_restriction': 'Lezecké omezení',

'opening_hours.open': 'Otevřeno: __todayTime__',
'opening_hours.now_closed_but_today': 'Nyní zavřeno, dnes: __todayTime__',
Expand Down
1 change: 1 addition & 0 deletions src/locales/vocabulary.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export default {
'featurepanel.inline_edit_title': 'Edit',
'featurepanel.objects_around': 'Nearby objects',
'featurepanel.more_in_openplaceguide': 'More information on __instanceName__',
'featurepanel.climbing_restriction': 'Climbing restriction',

'opening_hours.open': 'Open: __todayTime__',
'opening_hours.now_closed_but_today': 'Closed now - Open __todayTime__',
Expand Down

0 comments on commit 61a0e5d

Please sign in to comment.