@@ -6,9 +6,9 @@ import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
66import { SafeTx } from "@/core/safe-tx" ;
77import { useCurrentTransactions } from "@/hooks/use-current-transactions" ;
88import { useSafeParams } from "@/hooks/use-safe-params" ;
9- import { useRouter , useSearchParams } from "next/navigation" ;
10- import { useEffect , useMemo , useState } from "react" ;
9+ import { useMemo } from "react" ;
1110import { Address } from "viem" ;
11+ import useTabs , { TabType } from "../../hooks/use-tabs" ;
1212import { getReportRef } from "../../utils/get-report" ;
1313import { TimelockTxStatus } from "../../utils/tx-status" ;
1414import { Button } from "../ui/button" ;
@@ -19,21 +19,8 @@ interface SafeViewProps {
1919 executedProposals : SafeTx [ ] ;
2020}
2121
22- export type TabType = "queue" | "execute" | "history" ;
23-
2422export function SafeView ( { safeAddress } : SafeViewProps ) {
25- const router = useRouter ( ) ;
26- const searchParams = useSearchParams ( ) ;
27- const [ activeTab , setActiveTab ] = useState < TabType > ( ) ;
28-
29- useEffect ( ( ) => {
30- if ( activeTab === undefined ) {
31- const tab = searchParams . get ( "tab" ) as TabType ;
32- setActiveTab (
33- tab && [ "queue" , "execute" , "history" ] . includes ( tab ) ? tab : "queue"
34- ) ;
35- }
36- } , [ searchParams , activeTab ] ) ;
23+ const { activeTab, handleTabChange } = useTabs ( ) ;
3724
3825 const { txs, governor, isLoading, error } =
3926 useCurrentTransactions ( safeAddress ) ;
@@ -97,10 +84,7 @@ export function SafeView({ safeAddress }: SafeViewProps) {
9784 < div className = "p-4" >
9885 < Tabs
9986 value = { activeTab }
100- onValueChange = { ( value ) => {
101- setActiveTab ( value as TabType ) ;
102- router . replace ( `?tab=${ value } ` ) ;
103- } }
87+ onValueChange = { ( value ) => handleTabChange ( value as TabType ) }
10488 className = "w-full"
10589 >
10690 < TabsList >
0 commit comments