From 85d08d45f0a62595891987f29c24f9902f1af123 Mon Sep 17 00:00:00 2001 From: jeremy-babylonchain Date: Thu, 9 Jan 2025 13:01:37 +0700 Subject: [PATCH 1/5] improve fp search to allow search to not scope to showing tab --- .../FinalityProviderFilter.tsx | 5 +- .../FinalityProviderSearch.tsx | 23 +++++++- src/app/state/FinalityProviderState.tsx | 58 +++++++++++-------- 3 files changed, 58 insertions(+), 28 deletions(-) diff --git a/src/app/components/Staking/FinalityProviders/FinalityProviderFilter.tsx b/src/app/components/Staking/FinalityProviders/FinalityProviderFilter.tsx index ed4abb4c..c3d8e2ff 100644 --- a/src/app/components/Staking/FinalityProviders/FinalityProviderFilter.tsx +++ b/src/app/components/Staking/FinalityProviders/FinalityProviderFilter.tsx @@ -8,14 +8,15 @@ const options = [ ]; export const FinalityProviderFilter = () => { - const { filterValue, handleFilter } = useFinalityProviderState(); + const { filterValue, handleFilter, searchValue } = useFinalityProviderState(); return ( handleFilter("status", value.toString())} placeholder="Select Status" - value={searchValue ? "" : filterValue} - disabled={Boolean(searchValue)} + value={filter.search ? "" : filter.status} + disabled={Boolean(filter.search)} renderSelectedOption={(option) => `Showing ${option.label}`} /> ); diff --git a/src/app/components/Staking/FinalityProviders/FinalityProviderSearch.tsx b/src/app/components/Staking/FinalityProviders/FinalityProviderSearch.tsx index c5e678eb..162f3967 100644 --- a/src/app/components/Staking/FinalityProviders/FinalityProviderSearch.tsx +++ b/src/app/components/Staking/FinalityProviders/FinalityProviderSearch.tsx @@ -7,20 +7,20 @@ import cancelCircle from "@/app/assets/cancel-circle.svg"; import { useFinalityProviderState } from "@/app/state/FinalityProviderState"; export const FinalityProviderSearch = () => { - const { handleSearch, searchValue } = useFinalityProviderState(); + const { filter, handleFilter } = useFinalityProviderState(); const onSearchChange = useCallback( (e: React.ChangeEvent) => { - handleSearch(e.target.value); + handleFilter("search", e.target.value); }, - [handleSearch], + [handleFilter], ); const onClearSearch = useCallback(() => { - handleSearch(""); - }, [handleSearch]); + handleFilter("search", ""); + }, [handleFilter]); - const searchSuffix = searchValue ? ( + const searchSuffix = filter.search ? (