Refactor DashboardFilterBar to use props exclusively, eliminate dual state source

- DashboardFilterBar now requires all filter props (timeRange, onTimeRangeChange, originFilter, onOriginFilterChange) instead of falling back to context
- Removed useDashboardFilters() hook dependency from DashboardFilterBar, BanTrendChart, and JailDistributionChart
- Updated DashboardPage to explicitly pass all filter values and callbacks from context to components
- Made props required on BanTrendChart and JailDistributionChart
- Updated all tests to reflect new prop requirements
- This eliminates the silent dual-source behavior that could lead to subtle bugs when components are used with different data sources

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-04-23 09:24:16 +02:00
parent 10c534d090
commit 814000fe68
7 changed files with 58 additions and 84 deletions

View File

@@ -73,7 +73,7 @@ const useStyles = makeStyles({
*/
function DashboardPageContent(): React.JSX.Element {
const styles = useStyles();
const { timeRange, originFilter, source } = useDashboardFilters();
const { timeRange, originFilter, source, setTimeRange, setOriginFilter } = useDashboardFilters();
const { countries, countryNames, loading: countryLoading, error: countryError, reload: reloadCountry } =
useDashboardCountryData(timeRange, originFilter, source);
@@ -91,7 +91,12 @@ function DashboardPageContent(): React.JSX.Element {
{/* Global filter bar */}
{/* ------------------------------------------------------------------ */}
<div className={styles.filterRow}>
<DashboardFilterBar />
<DashboardFilterBar
timeRange={timeRange}
onTimeRangeChange={setTimeRange}
originFilter={originFilter}
onOriginFilterChange={setOriginFilter}
/>
</div>
{/* ------------------------------------------------------------------ */}
@@ -104,7 +109,11 @@ function DashboardPageContent(): React.JSX.Element {
</Text>
</div>
<div className={styles.tabContent}>
<BanTrendChart />
<BanTrendChart
timeRange={timeRange}
origin={originFilter}
source={source}
/>
</div>
</div>
@@ -155,7 +164,11 @@ function DashboardPageContent(): React.JSX.Element {
{/* Ban table */}
<div className={styles.tabContent}>
<BanTable />
<BanTable
timeRange={timeRange}
origin={originFilter}
source={source}
/>
</div>
</div>
</div>