diff --git a/src/components/data_search/DatasetFilterList.jsx b/src/components/data_search/DatasetFilterList.tsx similarity index 82% rename from src/components/data_search/DatasetFilterList.jsx rename to src/components/data_search/DatasetFilterList.tsx index c8ff3d562..8205a7cfc 100644 --- a/src/components/data_search/DatasetFilterList.jsx +++ b/src/components/data_search/DatasetFilterList.tsx @@ -9,9 +9,13 @@ import Divider from '@mui/material/Divider'; import { Button, TextField, Typography } from '@mui/material'; import { Checkbox } from '@mui/material'; import { flatten, uniq, compact, orderBy } from 'lodash'; -import { getAccessManagementSummary } from '../../types/model'; +import {DatasetTerm, getAccessManagementSummary} from '../../types/model'; -export const FilterItemHeader = (props) => { +interface FilterItemHeaderProps { + title: React.ReactNode; + headerStyle?: React.CSSProperties; +} +export const FilterItemHeader = (props: FilterItemHeaderProps) => { const { title, headerStyle = { fontFamily: 'Montserrat', fontWeight: '600', marginTop: '1em' } } = props; return ( @@ -20,7 +24,16 @@ export const FilterItemHeader = (props) => { ); }; -export const FilterItemList = (props) => { +interface FilterItemListProps { + category: string; + datasets: DatasetTerm[] + filter: string[]; + filterHandler: (category: string, filter: string) => void; + isFiltered: (filter: string, category: string) => boolean; + filterNameFn: (filter: string) => string; + filterDisplayFn?: (filter: string) => React.ReactNode; +} +export const FilterItemList = (props: FilterItemListProps) => { const { category, filter, filterHandler, isFiltered, filterNameFn, filterDisplayFn } = props; return ( @@ -45,9 +58,18 @@ export const FilterItemList = (props) => { ); }; -export const FilterItemRange = (props) => { +interface FilterItemRangeProps { + min: number; + max: number; + minCategory: string; + maxCategory: string; + datasets: DatasetTerm[]; + filterHandler: (category: string, filter: string) => void; +} + +export const FilterItemRange = (props: FilterItemRangeProps) => { const { min, max, minCategory, maxCategory, filterHandler } = props; - const getValue = (val, defaultVal) => isNaN(Number(val)) ? defaultVal : Number(val); + const getValue = (val: any, defaultVal: any) => isNaN(Number(val)) ? defaultVal : Number(val); return ( { ); }; -export const DatasetFilterList = (props) => { +interface DatasetFilterListProps { + datasets: DatasetTerm[]; + filterHandler: (category: string, filter: string) => void; + isFiltered: (filter: string, category: string) => boolean; + onClear: () => void; +} +export const DatasetFilterList = (props: DatasetFilterListProps) => { const { datasets, filterHandler, isFiltered, onClear } = props; const accessManagementFilters = uniq(compact(datasets.map((dataset) => dataset.accessManagement)));