11"use client"
22import { useMutation , useQuery , useQueryClient } from "@tanstack/react-query"
3- import { ArrowLeft , Copy , Pen , Search , X } from "lucide-react"
3+ import { ArrowLeft , Copy , Pen , RefreshCcw , Search , X } from "lucide-react"
44import Link from "next/link"
55import { useState } from "react"
66import { toast } from "sonner"
@@ -19,7 +19,7 @@ export default function TgGroups() {
1919 const trpc = useTRPC ( )
2020 const qc = useQueryClient ( )
2121 const queryOpts = trpc . tg . groups . search . queryOptions ( { query, limit : 20 , showHidden : true } )
22- const { data : allGroups , isLoading } = useQuery ( trpc . tg . groups . getAll . queryOptions ( ) )
22+ const { data : allGroups , isLoading, refetch } = useQuery ( trpc . tg . groups . getAll . queryOptions ( ) )
2323
2424 const [ rows , setRows ] = useState < Groups > ( ! isLoading ? ( allGroups ?? [ ] ) : [ ] )
2525
@@ -31,6 +31,7 @@ export default function TgGroups() {
3131
3232 async function invalidate ( ) {
3333 await qc . invalidateQueries ( queryOpts )
34+ refetch ( )
3435 await search ( )
3536 }
3637
@@ -78,6 +79,10 @@ export default function TgGroups() {
7879 Reset
7980 </ Button >
8081 ) }
82+ < Button variant = "outline" onClick = { invalidate } >
83+ < RefreshCcw />
84+ Refresh
85+ </ Button >
8186 </ div >
8287 < span className = "text-muted-foreground text-xs" > Max results: 20</ span >
8388 </ div >
0 commit comments