Skip to content

Commit

Permalink
Feature/barbecue places (#234)
Browse files Browse the repository at this point in the history
* Show barbecue places on the map

* Use correct icons

* Render info about barbecue places

* Use new hook to fetch data of barbecue places

* Add info text & update translations
  • Loading branch information
juhomakkonen authored Apr 11, 2024
1 parent 150a170 commit 30736be
Show file tree
Hide file tree
Showing 10 changed files with 146 additions and 2 deletions.
46 changes: 46 additions & 0 deletions src/components/MobilityPlatform/BarbecuePlaces/BarbecuePlaces.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/* eslint-disable react-hooks/exhaustive-deps */
import React, { useEffect } from 'react';
import { useMap } from 'react-leaflet';
import { useSelector } from 'react-redux';
import barbecuePlaceIconBw from 'servicemap-ui-turku/assets/icons/contrast/icons-icon_barbecue_place-bw.svg';
import barbecuePlaceIcon from 'servicemap-ui-turku/assets/icons/icons-icon_barbecue_place.svg';
import { useMobilityPlatformContext } from '../../../context/MobilityPlatformContext';
import { useAccessibleMap } from '../../../redux/selectors/settings';
import useMobilityDataFetch from '../utils/useMobilityDataFetch';
import { createIcon, isDataValid, fitToMapBounds } from '../utils/utils';
import MarkerComponent from '../MarkerComponent';
import BarbecuePlacesContent from './components/BarbecuePlacesContent';

const BarbecuePlaces = () => {
const options = {
type_name: 'BarbecuePlace',
};

const { showBarbecuePlaces } = useMobilityPlatformContext();

const map = useMap();

const useContrast = useSelector(useAccessibleMap);

const { icon } = global.L;

const customIcon = icon(createIcon(useContrast ? barbecuePlaceIconBw : barbecuePlaceIcon));

const { data } = useMobilityDataFetch(options, showBarbecuePlaces);
const renderData = isDataValid(showBarbecuePlaces, data);

useEffect(() => {
fitToMapBounds(renderData, data, map);
}, [showBarbecuePlaces, data]);

return (renderData
? data.map(item => (
<MarkerComponent key={item.id} item={item} icon={customIcon}>
<BarbecuePlacesContent item={item} />
</MarkerComponent>
))
: null
);
};

export default BarbecuePlaces;
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import PropTypes from 'prop-types';
import React from 'react';
import { Typography } from '@mui/material';
import { useIntl } from 'react-intl';
import styled from '@emotion/styled';

const BarbecuePlacesContent = ({ item }) => {
const intl = useIntl();
return (
<StyledContainer>
<StyledHeader>
<Typography variant="subtitle2" component="h3">
{intl.formatMessage({ id: 'mobilityPlatform.content.barbecuePlace.title' })}
</Typography>
</StyledHeader>
<StyledText>
<Typography variant="body2" component="p">
{`${item.extra.malli.trim()} (${item.extra.valmistaja})`}
</Typography>
</StyledText>
</StyledContainer>
);
};

const StyledContainer = styled.div(({ theme }) => ({
margin: theme.spacing(1),
}));

const StyledHeader = styled.div(({ theme }) => ({
width: '85%',
borderBottom: '1px solid #000',
paddingBottom: theme.spacing(0.5),
}));

const StyledText = styled.div(({ theme }) => ({
marginTop: theme.spacing(0.5),
}));

BarbecuePlacesContent.propTypes = {
item: PropTypes.shape({
extra: PropTypes.shape({
malli: PropTypes.string,
valmistaja: PropTypes.string,
}),
}),
};

BarbecuePlacesContent.defaultProps = {
item: {},
};

export default BarbecuePlacesContent;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import BarbecuePlacesContent from './BarbecuePlacesContent';

export default BarbecuePlacesContent;
3 changes: 3 additions & 0 deletions src/components/MobilityPlatform/BarbecuePlaces/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import BarbecuePlaces from './BarbecuePlaces';

export default BarbecuePlaces;
3 changes: 3 additions & 0 deletions src/context/MobilityPlatformContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ const MobilityPlatformContextProvider = ({ children }) => {
const [showUnderpasses, setShowUnderpasses] = useState(false);
const [showPublicBenches, setShowPublicBenches] = useState(false);
const [showRoadworks, setShowRoadworks] = useState(false);
const [showBarbecuePlaces, setShowBarbecuePlaces] = useState(false);

const getters = {
openMobilityPlatform,
Expand Down Expand Up @@ -172,6 +173,7 @@ const MobilityPlatformContextProvider = ({ children }) => {
showUnderpasses,
showPublicBenches,
showRoadworks,
showBarbecuePlaces,
};

const setters = {
Expand Down Expand Up @@ -242,6 +244,7 @@ const MobilityPlatformContextProvider = ({ children }) => {
setShowOverpasses,
setShowPublicBenches,
setShowRoadworks,
setShowBarbecuePlaces,
};

const contextValues = { ...getters, ...setters };
Expand Down
3 changes: 3 additions & 0 deletions src/i18n/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,7 @@ const translations = {
'mobilityPlatform.menu.show.railwayStations': 'Railway stations',
'mobilityPlatform.menu.show.airMonitoring': 'Air quality stations',
'mobilityPlatform.menu.show.parkAndRideBikes': 'Park and ride stops for bicycles',
'mobilityPlatform.menu.show.barbecuePlaces': 'Sites for barbequing & making fire',

// Content
'mobilityPlatform.content.general.provider': 'Service provider: {value}',
Expand Down Expand Up @@ -908,6 +909,7 @@ const translations = {
'mobilityPlatform.content.departingTrains.empty': 'No departing trains',
'mobilityPlatform.content.arrivingTrains.empty': 'No incoming trains',
'mobilityPlatform.parkAndRide.content.subtitle': 'Park and ride stop for bicycles',
'mobilityPlatform.content.barbecuePlace.title': 'Site for barbequing or making fire',

// Info text
'mobilityPlatform.info.description.title': 'Route description',
Expand Down Expand Up @@ -968,6 +970,7 @@ const translations = {
'mobilityPlatform.info.airMonitoring.paragraph.3': 'Air quality data for the service map is obtained from the Turku region air protection co-operative group.',
'mobilityPlatform.info.airMonitoring.link': 'For more information visit https://en.ilmatieteenlaitos.fi/air-quality',
'mobilityPlatform.info.parkAndRideBicycles': 'Park-and-ride arrangements provide the opportunity to leave your bicycle parked safely and hop on a bus to continue your journey. The Föli area boasts many park-and-ride sites for bicycles. Park-and-ride parking is free and intended for those using public transport for connections.',
'mobilityPlatform.info.barbecuePlaces': 'The map shows official sites for barbequing or making fire. Making a fire on the land administered by Turku City is allowed only on places designated for making an open flame. Making a fire on any other place than the official campfire and barbeque sites is always forbidden.',

// Bicycle routes
'mobilityPlatform.menu.bicycleRoutes.euroVelo': 'The EuroVelo 10, is the European cycle route that stretches along the Finnish costal line. The distance between Helsinki and Turku has roadside directions for the route.',
Expand Down
3 changes: 3 additions & 0 deletions src/i18n/fi.js
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,7 @@ const translations = {
'mobilityPlatform.menu.show.railwayStations': 'Rautatieasemat',
'mobilityPlatform.menu.show.airMonitoring': 'Ilmanlaadun mittauspisteet',
'mobilityPlatform.menu.show.parkAndRideBikes': 'Liityntäpysäkit pyörille',
'mobilityPlatform.menu.show.barbecuePlaces': 'Grillaus- ja tulentekopaikat',

// Content
'mobilityPlatform.content.general.provider': 'Palveluntarjoaja: {value}',
Expand Down Expand Up @@ -903,6 +904,7 @@ const translations = {
'mobilityPlatform.content.departingTrains.empty': 'Ei lähteviä junia',
'mobilityPlatform.content.arrivingTrains.empty': 'Ei saapuvia junia',
'mobilityPlatform.parkAndRide.content.subtitle': 'Liityntäpysäkki pyörille',
'mobilityPlatform.content.barbecuePlace.title': 'Grillaus- ja tulentekopaikka',

// Info text
'mobilityPlatform.info.description.title': 'Tietoja reitistä',
Expand Down Expand Up @@ -963,6 +965,7 @@ const translations = {
'mobilityPlatform.info.airMonitoring.paragraph.3': 'Palvelukartan ilmanlaatutiedot saadaan Turun seudun ilmansuojelun yhteistyöryhmältä.',
'mobilityPlatform.info.airMonitoring.link': 'Lisätietoja saa osoitteesta https://www.ilmatieteenlaitos.fi/ilmanlaatu',
'mobilityPlatform.info.parkAndRideBicycles': 'Liityntäpysäköinti tarjoaa mahdollisuuden jättää oma pyörä parkkiin ja jatkaa matkaa bussilla. Föli-alueella on useita liityntäpysäköintipaikkoja pyörille. Liityntäpysäköinti on maksutonta ja tarkoitettu vain joukkoliikennettä vaihtoyhteytenä käyttäville.',
'mobilityPlatform.info.barbecuePlaces': 'Kartalla näkyvät Turun viralliset tulenteko- ja grillauspaikat. Turun kaupungin hallinnoimilla mailla tulenteko on sallittu ainoastaan avotulen tekoon tarkoitetuilla paikoilla. Muilla kuin virallisilla nuotio- ja grillauspaikoilla avotulen teko on aina kielletty.',

// Bicycle routes
'mobilityPlatform.menu.bicycleRoutes.euroVelo': 'EuroVelo 10 on eurooppalainen Suomen rannikkoa seuraava polkupyöräreitti. Helsingin ja Turun välisellä matkalla reitti on merkitty opastein.',
Expand Down
5 changes: 4 additions & 1 deletion src/i18n/sv.js
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,7 @@ const translations = {
'mobilityPlatform.menu.show.roadworks': 'Vägarbeten',
'mobilityPlatform.menu.show.railwayStations': 'Järnvägsstationer',
'mobilityPlatform.menu.show.parkAndRideBikes': 'Infartsparkering för cyklar',
'mobilityPlatform.menu.show.barbecuePlaces': 'Grill- och eldningsplatser',

// Content
'mobilityPlatform.content.general.provider': 'Tjänsteleverantör: {value}',
Expand Down Expand Up @@ -912,6 +913,7 @@ const translations = {
'mobilityPlatform.content.departingTrains.empty': 'Inga avgående tåg',
'mobilityPlatform.content.arrivingTrains.empty': 'Inga inkommande tåg',
'mobilityPlatform.parkAndRide.content.subtitle': 'Infartspark for cyklarna',
'mobilityPlatform.content.barbecuePlace.title': 'Grill- och eldningplats',

// Info text
'mobilityPlatform.info.description.title': 'Beskrivning av rutten',
Expand Down Expand Up @@ -959,7 +961,7 @@ const translations = {
'mobilityPlatform.info.parkingMachines': 'Kartan visar de parkeringsautomater som ägs av Åbo stad. Bankkort och kontaktlös betalning används som betalningsmetoder i alla automater. Du kan se mer information om maskinen genom att trycka på ikonen på kartan.',
'mobilityPlatform.info.publicParkingSpaces': 'Allmänna parkeringsplatser visas på kartan. Det finns dock ingen information om deras utnyttjandegrad. Mer detaljerad information om det valda parkeringsområdet kan läsas genom att trycka på området på kartan.',
'mobilityPlatform.info.outdoorGymDevices': 'Åbo stad upprätthåller utomhusgym. De erbjuder ett roligt sätt att träna medan du njuter av den friska luften. På de utomhusgym som finns runt om i staden kan du träna hela kroppen. Overhead-remskivor, benpressar, armhävningar, surf- och promenadutrustning passar alla. Fler utmaningar erbjuds av armhävningsräcket, dip, magplanka och ryggbänk.',
'mobilityPlatform.info.crosswalks': 'Kartan visar placeringen av övergångsställen inne i Åbo stad. Zooma in på kartan för att se övergångsställen.',
'mobilityPlatform.info.crosswalks': 'Kartan visar placeringarna av övergångsställen inne i Åbo stad. Zooma in på kartan för att se övergångsställen.',
'mobilityPlatform.info.short.crosswalks': 'Kartan visar övergångsställen inne i Åbo.',
'mobilityPlatform.info.busStops': 'Kartan visar Åboregionens kollektivtrafiks, Fölis, busshållplatser. Om du kilckar på ikonen kan du se nästa buss som går från hållplatsen. Zooma in på kartan för att se hållplatserna. Datan kommer från gränssnittet som underhålls av Digitransit.',
'mobilityPlatform.info.underAndOverpasses': 'Kartan visar gångtunnlar och gångbroar som ligger i Åbo stadsområdet.',
Expand All @@ -972,6 +974,7 @@ const translations = {
'mobilityPlatform.info.airMonitoring.paragraph.3': 'Luftkvalitetsdata för Servicekartan erhålls från Åboregionens samarbetsgrupp för luftskydd.',
'mobilityPlatform.info.airMonitoring.link': 'För mer information besök: https://sv.ilmatieteenlaitos.fi/luftkvalitet',
'mobilityPlatform.info.parkAndRideBicycles': 'Infartsparkeringen erbjuder möjlighet att lämna din egen cykel på parkeringsplatsen och fortsätta resan med buss. Inom Föli-området finns flera infartsparkeringsplatser för cyklar. Infartsparkeringen är gratis och endast avsedd för dem som fortsätter sin resa med kollektivtrafik.',
'mobilityPlatform.info.barbecuePlaces': 'Kartan visar eldnings- och grillplatser i Åbo. Det är tillåtet att göra upp öppen eld endast vid särskilt avsedda eldningsplatser. Att göra upp eld på andra platser är förbjudet.',

// Bicycle routes
'mobilityPlatform.menu.bicycleRoutes.euroVelo': 'EuroVelo 10 är en europeisk cykelrutt som följer den finländska kusten. Sträckan mellan Helsingfors och Åbo är skyltad.',
Expand Down
2 changes: 2 additions & 0 deletions src/views/MobilityPlatformMapView/MobilityPlatformMapView.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import Roadworks from '../../components/MobilityPlatform/Roadworks';
import RailwayStations from '../../components/MobilityPlatform/RailwayStations';
import AirMonitoring from '../../components/MobilityPlatform/EnvironmentObservations/AirMonitoring';
import ParkAndRideBikes from '../../components/MobilityPlatform/ParkAndRideStops/ParkAndRideBikes';
import BarbecuePlaces from '../../components/MobilityPlatform/BarbecuePlaces';

const MobilityPlatformMapView = ({ mapObject }) => (
<>
Expand Down Expand Up @@ -79,6 +80,7 @@ const MobilityPlatformMapView = ({ mapObject }) => (
<RailwayStations />
<AirMonitoring />
<ParkAndRideBikes />
<BarbecuePlaces />
</>
);

Expand Down
28 changes: 27 additions & 1 deletion src/views/MobilitySettingsView/MobilitySettingsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ const MobilitySettingsView = ({ classes, intl, navigator }) => {
setShowAirMonitoringStations,
showParkAndRideBikes,
setShowParkAndRideBikes,
showBarbecuePlaces,
setShowBarbecuePlaces,
} = useMobilityPlatformContext();

const locale = useSelector(state => state.user.locale);
Expand Down Expand Up @@ -346,7 +348,16 @@ const MobilitySettingsView = ({ classes, intl, navigator }) => {
checkVisibilityValues(showUnderpasses, setOpenWalkSettings);
checkVisibilityValues(showOverpasses, setOpenWalkSettings);
checkVisibilityValues(showPublicBenches, setOpenWalkSettings);
}, [showPublicToilets, showOutdoorGymDevices, showCrossWalks, showUnderpasses, showOverpasses, showPublicBenches]);
checkVisibilityValues(showBarbecuePlaces, setOpenWalkSettings);
}, [
showPublicToilets,
showOutdoorGymDevices,
showCrossWalks,
showUnderpasses,
showOverpasses,
showPublicBenches,
showBarbecuePlaces,
]);

useEffect(() => {
checkVisibilityValues(showTrafficCounter.walking, setOpenWalkSettings);
Expand Down Expand Up @@ -842,6 +853,10 @@ const MobilitySettingsView = ({ classes, intl, navigator }) => {
setShowParkAndRideBikes(current => !current);
};

const barbecuePlacesToggle = () => {
setShowBarbecuePlaces(current => !current);
};

const cultureRouteListToggle = () => {
setOpenCultureRouteList(current => !current);
if (cultureRouteId) {
Expand Down Expand Up @@ -1175,6 +1190,12 @@ const MobilitySettingsView = ({ classes, intl, navigator }) => {
checkedValue: showPublicBenches,
onChangeValue: publicBenchesToggle,
},
{
type: 'barbecuePlaces',
msgId: 'mobilityPlatform.menu.show.barbecuePlaces',
checkedValue: showBarbecuePlaces,
onChangeValue: barbecuePlacesToggle,
},
{
type: 'cultureRoutes',
msgId: 'mobilityPlatform.menu.showCultureRoutes',
Expand Down Expand Up @@ -1594,6 +1615,11 @@ const MobilitySettingsView = ({ classes, intl, navigator }) => {
type: 'publicBenchesInfo',
component: <InfoTextBox infoText="mobilityPlatform.info.publicBenches" />,
},
{
visible: showBarbecuePlaces,
type: 'barbecuePlacesInfo',
component: <InfoTextBox infoText="mobilityPlatform.info.barbecuePlaces" />,
},
{
visible: openMarkedTrailsList,
type: 'markedTrailsListInfo',
Expand Down

0 comments on commit 30736be

Please sign in to comment.