-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
backend coupling , refresh encapsulation , empty data / error fallbac…
…k options
- Loading branch information
Showing
24 changed files
with
558 additions
and
230 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
"VITE_BACKEND_PORT=9000" | ||
VITE_BACKEND_PORT=9000 | ||
VITE_API_TIMEOUT=5000 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,6 +1,14 @@ | ||
import axios from "axios"; | ||
import { toast } from "sonner"; | ||
|
||
const client = axios.create({ | ||
baseURL: import.meta.env.VITE_SVELTOS_API_BASE_URL, | ||
timeout: 1000, | ||
baseURL: "/api", | ||
timeout: import.meta.env.VITE_API_TIMEOUT, | ||
}); | ||
|
||
client.interceptors.request.use(function (config) { | ||
config.headers["Content-Type"] = "application/json"; | ||
return config; | ||
}); | ||
|
||
export default client; |
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,37 @@ | ||
import * as React from "react"; | ||
|
||
import { cn } from "@/lib/utils"; | ||
import { Button, ButtonProps } from "@/components/ui/button"; | ||
import { useIsFetching, useQueryClient } from "react-query"; | ||
|
||
import { RefreshCcw } from "lucide-react"; | ||
|
||
const RefreshButton = React.forwardRef<HTMLButtonElement, ButtonProps>( | ||
({ className, variant, size, asChild = false, ...props }, ref) => { | ||
|
||
const queryClient = useQueryClient(); | ||
const isFetching = useIsFetching(); | ||
const handleRefresh = () =>{ | ||
queryClient.refetchQueries(); | ||
}; | ||
return ( | ||
<Button | ||
variant={"outline"} | ||
disabled={isFetching> 0} | ||
onClick={handleRefresh} | ||
className={className} | ||
ref={ref} | ||
> | ||
<> | ||
|
||
|
||
{isFetching>0 ? <RefreshCcw className="w-4 h-4 animate-spin mr-2" /> : <RefreshCcw className="w-4 h-4 mr-2" />} | ||
Refresh | ||
</> | ||
</Button> | ||
); | ||
}, | ||
); | ||
RefreshButton.displayName = "Button"; | ||
|
||
export { RefreshButton }; |
Oops, something went wrong.