mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
88ebda42ff
* dev: update python version * dev: handle magic code attempt exhausted * dev: update app, space and god mode redirection paths * fix: handled signup and signin workflow * chore: auth input error indication and autofill styling improvement * dev: add app redirection urls * dev: update redirections * chore: onboarding improvement * chore: onboarding improvement * chore: redirection issue in space resolved * chore: instance empty state added * dev: fix app, space, admin redirection in docker setitngs --------- Co-authored-by: guru_sainath <gurusainath007@gmail.com> Co-authored-by: Anmol Singh Bhatia <anmolsinghbhatia@plane.so>
66 lines
1.9 KiB
TypeScript
66 lines
1.9 KiB
TypeScript
"use client";
|
|
|
|
import { FC, ReactNode } from "react";
|
|
import { redirect, useSearchParams } from "next/navigation";
|
|
import { observer } from "mobx-react-lite";
|
|
import useSWR from "swr";
|
|
import { Spinner } from "@plane/ui";
|
|
// layouts
|
|
import { DefaultLayout } from "@/layouts";
|
|
// components
|
|
import { InstanceNotReady } from "@/components/instance";
|
|
// hooks
|
|
import { useInstance } from "@/hooks/store";
|
|
// helpers
|
|
import { EInstancePageType } from "@/helpers";
|
|
import { EmptyState } from "@/components/common";
|
|
|
|
type TInstanceWrapper = {
|
|
children: ReactNode;
|
|
pageType?: EInstancePageType;
|
|
};
|
|
|
|
export const InstanceWrapper: FC<TInstanceWrapper> = observer((props) => {
|
|
const { children, pageType } = props;
|
|
const searchparams = useSearchParams();
|
|
const authEnabled = searchparams.get("auth_enabled") || "1";
|
|
// hooks
|
|
const { isLoading, instance, fetchInstanceInfo } = useInstance();
|
|
|
|
const { isLoading: isSWRLoading } = 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 (
|
|
<EmptyState
|
|
title="Your instance wasn't configured successfully."
|
|
description="Please try re-installing Plane to fix the problem. If the issue still persists please reach out to support@plane.so."
|
|
/>
|
|
);
|
|
}
|
|
|
|
if (instance?.instance?.is_setup_done === false && authEnabled === "1")
|
|
return (
|
|
<DefaultLayout withoutBackground>
|
|
<InstanceNotReady />
|
|
</DefaultLayout>
|
|
);
|
|
|
|
if (instance?.instance?.is_setup_done && pageType === EInstancePageType.PRE_SETUP) redirect("/");
|
|
|
|
if (!instance?.instance?.is_setup_done && pageType === EInstancePageType.POST_SETUP) redirect("/setup");
|
|
|
|
return <>{children}</>;
|
|
});
|