diff --git a/static-site/src/components/ListResources/index.tsx b/static-site/src/components/ListResources/index.tsx index 5632abdca..10a2765b7 100644 --- a/static-site/src/components/ListResources/index.tsx +++ b/static-site/src/components/ListResources/index.tsx @@ -12,7 +12,7 @@ import { ErrorContainer } from "../../pages/404"; import { TooltipWrapper } from "./IndividualResource"; import {ResourceModal, SetModalResourceContext} from "./Modal"; import { CardImgWrapper, CardInner, CardOuter, CardTitle, Showcase } from "../Showcase"; -import { FilterCard, FilterOption, Group, GroupDisplayNames, QuickLink, Resource, ResourceListingInfo } from './types'; +import { FilterCard, FilterOption, Group, QuickLink, Resource, ResourceListingInfo } from './types'; import { HugeSpacer } from "../../layouts/generalComponents"; interface ListResourcesProps extends ListResourcesResponsiveProps { @@ -128,7 +128,9 @@ interface ListResourcesResponsiveProps { /** Should the group name itself be a url? (which we let the server redirect) */ defaultGroupLinks: boolean - groupDisplayNames: GroupDisplayNames + + /** Mapping from group name -> display name */ + groupDisplayNames: Record showcase: FilterCard[] resourceListingCallback: () => Promise; } @@ -255,13 +257,7 @@ const Byline = styled.div` /*** SHOWCASE ***/ - -interface FilterShowcaseTileProps { - card: FilterCard -} - - -const FilterShowcaseTile = ({ card }: FilterShowcaseTileProps) => { +const FilterShowcaseTile = ({ card }: { card: FilterCard }) => { const setSelectedFilterOptions = useContext(SetSelectedFilterOptions); if (!setSelectedFilterOptions) { diff --git a/static-site/src/components/ListResources/types.ts b/static-site/src/components/ListResources/types.ts index 5f0e1cbdc..0b933fab1 100644 --- a/static-site/src/components/ListResources/types.ts +++ b/static-site/src/components/ListResources/types.ts @@ -36,14 +36,7 @@ export interface ResourceDisplayName { export interface ResourceListingInfo { pathPrefix: string - pathVersions: PathVersions -} - -/** - * Mapping from group name -> display name - */ -export interface GroupDisplayNames { - [name: string]: string + pathVersions: Record } export interface UpdateCadence { @@ -62,7 +55,3 @@ export interface QuickLink { display: string groupName?: string } - -export interface PathVersions { - [name: string]: string[] // versions -} diff --git a/static-site/src/components/ListResources/useDataFetch.ts b/static-site/src/components/ListResources/useDataFetch.ts index b5eccdfb3..d8c0e7bb2 100644 --- a/static-site/src/components/ListResources/useDataFetch.ts +++ b/static-site/src/components/ListResources/useDataFetch.ts @@ -1,5 +1,5 @@ import { useState, useEffect } from 'react'; -import { Group, GroupDisplayNames, PathVersions, Resource, ResourceListingInfo } from './types'; +import { Group, Resource, ResourceListingInfo } from './types'; /** @@ -21,7 +21,7 @@ import { Group, GroupDisplayNames, PathVersions, Resource, ResourceListingInfo } export function useDataFetch( versioned: boolean, defaultGroupLinks: boolean, - groupDisplayNames: GroupDisplayNames, + groupDisplayNames: Record, resourceListingCallback: () => Promise, ) : {groups: Group[] | undefined, dataFetchError: boolean} { const [groups, setGroups] = useState(); @@ -51,18 +51,13 @@ export function useDataFetch( } -interface Partitions { - [name: string]: Resource[] -} - - /** - * Groups the provided array of pathVersions into an object with keys + * Groups the provided array mapping from path to dates into an object with keys * representing group names (pathogen names) and values which are arrays of * resource objects. */ -function partitionByPathogen(pathVersions: PathVersions, pathPrefix: string, versioned: boolean) { - return Object.entries(pathVersions).reduce((store: Partitions, [name, dates]) => { +function partitionByPathogen(pathVersions: Record, pathPrefix: string, versioned: boolean) { + return Object.entries(pathVersions).reduce((store: Record, [name, dates]) => { const sortedDates = [...dates].sort(); const nameParts = name.split('/'); @@ -96,7 +91,7 @@ function partitionByPathogen(pathVersions: PathVersions, pathPrefix: string, ver * Turn the provided partitions (an object mapping groupName to an array of resources) * into an array of groups. */ -function groupsFrom(partitions: Partitions, pathPrefix: string, defaultGroupLinks: boolean, groupDisplayNames: GroupDisplayNames) { +function groupsFrom(partitions: Record, pathPrefix: string, defaultGroupLinks: boolean, groupDisplayNames: Record) { return Object.entries(partitions).map(([groupName, resources]) => { const groupInfo: Group = { groupName: groupName,