Skip to content

Commit

Permalink
🔧 Some minor tweaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasGilg committed Dec 12, 2024
1 parent e3cceac commit 3d25159
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
19 changes: 16 additions & 3 deletions frontend/src/components/Sidebar/SidebarTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import Box from '@mui/material/Box';
import {useTranslation} from 'react-i18next';
import React, {useCallback, useContext, useMemo, useRef, useState} from 'react';
import React, {useCallback, useContext, useEffect, useMemo, useRef, useState} from 'react';
import {Grid, Typography} from '@mui/material';
import TabContext from '@mui/lab/TabContext';
import TabPanel from '@mui/lab/TabPanel';
Expand All @@ -27,6 +27,7 @@ import legendPresets from '../../../assets/heatmap_legend_presets.json?url';
import {GeoJSON, GeoJsonProperties} from 'geojson';
import TripChainView from '../TripChainView';
import StatisticsDashboard from './StatisicsComponent/StatisticsDashboard';
import {selectDistrict} from '../../store/DataSelectionSlice';

export default function SidebarTabs(): JSX.Element {
const {t, i18n} = useTranslation('global');
Expand Down Expand Up @@ -126,6 +127,18 @@ export default function SidebarTabs(): JSX.Element {
[t]
);

// Set selected area in store
useEffect(() => {
dispatch(
selectDistrict({
ags: String(selectedArea?.['RS']),
name: String(selectedArea?.['GEN']),
type: String(selectedArea?.['BEZ']),
})
);
// This effect should only run when the selectedArea changes
}, [selectedArea, dispatch]);

const localization = useMemo(() => {
return {
formatNumber: formatNumber,
Expand Down Expand Up @@ -173,7 +186,7 @@ export default function SidebarTabs(): JSX.Element {
height: '100%',
}}
>
<Box id='sidebar-map-search-bar-wrapper' sx={{width: '100%'}}>
<Box id='sidebar-map-search-bar-wrapper' sx={{width: '95%'}}>
<SearchBar
data={searchBarData}
sortProperty={'GEN'}
Expand All @@ -195,7 +208,7 @@ export default function SidebarTabs(): JSX.Element {
valueEqualProperty='RS'
/>
</Box>
<Box id='sidebar-map-wrapper' sx={{width: '100%'}}>
<Box id='sidebar-map-wrapper' sx={{width: '95%'}}>
<LoadingContainer show={areMapValuesFetching || longLoad} overlayColor={theme.palette.background.default}>
<HeatMap
selectedArea={selectedArea}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
selectDestinationTypes,
selectInfectionStates, selectOriginTypes,
selectTransportationModes,
selectTripDuration,
} from 'store/PandemosFilterSlice';
import {KeyInfo} from 'types/pandemos';
import RestartAltIcon from '@mui/icons-material/RestartAlt';
Expand Down Expand Up @@ -77,7 +76,7 @@ export default function StatisticsDashboard(props: any): JSX.Element {
.keyAccessor((d: any) => d.key)
.colors(d3.scaleOrdinal(d3.schemeBlues[9].slice().reverse()))
.on('filtered', function (_chart: any) {
const selectedFilters = _chart.filters()//.map((d: any) => Object.values(KeyInfo.infection_state).findIndex((e: any) => e.icon === d));
const selectedFilters = _chart.filters()
dispatch(
selectInfectionStates({
infectionStates: selectedFilters,
Expand Down

0 comments on commit 3d25159

Please sign in to comment.