fix: reload TrainingTypeDistribution on quality filter change (Issue #31)
All checks were successful
Deploy Development / deploy (push) Successful in 44s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s

The component was loading data from backend (which uses global filter)
but useEffect dependency didn't include quality_filter_level, so it
didn't reload when user changed the filter in Settings.

Added useProfile() context and activeProfile.quality_filter_level
to dependency array.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Lars 2026-03-24 06:30:39 +01:00
parent 04306a7fef
commit e3819327a9

View File

@ -1,6 +1,7 @@
import { useState, useEffect } from 'react' import { useState, useEffect } from 'react'
import { PieChart, Pie, Cell, ResponsiveContainer, Legend, Tooltip } from 'recharts' import { PieChart, Pie, Cell, ResponsiveContainer, Legend, Tooltip } from 'recharts'
import { api } from '../utils/api' import { api } from '../utils/api'
import { useProfile } from '../context/ProfileContext'
/** /**
* TrainingTypeDistribution - Pie chart showing activity distribution by type * TrainingTypeDistribution - Pie chart showing activity distribution by type
@ -8,6 +9,7 @@ import { api } from '../utils/api'
* @param {number} days - Number of days to analyze (default: 28) * @param {number} days - Number of days to analyze (default: 28)
*/ */
export default function TrainingTypeDistribution({ days = 28 }) { export default function TrainingTypeDistribution({ days = 28 }) {
const { activeProfile } = useProfile() // Issue #31: Trigger reload on quality filter change
const [data, setData] = useState([]) const [data, setData] = useState([])
const [categories, setCategories] = useState({}) const [categories, setCategories] = useState({})
const [loading, setLoading] = useState(true) const [loading, setLoading] = useState(true)
@ -41,7 +43,7 @@ export default function TrainingTypeDistribution({ days = 28 }) {
console.error('Failed to load training type distribution:', err) console.error('Failed to load training type distribution:', err)
setLoading(false) setLoading(false)
}) })
}, [days]) }, [days, activeProfile?.quality_filter_level]) // Issue #31: Reload when quality filter changes
if (loading) { if (loading) {
return ( return (