import { FC, ReactNode, useEffect } from "react"; import useSWR from "swr"; // route import { useRouter } from "next/router"; // store import { observer } from "mobx-react-lite"; import { useMobxStore } from "lib/mobx/store-provider"; // components import { Spinner } from "@plane/ui"; import { InstanceNotReady } from "components/instance"; type Props = { children: ReactNode; }; const InstanceLayout: FC = observer(({ children }) => { // store const { instance: { fetchInstanceInfo, instance, createInstance }, } = useMobxStore(); const router = useRouter(); const isGodMode = router.pathname.includes("god-mode"); useSWR("INSTANCE_INFO", () => fetchInstanceInfo()); useEffect(() => { if (instance?.is_activated === false) { createInstance(); } }, [instance?.is_activated, createInstance]); return (
{instance ? ( !instance.is_setup_done && !isGodMode ? ( ) : ( children ) ) : (
)}
); }); export default InstanceLayout;