mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-06-08 11:37:25 +00:00
try to get task status before enabling certain buttons (not working yet)-
Some checks failed
Next.js Build Check / build (push) Has been cancelled
Some checks failed
Next.js Build Check / build (push) Has been cancelled
This commit is contained in:
parent
ddaed9c14a
commit
af33904b69
1 changed files with 33 additions and 1 deletions
|
|
@ -204,7 +204,39 @@ export function ReportingClientArea({
|
|||
// Baseline stays baseline
|
||||
const activeMetrics = baseline;
|
||||
|
||||
const scenarioBusy = !!selectedScenarioId && (isLoading || isFetching);
|
||||
const {
|
||||
data: taskData,
|
||||
isLoading: taskLoading,
|
||||
} = useQuery({
|
||||
queryKey: ["task", portfolioId],
|
||||
queryFn: async () => {
|
||||
const res = await fetch(
|
||||
`/api/task?source=portfolio_id&source_id=${portfolioId}&service=plan_categorisation`,
|
||||
);
|
||||
|
||||
if (!res.ok) throw new Error("Failed to fetch task");
|
||||
return res.json();
|
||||
},
|
||||
refetchInterval: (data) => {
|
||||
const status = data?.state?.data?.task?.status;
|
||||
|
||||
if (status === "Complete" || status === "Failed") {
|
||||
return false;
|
||||
}
|
||||
|
||||
return 3000;
|
||||
},
|
||||
refetchOnWindowFocus: false,
|
||||
});
|
||||
|
||||
const taskStatus = taskData?.task?.status;
|
||||
|
||||
const isTaskInProgress =
|
||||
taskStatus && taskStatus !== "Complete" && taskStatus !== "Failed";
|
||||
|
||||
const scenarioBusy =
|
||||
!!selectedScenarioId && (isLoading || isFetching || isTaskInProgress);
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue