From 59e5a818ffb0a943647f1d0bd1b257913a9ad27c Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Tue, 12 Sep 2023 14:28:36 +0530 Subject: [PATCH] remove unintended implementations --- src/CAREUI/misc/PaginatedList.tsx | 3 +- src/Redux/api.tsx | 2 +- src/Utils/request/types.ts | 7 ++++ src/Utils/request/usePaginatedQuery.ts | 54 -------------------------- 4 files changed, 9 insertions(+), 57 deletions(-) delete mode 100644 src/Utils/request/usePaginatedQuery.ts diff --git a/src/CAREUI/misc/PaginatedList.tsx b/src/CAREUI/misc/PaginatedList.tsx index bd81dfe06f2..7bbc4330991 100644 --- a/src/CAREUI/misc/PaginatedList.tsx +++ b/src/CAREUI/misc/PaginatedList.tsx @@ -1,6 +1,5 @@ import { createContext, useContext, useState } from "react"; -import { QueryRoute } from "../../Utils/request/types"; -import { PaginatedResponse } from "../../Utils/request/usePaginatedQuery"; +import { PaginatedResponse, QueryRoute } from "../../Utils/request/types"; import useQuery, { QueryOptions } from "../../Utils/request/useQuery"; import ButtonV2, { CommonButtonProps, diff --git a/src/Redux/api.tsx b/src/Redux/api.tsx index b0ba04b8061..b98a099f439 100644 --- a/src/Redux/api.tsx +++ b/src/Redux/api.tsx @@ -1,5 +1,5 @@ -import { PaginatedResponse } from "../Utils/request/usePaginatedQuery"; import { LocationModel } from "../Components/Facility/models"; +import { PaginatedResponse } from "../Utils/request/types"; /** * A fake function that returns an empty object casted to type T diff --git a/src/Utils/request/types.ts b/src/Utils/request/types.ts index 04da734187d..e7f0f9544a3 100644 --- a/src/Utils/request/types.ts +++ b/src/Utils/request/types.ts @@ -23,3 +23,10 @@ export interface RequestOptions { body?: object; pathParams?: Record; } + +export interface PaginatedResponse { + count: number; + next: string | null; + previous: string | null; + results: TItem[]; +} diff --git a/src/Utils/request/usePaginatedQuery.ts b/src/Utils/request/usePaginatedQuery.ts deleted file mode 100644 index b957705b1ba..00000000000 --- a/src/Utils/request/usePaginatedQuery.ts +++ /dev/null @@ -1,54 +0,0 @@ -export interface PaginatedResponse { - count: number; - next: string | null; - previous: string | null; - results: TItem[]; -} - -// export default function usePaginatedQuery( -// queryKey: keyof typeof routes, -// options: Options = {} -// ) { -// const [offset, setOffset] = useState(0); -// const [limit, setLimit] = useState(options.limit ?? 14); -// const [filters, setFilters] = useState>({}); -// const [items, setItems] = useState([]); - -// const _query = useQuery>(queryKey, { -// query: { -// ...filters, -// offset: `${offset}`, -// limit: `${limit}`, -// }, -// pathParams: options.pathParams, -// onSuccess: ({ results }) => setItems(results), -// }); - -// const { data } = _query; - -// const nextPage = () => { -// if (data?.next) { -// setOffset(offset + limit); -// } -// }; - -// const previousPage = () => { -// if (data?.previous) { -// const newOffset = offset - limit; -// setOffset(newOffset < 0 ? 0 : newOffset); -// } -// }; - -// return { -// ..._query, -// total: data?.count ?? null, -// items, -// nextPage, -// previousPage, -// setFilters, -// offset, -// setOffset, -// limit, -// setLimit, -// }; -// }