mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
58bf056ddb
* fix: login redirection * dev: log the user out when deactivating the account * dev: update redirect uris for google and github * fix: redirection url and invitation api and add redirection to god mode in nginx * dev: add reset password redirection * dev: update nginx headers * dev: fix setup sh and env example and put validation for use minio when fetching project covers * dev: stabilize dev setup * fix: handled redirection error in web, space, and admin apps * fix: resovled build errors --------- Co-authored-by: pablohashescobar <nikhilschacko@gmail.com>
53 lines
1.5 KiB
TypeScript
53 lines
1.5 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";
|
|
// helpers
|
|
import { EInstancePageType } from "@/helpers";
|
|
|
|
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,
|
|
});
|
|
|
|
if (isSWRLoading || isLoading)
|
|
return (
|
|
<div className="relative flex h-screen w-full items-center justify-center">
|
|
<Spinner />
|
|
</div>
|
|
);
|
|
|
|
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}</>;
|
|
});
|