fix: handle errors in PotenzialiProvider and SessionProvider by reloading the window
This commit is contained in:
parent
0327957b3b
commit
9b37e5899d
2 changed files with 7 additions and 1 deletions
|
|
@ -26,12 +26,17 @@ type PotenzialiProviderProps = {
|
|||
children: React.ReactNode;
|
||||
};
|
||||
export const PotenzialiProvider = ({ children }: PotenzialiProviderProps) => {
|
||||
const { data } = api.potenziali.getPotenziali.useQuery(undefined, {
|
||||
const { data, isError } = api.potenziali.getPotenziali.useQuery(undefined, {
|
||||
refetchInterval: 30000,
|
||||
refetchIntervalInBackground: true,
|
||||
refetchOnWindowFocus: true,
|
||||
});
|
||||
|
||||
if (isError) {
|
||||
console.error("Errore nel caricamento dei potenziali");
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
const { data: columns } = api.potenziali.getPotenzialiGroups.useQuery();
|
||||
|
||||
const utils = api.useUtils();
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ export const SessionProvider: FC<{ children: ReactNode }> = ({ children }) => {
|
|||
|
||||
if (isError && error) {
|
||||
console.error("Session fetch error: ", error);
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
// Invalidate session on route change
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue