2026-01-27 13:54:22 +05:30
|
|
|
/**
|
|
|
|
|
* Copyright (c) 2023-present Plane Software, Inc. and contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
* See the LICENSE file for details.
|
|
|
|
|
*/
|
|
|
|
|
|
2025-09-17 18:52:35 +05:30
|
|
|
import { useEffect } from "react";
|
2024-06-20 14:08:52 +05:30
|
|
|
import { observer } from "mobx-react";
|
2025-09-17 18:52:35 +05:30
|
|
|
import { useSearchParams, useRouter } from "next/navigation";
|
|
|
|
|
// plane imports
|
|
|
|
|
import { isValidNextPath } from "@plane/utils";
|
2024-05-14 14:26:54 +05:30
|
|
|
// components
|
2025-08-15 13:12:36 +05:30
|
|
|
import { UserLoggedIn } from "@/components/account/user-logged-in";
|
|
|
|
|
import { LogoSpinner } from "@/components/common/logo-spinner";
|
2024-05-14 14:26:54 +05:30
|
|
|
import { AuthView } from "@/components/views";
|
2024-05-16 04:03:43 +05:30
|
|
|
// hooks
|
2025-08-15 13:12:36 +05:30
|
|
|
import { useUser } from "@/hooks/store/use-user";
|
2025-11-26 13:57:46 +05:30
|
|
|
import type { Route } from "./+types/page";
|
|
|
|
|
|
|
|
|
|
export const headers: Route.HeadersFunction = () => ({
|
|
|
|
|
"X-Frame-Options": "SAMEORIGIN",
|
|
|
|
|
});
|
2024-05-14 14:26:54 +05:30
|
|
|
|
2025-11-20 19:09:40 +07:00
|
|
|
const HomePage = observer(function HomePage() {
|
2025-08-06 22:32:52 +05:30
|
|
|
const { data: currentUser, isAuthenticated, isInitializing } = useUser();
|
2025-09-17 18:52:35 +05:30
|
|
|
const searchParams = useSearchParams();
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
const nextPath = searchParams.get("next_path");
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (currentUser && isAuthenticated && nextPath && isValidNextPath(nextPath)) {
|
|
|
|
|
router.replace(nextPath);
|
|
|
|
|
}
|
|
|
|
|
}, [currentUser, isAuthenticated, nextPath, router]);
|
2024-05-14 14:26:54 +05:30
|
|
|
|
2025-08-06 22:32:52 +05:30
|
|
|
if (isInitializing)
|
2025-08-06 22:24:47 +05:30
|
|
|
return (
|
2026-03-02 20:40:50 +05:30
|
|
|
<div className="flex h-screen min-h-[500px] w-full items-center justify-center bg-surface-1">
|
2025-08-06 22:24:47 +05:30
|
|
|
<LogoSpinner />
|
|
|
|
|
</div>
|
|
|
|
|
);
|
2024-05-16 04:03:43 +05:30
|
|
|
|
2025-09-17 18:52:35 +05:30
|
|
|
if (currentUser && isAuthenticated) {
|
|
|
|
|
if (nextPath && isValidNextPath(nextPath)) {
|
|
|
|
|
return (
|
2026-03-02 20:40:50 +05:30
|
|
|
<div className="flex h-screen min-h-[500px] w-full items-center justify-center bg-surface-1">
|
2025-09-17 18:52:35 +05:30
|
|
|
<LogoSpinner />
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return <UserLoggedIn />;
|
|
|
|
|
}
|
2024-05-14 14:26:54 +05:30
|
|
|
|
2024-05-15 02:25:38 +05:30
|
|
|
return <AuthView />;
|
2024-05-23 14:27:16 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export default HomePage;
|