import { redirect } from "next/navigation";
import type { PropsWithChildren } from "react";
import { api } from "@repo/backend/src/_generated/api";
import { fetchQuery } from "convex/nextjs";
import { getToken } from "@/lib/auth/server";
export const dynamic = "force-dynamic";
export const SignedIn = async ({ children }: PropsWithChildren) => {
const token = await getToken();
if (!token) redirect("/");
const currentUser = await fetchQuery(api.auth.getCurrentUser, {}, { token });
if (!currentUser) redirect("/");
return <>{children}</>;
};
import { redirect } from "next/navigation";
import type { PropsWithChildren } from "react";
import { api } from "@repo/backend/src/_generated/api";
import { fetchQuery } from "convex/nextjs";
import { getToken } from "@/lib/auth/server";
export const dynamic = "force-dynamic";
export const SignedIn = async ({ children }: PropsWithChildren) => {
const token = await getToken();
if (!token) redirect("/");
const currentUser = await fetchQuery(api.auth.getCurrentUser, {}, { token });
if (!currentUser) redirect("/");
return <>{children}</>;
};