Skip to content

Commit

Permalink
feat: redirect to my simulations from running simulation if in that p…
Browse files Browse the repository at this point in the history
…age when it ends
  • Loading branch information
ivopr committed Jan 4, 2024
1 parent 0a71ba2 commit cb1f0b7
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"use client";
import { useEffect } from "react";
import { useRouter } from "next/navigation";

import { Details } from "@/app/[locale]/(simulation)/running-simulation/Information/Details";
import { RealtimeLog } from "@/app/[locale]/(simulation)/running-simulation/Information/RealtimeLog";
Expand All @@ -12,12 +12,14 @@ type Props = {
};

export function SimulationInformation({ username }: Props) {
const { data, isRefetching, refetch } = useRunningSimulation(username);
const { data, isRefetching } = useRunningSimulation(username);
const router = useRouter();

useEffect(() => {
refetch();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
if (!data || data.status === "not-running") {
router.push("/simulations");

return null;
}

if (!data || data.status !== "running") {
return null;
Expand Down

0 comments on commit cb1f0b7

Please sign in to comment.