diff --git a/src/components/item/ItemCard.tsx b/src/components/item/ItemCard.tsx index dfc7591..64fbc9b 100644 --- a/src/components/item/ItemCard.tsx +++ b/src/components/item/ItemCard.tsx @@ -19,9 +19,9 @@ import { AiFillCheckCircle, AiFillCloseCircle } from "react-icons/ai"; import { FiExternalLink } from "react-icons/fi"; import { ImCopy } from "react-icons/im"; -import { ListItem } from "components/models/list"; +import { APIEntry } from "services/publicapis/list/types"; -type APIDetailsProps = Omit; +type APIDetailsProps = Omit; const APIDetails = ({ Category, HTTPS, Cors, Auth }: APIDetailsProps) => { return ( @@ -49,7 +49,7 @@ const APIDetails = ({ Category, HTTPS, Cors, Auth }: APIDetailsProps) => { }; type ItemCardProps = { - value: ListItem; + value: APIEntry; useAccordion?: boolean; }; diff --git a/src/components/item/ItemContainer.tsx b/src/components/item/ItemContainer.tsx index 9218c6c..c1eb68e 100644 --- a/src/components/item/ItemContainer.tsx +++ b/src/components/item/ItemContainer.tsx @@ -1,11 +1,11 @@ import { Grid } from "@chakra-ui/react"; -import { ListItem } from "components/models/list"; +import { APIEntry } from "services/publicapis/list/types"; import ItemCard from "./ItemCard"; type ItemContainerProps = { - entries: Array; + entries: Array; useAccordion?: boolean; }; @@ -22,7 +22,11 @@ const ItemContainer = ({ entries, useAccordion }: ItemContainerProps) => { gap={8} > {entries.map((entry) => ( - + ))} ); diff --git a/src/components/models/list.ts b/src/components/models/list.ts deleted file mode 100644 index 3542cee..0000000 --- a/src/components/models/list.ts +++ /dev/null @@ -1,16 +0,0 @@ -export type ListItem = { - /** API name */ - API: string; - /** API Authentication type */ - Auth: string; - /** the category of the API */ - Category: string; - /** does the API support CORS */ - Cors: string; - /** API description */ - Description: string; - /** does the API support HTTPS */ - HTTPS: boolean; - /** the API url / link */ - Link: string; -}; diff --git a/src/components/pages/all/index.tsx b/src/components/pages/all/index.tsx index a4942dd..b34dcda 100644 --- a/src/components/pages/all/index.tsx +++ b/src/components/pages/all/index.tsx @@ -1,5 +1,6 @@ import { Box, Button, FormControl, Input, Skeleton } from "@chakra-ui/react"; import chunk from "lodash/chunk"; +import debounce from "lodash/debounce"; import Link from "next/link"; import { ChangeEvent, useCallback, useMemo, useState } from "react"; import { AiOutlineArrowLeft } from "react-icons/ai"; @@ -61,11 +62,15 @@ const APIListPage = ({ fallbackData }: APIListPageProps) => { [currentPage] ); + // eslint-disable-next-line react-hooks/exhaustive-deps const handleChangeKeyword = useCallback( - (event: ChangeEvent) => { + debounce((event: ChangeEvent) => { setKeyword(event.target.value.toLowerCase()); - }, - [] + if (currentPage !== 0) { + setCurrentPage(0); + } + }, 200), + [currentPage] ); const pageNavigationButtonsProps: PageNavigationButtonsProps = useMemo(