mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import { FC, ReactNode } from "react";
|
|
import { observer } from "mobx-react-lite";
|
|
import useSWR from "swr";
|
|
// ui
|
|
import { Spinner } from "@plane/ui";
|
|
// components
|
|
import { InstanceNotReady, InstanceFailureView } from "@/components/instance";
|
|
// hooks
|
|
import { useInstance } from "@/hooks/store";
|
|
|
|
type TInstanceWrapper = {
|
|
children: ReactNode;
|
|
};
|
|
|
|
export const InstanceWrapper: FC<TInstanceWrapper> = observer((props) => {
|
|
const { children } = props;
|
|
// hooks
|
|
const { isLoading, instance, fetchInstanceInfo } = useInstance();
|
|
|
|
const { isLoading: isSWRLoading, mutate } = useSWR("INSTANCE_INFORMATION", () => fetchInstanceInfo(), {
|
|
revalidateOnFocus: false,
|
|
revalidateIfStale: false,
|
|
revalidateOnReconnect: false,
|
|
errorRetryCount: 0,
|
|
});
|
|
|
|
if (isSWRLoading || isLoading)
|
|
return (
|
|
<div className="relative flex h-screen w-full items-center justify-center">
|
|
<Spinner />
|
|
</div>
|
|
);
|
|
|
|
if (!instance) return <InstanceFailureView mutate={mutate} />;
|
|
|
|
if (instance?.instance?.is_setup_done === false) return <InstanceNotReady />;
|
|
|
|
return <>{children}</>;
|
|
});
|