-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'adminV2' into SPV-1107/RemoveDeleteOption
- Loading branch information
Showing
10 changed files
with
95 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { useQueryClient } from '@tanstack/react-query'; | ||
import { useState } from 'react'; | ||
import { toast } from 'sonner'; | ||
import logger from '@/logger'; | ||
import { RefreshCw } from 'lucide-react'; | ||
import { cn } from '@/lib/utils.ts'; | ||
import { Button } from '@/components'; | ||
|
||
export const PageRefreshButton = () => { | ||
const queryClient = useQueryClient(); | ||
const [isRefreshing, setIsRefreshing] = useState(false); | ||
|
||
const onRefreshClick = async () => { | ||
setIsRefreshing(true); | ||
try { | ||
// Wait for all queries invalidation (data refetching) | ||
// and a minimum delay of 0.5sec before proceeding to make sure the UI doesn't flicker | ||
await Promise.all([queryClient.invalidateQueries(), new Promise((resolve) => setTimeout(resolve, 500))]); | ||
toast.success('Data refreshed'); | ||
} catch { | ||
logger.error('Failed to refresh'); | ||
toast.error('Failed to refresh'); | ||
} finally { | ||
setIsRefreshing(false); | ||
} | ||
}; | ||
|
||
return ( | ||
<Button variant="ghost" className="ml-auto" disabled={isRefreshing} onClick={onRefreshClick}> | ||
<RefreshCw className={cn('h-4 w-4 mr-2', isRefreshing && 'animate-spin')} /> | ||
Refresh | ||
</Button> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './PageRefreshButton.tsx'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters