fix: handle errors in PotenzialiProvider and SessionProvider by reloading the window

This commit is contained in:
Marco Pedone 2025-12-11 15:42:02 +01:00
parent 0327957b3b
commit 9b37e5899d
2 changed files with 7 additions and 1 deletions

View file

@ -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();

View file

@ -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