Skip to content

Commit 64e9cfe

Browse files
committed
feat: improve error handling in apps, datasets, deals, tasks, and workerpools routes with hasPastError flag
1 parent 13cabd9 commit 64e9cfe

File tree

5 files changed

+59
-24
lines changed

5 files changed

+59
-24
lines changed

src/routes/apps.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,22 @@ function useAppsData(currentPage: number) {
5151
data: formattedData,
5252
isLoading,
5353
isRefetching,
54-
isError: isError || errorUpdateCount > 0,
54+
isError,
55+
hasPastError: isError || errorUpdateCount > 0,
5556
additionalPages,
5657
};
5758
}
5859

5960
function AppsRoute() {
6061
const [currentPage, setCurrentPage] = useState(0);
61-
const { data, isLoading, isRefetching, isError, additionalPages } =
62-
useAppsData(currentPage);
62+
const {
63+
data,
64+
isLoading,
65+
isRefetching,
66+
isError,
67+
hasPastError,
68+
additionalPages,
69+
} = useAppsData(currentPage);
6370

6471
return (
6572
<div className="mt-8 grid gap-6">
@@ -76,12 +83,12 @@ function AppsRoute() {
7683
{isLoading && isRefetching && <LoaderCircle className="animate-spin" />}
7784
</h1>
7885

79-
{isError && !data.length ? (
86+
{hasPastError && !data.length ? (
8087
<Alert variant="destructive" className="mx-auto w-fit text-left">
8188
<Terminal className="h-4 w-4" />
8289
<AlertTitle>Error</AlertTitle>
8390
<AlertDescription>
84-
A error occurred during deals loading.
91+
A error occurred during apps loading.
8592
</AlertDescription>
8693
</Alert>
8794
) : (

src/routes/datasets.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,22 @@ function useDatasetsData(currentPage: number) {
5151
data: formattedData,
5252
isLoading,
5353
isRefetching,
54-
isError: isError || errorUpdateCount > 0,
54+
isError: isError,
55+
hasPastError: isError || errorUpdateCount > 0,
5556
additionalPages,
5657
};
5758
}
5859

5960
function DatasetsRoute() {
6061
const [currentPage, setCurrentPage] = useState(0);
61-
const { data, isLoading, isRefetching, isError, additionalPages } =
62-
useDatasetsData(currentPage);
62+
const {
63+
data,
64+
isLoading,
65+
isRefetching,
66+
isError,
67+
hasPastError,
68+
additionalPages,
69+
} = useDatasetsData(currentPage);
6370

6471
return (
6572
<div className="mt-8 grid gap-6">
@@ -78,12 +85,12 @@ function DatasetsRoute() {
7885
)}
7986
</h1>
8087

81-
{isError && !data.length ? (
88+
{hasPastError && !data.length ? (
8289
<Alert variant="destructive" className="mx-auto w-fit text-left">
8390
<Terminal className="h-4 w-4" />
8491
<AlertTitle>Error</AlertTitle>
8592
<AlertDescription>
86-
A error occurred during deals loading.
93+
A error occurred during datasets loading.
8794
</AlertDescription>
8895
</Alert>
8996
) : (

src/routes/deals.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,22 @@ function useDealsData(currentPage: number) {
5151
data: formattedData,
5252
isLoading,
5353
isRefetching,
54-
isError: isError || errorUpdateCount > 0,
54+
isError: isError,
55+
hasPastError: isError || errorUpdateCount > 0,
5556
additionalPages,
5657
};
5758
}
5859

5960
function DealsRoute() {
6061
const [currentPage, setCurrentPage] = useState(0);
61-
const { data, isLoading, isRefetching, isError, additionalPages } =
62-
useDealsData(currentPage);
62+
const {
63+
data,
64+
isLoading,
65+
isRefetching,
66+
isError,
67+
hasPastError,
68+
additionalPages,
69+
} = useDealsData(currentPage);
6370

6471
return (
6572
<div className="mt-8 grid gap-6">
@@ -77,7 +84,7 @@ function DealsRoute() {
7784
<LoaderCircle className="animate-spin" />
7885
)}
7986
</h1>
80-
{isError && !data.length ? (
87+
{hasPastError && !data.length ? (
8188
<Alert variant="destructive" className="mx-auto w-fit text-left">
8289
<Terminal className="h-4 w-4" />
8390
<AlertTitle>Error</AlertTitle>

src/routes/tasks.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,22 @@ function useTasksData(currentPage: number) {
5151
data: formattedData,
5252
isLoading,
5353
isRefetching,
54-
isError: isError || errorUpdateCount > 0,
54+
isError: isError,
55+
hasPastError: isError || errorUpdateCount > 0,
5556
additionalPages,
5657
};
5758
}
5859

5960
function TasksRoute() {
6061
const [currentPage, setCurrentPage] = useState(0);
61-
const { data, isLoading, isRefetching, isError, additionalPages } =
62-
useTasksData(currentPage);
62+
const {
63+
data,
64+
isLoading,
65+
isRefetching,
66+
isError,
67+
hasPastError,
68+
additionalPages,
69+
} = useTasksData(currentPage);
6370

6471
return (
6572
<div className="mt-8 grid gap-6">
@@ -78,12 +85,12 @@ function TasksRoute() {
7885
)}
7986
</h1>
8087

81-
{isError && !data.length ? (
88+
{hasPastError && !data.length ? (
8289
<Alert variant="destructive" className="mx-auto w-fit text-left">
8390
<Terminal className="h-4 w-4" />
8491
<AlertTitle>Error</AlertTitle>
8592
<AlertDescription>
86-
A error occurred during deals loading.
93+
A error occurred during tasks loading.
8794
</AlertDescription>
8895
</Alert>
8996
) : (

src/routes/workerpools.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,22 @@ function useWorkerpoolsData(currentPage: number) {
5151
data: formattedData,
5252
isLoading,
5353
isRefetching,
54-
isError: isError || errorUpdateCount > 0,
54+
isError: isError,
55+
hasPastError: isError || errorUpdateCount > 0,
5556
additionalPages,
5657
};
5758
}
5859

5960
function WorkerpoolsRoute() {
6061
const [currentPage, setCurrentPage] = useState(0);
61-
const { data, isLoading, isRefetching, isError, additionalPages } =
62-
useWorkerpoolsData(currentPage);
62+
const {
63+
data,
64+
isLoading,
65+
isRefetching,
66+
isError,
67+
hasPastError,
68+
additionalPages,
69+
} = useWorkerpoolsData(currentPage);
6370

6471
return (
6572
<div className="mt-8 grid gap-6">
@@ -78,12 +85,12 @@ function WorkerpoolsRoute() {
7885
)}
7986
</h1>
8087

81-
{isError && !data.length ? (
88+
{hasPastError && !data.length ? (
8289
<Alert variant="destructive" className="mx-auto w-fit text-left">
8390
<Terminal className="h-4 w-4" />
8491
<AlertTitle>Error</AlertTitle>
8592
<AlertDescription>
86-
A error occurred during deals loading.
93+
A error occurred during workerpool loading.
8794
</AlertDescription>
8895
</Alert>
8996
) : (

0 commit comments

Comments
 (0)