Skip to content

Commit

Permalink
Add major districts to area view
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkoisa authored and mhieta committed Aug 30, 2021
1 parent 2588ed4 commit e2027e1
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/i18n/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ const translations = {
'area.localAddress.postCode': 'Postal code area: {area}',
'area.geographicalServices.neighborhood': 'Services of the neighbourhood ({length})',
'area.geographicalServices.postcode_area': 'Services of the postal code area ({length})',
'area.geographicalServices.major_district': 'Services of the major district ({length})',
'area.neighborhood.title': 'Choose neighbourhood',
'area.postcode_area.title': 'Choose postal code',
'area.major_district.title': 'Choose major district',
'area.noSelection': 'Choose area from the Choice of Area tab',
'area.noUnits': 'There are no service points in your chosen area',
'area.popupLink': 'Show the details for the area (new tab)',
Expand All @@ -78,6 +80,7 @@ const translations = {
'area.list.neighborhood': 'Neighborhood',
'area.list.postcode': 'Postcode',
'area.list.postcode_area': 'Postcode area',
'area.list.major_district': 'Major district',
'area.list.rescue_area': 'Civil defence district',
'area.list.rescue_district': 'Civil defence section',
'area.list.rescue_sub_district': 'Civil defence subsection',
Expand All @@ -93,6 +96,7 @@ const translations = {
'area.list.resident_parking_zone': 'Residential parking areas',
'area.list.neighborhood.plural': 'Neighborhoods',
'area.list.postcode_area.plural': 'Postcode areas',
'area.list.major_district.plural': 'Major districts',
'area.list.rescue_area.plural': 'Civil defence districts',
'area.list.rescue_district.plural': 'Civil defence sections',
'area.list.rescue_sub_district.plural': 'Civil defence subsections',
Expand Down
4 changes: 4 additions & 0 deletions src/i18n/fi.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ const translations = {
'area.localAddress.postCode': 'Postinumero: {area}',
'area.geographicalServices.neighborhood': 'Kaupunginosan palvelut ({length})',
'area.geographicalServices.postcode_area': 'Postinumeroalueen palvelut ({length})',
'area.geographicalServices.major_district': 'Suurpiirin palvelut ({length})',
'area.neighborhood.title': 'Valitse kaupunginosa',
'area.postcode_area.title': 'Valitse postinumero',
'area.major_district.title': 'Valitse suurpiiri',
'area.noSelection': 'Valitse alue Alueen Valinta -välilehdeltä',
'area.noUnits': 'Valitsemallasi alueella ei ole toimipisteitä',
'area.popupLink': 'Näytä alueen tiedot (uusi välilehti)',
Expand All @@ -78,6 +80,7 @@ const translations = {
'area.list.neighborhood': 'Kaupunginosa',
'area.list.postcode': 'Postinumero',
'area.list.postcode_area': 'Postinumeroalue',
'area.list.major_district': 'Suurpiiri',
'area.list.rescue_area': 'Suojelupiiri',
'area.list.rescue_district': 'Suojelulohko',
'area.list.rescue_sub_district': 'Suojelualalohko',
Expand All @@ -93,6 +96,7 @@ const translations = {
'area.list.resident_parking_zone': 'Asukaspysäköintialueet',
'area.list.neighborhood.plural': 'Kaupunginosat',
'area.list.postcode_area.plural': 'Postinumeroalueet',
'area.list.major_district.plural': 'Suurpiirit',
'area.list.rescue_area.plural': 'Suojelupiirit',
'area.list.rescue_district.plural': 'Suojelulohkot',
'area.list.rescue_sub_district.plural': 'Suojelualalohkot',
Expand Down
4 changes: 4 additions & 0 deletions src/i18n/sv.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ const translations = {
'area.localAddress.postCode': 'Postnummer: {area}',
'area.geographicalServices.neighborhood': 'Tjänster i stadsdelen ({length})',
'area.geographicalServices.postcode_area': 'Tjänster i postnummerområdet ({length})',
'area.geographicalServices.major_district': 'Tjänster i stordistriktet ({length})',
'area.neighborhood.title': 'Välj stadsdel',
'area.postcode_area.title': 'Välj postnummer',
'area.major_district.title': 'Välj stordistrikt',
'area.noSelection': 'Väl område under fliken Val av område',
'area.noUnits': 'Det finns inga verksamhetsställen i ditt valda område',
'area.popupLink': 'Visa uppgifterna för området (ny flik)',
Expand All @@ -78,6 +80,7 @@ const translations = {
'area.list.neighborhood': 'Stadsdel',
'area.list.postcode': 'Postnummer',
'area.list.postcode_area': 'Postnummerområde',
'area.list.major_district': 'Stordistrikt',
'area.list.rescue_area': 'Skyddsdistrikt',
'area.list.rescue_district': 'Skyddsavsnitt',
'area.list.rescue_sub_district': 'Skyddsunderavsnitt',
Expand All @@ -93,6 +96,7 @@ const translations = {
'area.list.resident_parking_zone': 'Invånarparkeringsområden',
'area.list.neighborhood.plural': 'Stadsdelar',
'area.list.postcode_area.plural': 'Postnummerområden',
'area.list.major_district.plural': 'Stordistrikten',
'area.list.rescue_area.plural': 'Skyddsdistrikten',
'area.list.rescue_district.plural': 'Skyddsavsnitten',
'area.list.rescue_sub_district.plural': 'Skyddsunderavsnitten',
Expand Down
2 changes: 2 additions & 0 deletions src/views/AddressView/utils/fetchAdministrativeDistricts.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { districtFetch } from '../../../utils/fetch';
const SORTED_DIVISIONS = [
'postcode_area',
'neighborhood',
'major_district',
'health_station_district',
'maternity_clinic_district',
'income_support_district',
Expand All @@ -23,6 +24,7 @@ const fetchAdministrativeDistricts = async (lnglat) => {
const districts = [
'postcode_area',
'neighborhood',
'major_district',
'health_station_district',
'maternity_clinic_district',
'lower_comprehensive_school_district_fi',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { getFilteredSubdistrictServices } from '../../../../redux/selectors/dist
import GeographicalDistrictList from '../GeographicalDistrictList';
import GeographicalUnitList from '../GeographicalUnitList';
import useLocaleText from '../../../../utils/useLocaleText';
import { geographicalDistricts } from '../../utils/districtDataHelper';


const GeographicalTab = ({
Expand All @@ -37,7 +38,7 @@ const GeographicalTab = ({
const getLocaleText = useLocaleText();

const [openCategory, setOpenCategory] = useState(
useSelector(state => state.districts.openItems).find(item => item === 'neighborhood' || item === 'postcode_area') || [],
useSelector(state => state.districts.openItems).find(item => geographicalDistricts.includes(item)) || [],
);


Expand Down Expand Up @@ -83,7 +84,7 @@ const GeographicalTab = ({
};

useEffect(() => {
if (!selectedDistrictType || (selectedDistrictType !== 'neighborhood' && selectedDistrictType !== 'postcode_area')) {
if (!selectedDistrictType || geographicalDistricts.includes(selectedDistrictType)) {
dispatch(setSelectedSubdistricts([]));
dispatch(setSelectedDistrictServices([]));
setOpenCategory(null);
Expand Down Expand Up @@ -117,7 +118,7 @@ const GeographicalTab = ({


const render = () => {
const districtItems = districtData.filter(obj => obj.id === 'neighborhood' || obj.id === 'postcode_area');
const districtItems = districtData.filter(obj => geographicalDistricts.includes(obj.id));
return (
<>
{localAddressData?.address && localAddressData.districts?.length && (
Expand Down
1 change: 1 addition & 0 deletions src/views/AreaView/utils/districtDataHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const dataStructure = [ // Categorized district data structure
districts: [
'neighborhood',
'postcode_area',
'major_district',
],
},
{
Expand Down

0 comments on commit e2027e1

Please sign in to comment.