fix: space user validation check

This commit is contained in:
sriram veeraghanta 2024-05-16 04:03:43 +05:30
parent b14d44049c
commit a195f1bf7e
13 changed files with 92 additions and 65 deletions

View file

@ -11,6 +11,7 @@ export const UserLoggedIn = () => {
const { data: user } = useUser();
if (!user) return null;
return (
<div className="flex h-screen w-screen flex-col">
<div className="relative flex w-full items-center justify-between gap-4 border-b border-custom-border-200 px-6 py-5">

View file

@ -1,2 +1,3 @@
export * from "./latest-feature-block";
export * from "./project-logo";
export * from "./logo-spinner";

View file

@ -0,0 +1,20 @@
"use client";
import Image from "next/image";
import { useTheme } from "next-themes";
// assets
import LogoSpinnerDark from "@/public/images/logo-spinner-dark.gif";
import LogoSpinnerLight from "@/public/images/logo-spinner-light.gif";
export const LogoSpinner = () => {
const { resolvedTheme } = useTheme();
const logoSrc = resolvedTheme === "dark" ? LogoSpinnerDark : LogoSpinnerLight;
return (
<div className="h-screen w-full flex min-h-[600px] justify-center items-center">
<div className="flex items-center justify-center">
<Image src={logoSrc} alt="logo" className="w-[82px] h-[82px] mr-2" />
</div>
</div>
);
};

View file

@ -1,8 +1,10 @@
"use client";
import { useEffect, FC } from "react";
import { observer } from "mobx-react-lite";
import Link from "next/link";
import { useRouter, useParams, useSearchParams, usePathname } from "next/navigation";
import useSWR from "swr";
// ui
import { Avatar, Button } from "@plane/ui";
// components
@ -21,7 +23,7 @@ export type NavbarControlsProps = {
projectSettings: any;
};
export const NavbarControls: FC<NavbarControlsProps> = (props) => {
export const NavbarControls: FC<NavbarControlsProps> = observer((props) => {
const { workspaceSlug, projectId, projectSettings } = props;
const { views } = projectSettings;
// router
@ -34,7 +36,11 @@ export const NavbarControls: FC<NavbarControlsProps> = (props) => {
const { settings, activeLayout, hydrate, setActiveLayout } = useProject();
hydrate(projectSettings);
const { data: user } = useUser();
const { data: user, fetchCurrentUser } = useUser();
useSWR("CURRENT_USER", () => fetchCurrentUser(), { errorRetryCount: 2 });
console.log("user", user);
useEffect(() => {
if (workspaceSlug && projectId && settings) {
@ -126,4 +132,4 @@ export const NavbarControls: FC<NavbarControlsProps> = (props) => {
)}
</>
);
};
});

View file

@ -1,7 +1,5 @@
"use client";
import { FC } from "react";
import { observer } from "mobx-react-lite";
import { Briefcase } from "lucide-react";
// components
import { ProjectLogo } from "@/components/common";
@ -13,7 +11,7 @@ type IssueNavbarProps = {
projectId: string;
};
const IssueNavbar: FC<IssueNavbarProps> = observer((props) => {
const IssueNavbar: FC<IssueNavbarProps> = (props) => {
const { projectSettings, workspaceSlug, projectId } = props;
const { project_details } = projectSettings;
@ -40,6 +38,6 @@ const IssueNavbar: FC<IssueNavbarProps> = observer((props) => {
</div>
</div>
);
});
};
export default IssueNavbar;

View file

@ -4,12 +4,8 @@ import { observer } from "mobx-react-lite";
import Image from "next/image";
// ui
import { useTheme } from "next-themes";
import useSWR from "swr";
import { Spinner } from "@plane/ui";
// components
import { AuthRoot } from "@/components/accounts";
// hooks
import { useUser } from "@/hooks/store";
// images
import PlaneBackgroundPatternDark from "public/auth/background-pattern-dark.svg";
import PlaneBackgroundPattern from "public/auth/background-pattern.svg";
@ -18,48 +14,27 @@ import BluePlaneLogoWithoutText from "public/plane-logos/blue-without-text-new.p
export const AuthView = observer(() => {
// hooks
const { resolvedTheme } = useTheme();
// store
const { fetchCurrentUser, isLoading } = useUser();
// fetching user information
const { isLoading: isSWRLoading } = useSWR("CURRENT_USER_DETAILS", () => fetchCurrentUser(), {
shouldRetryOnError: false,
revalidateOnFocus: false,
revalidateIfStale: false,
revalidateOnReconnect: true,
errorRetryCount: 1,
});
return (
<>
{isLoading || isSWRLoading ? (
<div className="relative flex h-screen w-screen items-center justify-center">
<Spinner />
</div>
) : (
<>
<div className="relative w-screen h-screen overflow-hidden">
<div className="absolute inset-0 z-0">
<Image
src={resolvedTheme === "dark" ? PlaneBackgroundPatternDark : PlaneBackgroundPattern}
className="w-full h-full object-cover"
alt="Plane background pattern"
/>
</div>
<div className="relative z-10 w-screen h-screen overflow-hidden overflow-y-auto flex flex-col">
<div className="container mx-auto px-10 lg:px-0 flex-shrink-0 relative flex items-center justify-between pb-4 transition-all">
<div className="flex items-center gap-x-2 py-10">
<Image src={BluePlaneLogoWithoutText} height={30} width={30} alt="Plane Logo" />
<span className="text-2xl font-semibold sm:text-3xl">Plane</span>
</div>
</div>
<div className="flex-grow container mx-auto max-w-lg px-10 lg:max-w-md lg:px-5 py-10">
<AuthRoot />
</div>
</div>
<div className="relative w-screen h-screen overflow-hidden">
<div className="absolute inset-0 z-0">
<Image
src={resolvedTheme === "dark" ? PlaneBackgroundPatternDark : PlaneBackgroundPattern}
className="w-full h-full object-cover"
alt="Plane background pattern"
/>
</div>
<div className="relative z-10 w-screen h-screen overflow-hidden overflow-y-auto flex flex-col">
<div className="container mx-auto px-10 lg:px-0 flex-shrink-0 relative flex items-center justify-between pb-4 transition-all">
<div className="flex items-center gap-x-2 py-10">
<Image src={BluePlaneLogoWithoutText} height={30} width={30} alt="Plane Logo" />
<span className="text-2xl font-semibold sm:text-3xl">Plane</span>
</div>
</>
)}
</>
</div>
<div className="flex-grow container mx-auto max-w-lg px-10 lg:max-w-md lg:px-5 py-10">
<AuthRoot />
</div>
</div>
</div>
);
});