fix: admin auth related fixes
This commit is contained in:
parent
9b7b23f5a2
commit
bcc4524f7f
80 changed files with 606 additions and 360 deletions
|
|
@ -1,15 +1,48 @@
|
|||
import { FC, ReactNode } from "react";
|
||||
"use client";
|
||||
import { FC, ReactNode, useEffect } from "react";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { useRouter } from "next/navigation";
|
||||
import useSWR from "swr";
|
||||
// ui
|
||||
import { Spinner } from "@plane/ui";
|
||||
// components
|
||||
import { InstanceSidebar } from "@/components/admin-sidebar";
|
||||
import { InstanceHeader } from "@/components/auth-header";
|
||||
import { NewUserPopup } from "@/components/new-user-popup";
|
||||
// hooks
|
||||
import { useInstance, useUser } from "@/hooks/store";
|
||||
|
||||
type TAdminLayout = {
|
||||
children: ReactNode;
|
||||
};
|
||||
|
||||
export const AdminLayout: FC<TAdminLayout> = (props) => {
|
||||
export const AdminLayout: FC<TAdminLayout> = observer((props) => {
|
||||
const { children } = props;
|
||||
// router
|
||||
const router = useRouter();
|
||||
// hooks
|
||||
const { fetchInstanceAdmins } = useInstance();
|
||||
const { fetchCurrentUser, isUserLoggedIn } = useUser();
|
||||
|
||||
useSWR("INSTANCE_ADMINS", () => fetchInstanceAdmins());
|
||||
|
||||
useSWR("CURRENT_USER", () => fetchCurrentUser(), {
|
||||
shouldRetryOnError: false,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (isUserLoggedIn === false) {
|
||||
router.push("/");
|
||||
}
|
||||
}, [router, isUserLoggedIn]);
|
||||
|
||||
if (isUserLoggedIn === undefined) {
|
||||
return (
|
||||
<div className="relative flex h-screen w-full items-center justify-center">
|
||||
<Spinner />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="relative flex h-screen w-screen overflow-hidden">
|
||||
|
|
@ -21,4 +54,4 @@ export const AdminLayout: FC<TAdminLayout> = (props) => {
|
|||
<NewUserPopup />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ export const DefaultLayout: FC<TDefaultLayout> = (props) => {
|
|||
const { children, withoutBackground = false } = props;
|
||||
// hooks
|
||||
const { resolvedTheme } = useTheme();
|
||||
const patternBackground = resolvedTheme === "dark" ? PlaneBackgroundPatternDark : PlaneBackgroundPattern;
|
||||
|
||||
return (
|
||||
<div className="relative">
|
||||
|
|
@ -29,11 +30,7 @@ export const DefaultLayout: FC<TDefaultLayout> = (props) => {
|
|||
</div>
|
||||
{!withoutBackground && (
|
||||
<div className="absolute inset-0 z-0">
|
||||
<Image
|
||||
src={resolvedTheme === "dark" ? PlaneBackgroundPatternDark : PlaneBackgroundPattern}
|
||||
className="w-screen h-full object-cover"
|
||||
alt="Plane background pattern"
|
||||
/>
|
||||
<Image src={patternBackground} className="w-screen h-full object-cover" alt="Plane background pattern" />
|
||||
</div>
|
||||
)}
|
||||
<div className="relative z-10 mb-[110px] flex-grow">{children}</div>
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
export * from "./default-layout";
|
||||
export * from "./admin-layout";
|
||||
Loading…
Add table
Add a link
Reference in a new issue