diff --git a/next-app/src/app/datasources/page.tsx b/next-app/src/app/datasources/page.tsx index dfd53d5..3afe673 100644 --- a/next-app/src/app/datasources/page.tsx +++ b/next-app/src/app/datasources/page.tsx @@ -93,13 +93,13 @@ export default function DataPage(): ReactElement { } function checkedDataFilter( - tagType: string, + tagType: keyof IDataSourceFilters, tagName: string, boxIndex: number ) { setSelectedFilters((prev) => { const newFilters = { ...prev }; - const key = tagType === "dataType" ? "dataTypes" : "diseaseTypes"; + const key = tagType === "dataTypes" ? "dataTypes" : "diseaseTypes"; if (newFilters[key].includes(tagName)) { newFilters[key] = newFilters[key].filter((item) => item !== tagName); } else { @@ -118,10 +118,8 @@ export default function DataPage(): ReactElement { function applyDataTypeFilter(dataSource: IDataSourcesDC) { return ( selectedFilters.dataTypes.length === 0 || - selectedFilters.dataTypes.every((filter) => - dataSource.data.some( - (tag) => tag.toLowerCase() === filter.toLowerCase() - ) + selectedFilters.dataTypes.some((filter) => + dataSource.data.some((tag) => tag.toLowerCase() === filter.toLowerCase()) ) ); } @@ -129,7 +127,7 @@ export default function DataPage(): ReactElement { function applyDiseaseTypeFilter(dataSource: IDataSourcesDC) { return ( selectedFilters.diseaseTypes.length === 0 || - selectedFilters.diseaseTypes.every((filter) => + selectedFilters.diseaseTypes.some((filter) => dataSource.disease_type.some( (tag) => tag.toLowerCase() === filter.toLowerCase() ) @@ -158,13 +156,11 @@ export default function DataPage(): ReactElement { function sanitizeURL(url: string) { try { const parsedURL = new URL(url); - // Only allow http and https protocols if (parsedURL.protocol !== "http:" && parsedURL.protocol !== "https:") { return "#"; } return parsedURL.toString(); } catch { - // If URL is invalid, return a safe default return "#"; } } @@ -199,6 +195,11 @@ export default function DataPage(): ReactElement {