From 18634386b5fc542c3e060b13fb049e29d7c50b72 Mon Sep 17 00:00:00 2001 From: Lukas <lukas.budginas@gmail.com> Date: Fri, 24 Jan 2025 15:33:40 +0200 Subject: [PATCH] Update search ranges imports --- .../tabs/operations/OperationsTabContent.tsx | 1 - .../home/searches/BalanceHistorySearch.tsx | 10 ++++++---- .../home/searches/CommentPermlinkSearch.tsx | 16 +++------------- 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/components/account/tabs/operations/OperationsTabContent.tsx b/components/account/tabs/operations/OperationsTabContent.tsx index b7aa495d..c2007fa1 100644 --- a/components/account/tabs/operations/OperationsTabContent.tsx +++ b/components/account/tabs/operations/OperationsTabContent.tsx @@ -12,7 +12,6 @@ import { Card, CardHeader, CardTitle, CardContent } from "@/components/ui/card"; import { TabsContent } from "@/components/ui/tabs"; import OperationsTable from "@/components/OperationsTable"; import useURLParams from "@/hooks/common/useURLParams"; -import useSearchRanges from "@/hooks/common/useSearchRanges"; import { defaultSearchParams } from "@/pages/[accountName]"; import useOperationsFormatter from "@/hooks/common/useOperationsFormatter"; import { diff --git a/components/home/searches/BalanceHistorySearch.tsx b/components/home/searches/BalanceHistorySearch.tsx index de75d003..441edaa3 100644 --- a/components/home/searches/BalanceHistorySearch.tsx +++ b/components/home/searches/BalanceHistorySearch.tsx @@ -4,10 +4,10 @@ import SearchRanges from "@/components/searchRanges/SearchRanges"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; -import useSearchRanges from "@/hooks/common/useSearchRanges"; import useURLParams from "@/hooks/common/useURLParams"; import OperationTypesDialog from "@/components/OperationTypesDialog"; import useAccountOperationTypes from "@/hooks/api/accountPage/useAccountOperationTypes"; +import { useSearchesContext } from "@/contexts/SearchesContext"; interface AccountSearchParams { accountName?: string | undefined; @@ -43,6 +43,7 @@ const BalanceHistorySearch = () => { const [coinType, setCoinType] = useState<string>("HIVE"); // State to store the selected coin name const COIN_TYPES = ["HIVE", "VESTS", "HBD"]; const router = useRouter(); + const { searchRanges } = useSearchesContext(); const accountNameFromRoute = (router.query.accountName as string)?.slice(1); const { accountOperationTypes } = useAccountOperationTypes(accountNameFromRoute); @@ -92,8 +93,6 @@ const BalanceHistorySearch = () => { const [initialSearch, setInitialSearch] = useState<boolean>(false); const [filters, setFilters] = useState<boolean[]>([]); - const searchRanges = useSearchRanges(); - const handleSearch = async (resetPage?: boolean) => { if ( !initialSearch && @@ -200,7 +199,10 @@ const BalanceHistorySearch = () => { className="w-[180px] border border-gray-300 p-2 rounded bg-theme dark:bg-theme" > {COIN_TYPES.map((type) => ( - <option key={type} value={type}> + <option + key={type} + value={type} + > {type} </option> ))} diff --git a/components/home/searches/CommentPermlinkSearch.tsx b/components/home/searches/CommentPermlinkSearch.tsx index 977f612e..50680046 100644 --- a/components/home/searches/CommentPermlinkSearch.tsx +++ b/components/home/searches/CommentPermlinkSearch.tsx @@ -1,4 +1,4 @@ -import { useState, ChangeEvent, useEffect } from "react"; +import { useState, ChangeEvent } from "react"; import { Loader2 } from "lucide-react"; import Explorer from "@/types/Explorer"; import { trimAccountName } from "@/utils/StringUtils"; @@ -10,7 +10,6 @@ import { useSearchesContext } from "@/contexts/SearchesContext"; import usePermlinkSearch from "@/hooks/api/common/usePermlinkSearch"; import { startCommentPermlinkSearch } from "./utils/commentPermlinkSearchHelpers"; import PostTypeSelector from "./PostTypeSelector"; -import useSearchRanges from "@/hooks/common/useSearchRanges"; const CommentsPermlinkSearch = () => { const { @@ -19,17 +18,16 @@ const CommentsPermlinkSearch = () => { setCommentPaginationPage, setCommentType, setLastSearchKey, + searchRanges, } = useSearchesContext(); - const searchRanges = useSearchRanges("lastTime"); - const { permlinkSearchDataLoading } = usePermlinkSearch(permlinkSearchProps); const [accountName, setAccountName] = useState<string>(""); const [localCommentType, setLocalCommentType] = useState<Explorer.CommentType>("post"); - const { getRangesValues, setLastTimeUnitValue } = searchRanges; + const { getRangesValues } = searchRanges; const onButtonClick = async () => { if (accountName !== "") { @@ -66,14 +64,6 @@ const CommentsPermlinkSearch = () => { } }; - // Set inital permlink search range as last 30 days - useEffect(() => { - setLastTimeUnitValue(30); - return () => { - setLastTimeUnitValue(undefined); - }; - }, []); - const handleChangeCommentType = (e: ChangeEvent<HTMLSelectElement>) => { const { target: { value }, -- GitLab