Skip to content

Commit

Permalink
[DEV-10046a] Remove a file
Browse files Browse the repository at this point in the history
  • Loading branch information
Atash3000 committed Jan 8, 2025
1 parent ea8ba3d commit 388eec6
Showing 1 changed file with 1 addition and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { hasDashboardApplyBehavior } from '../../helpers/hasDashboardApplyBehavi
import * as apiFilterHelpers from '../../helpers/apiFilterHelpers'
import { applyQueuedActive } from '@cdc/core/components/Filters/helpers/applyQueuedActive'
import './dashboardfilter.styles.css'
import { updateChildFilters } from '../../helpers/updateChildFilters'

type SubOptions = { subOptions?: Record<'value' | 'text', string>[] }

Expand All @@ -34,40 +35,6 @@ type DashboardFiltersProps = {
setAPILoading: (loading: boolean) => void
}

const updateChildFilters = (newSharedFilters, state) => {
const dataSetArr = Object.values(state.data).flat()

// Find all child filters and their parent filter
const childFilterIndexes = newSharedFilters
.map((filter, index) => (filter.parents ? index : -1)) // Get indexes of all child filters
.filter(index => index !== -1) // Filter out invalid indexes

if (childFilterIndexes.length === 0) return newSharedFilters // No child filters found

// Update child filters
let updatedFilters = [...newSharedFilters]
childFilterIndexes.forEach(childIndex => {
const childFilter = newSharedFilters[childIndex]
const parentFilter = newSharedFilters.find(filter => String(childFilter.parents) === String(filter.key))

if (parentFilter) {
// Get active values for the parent filter
const parentActiveValuesArr = dataSetArr.filter(d => d[parentFilter.columnName] === parentFilter.active)
const uniqChildValues = _.uniq(parentActiveValuesArr.map(d => d[childFilter.columnName]).filter(Boolean))

// Update the child filter if active values exist
if (uniqChildValues.length > 0) {
updatedFilters[childIndex] = {
...childFilter,
values: uniqChildValues
}
}
}
})

return updatedFilters
}

const DashboardFiltersWrapper: React.FC<DashboardFiltersProps> = ({
apiFilterDropdowns,
visualizationConfig,
Expand Down

0 comments on commit 388eec6

Please sign in to comment.