import { auth, SIGN_IN_PATH } from "@/auth"; import { getUserByEmail } from "@/db/users"; import type { Metadata } from "next"; import { redirect } from "next/navigation"; import { connection } from "next/server"; import { Suspense } from "react"; import { AuthShell } from "../_components/auth-shell"; import { signOutToHome } from "./actions"; export const metadata: Metadata = { title: "Account — SchemaTax", robots: { index: false, follow: false }, }; const dateTime = new Intl.DateTimeFormat("en-US", { dateStyle: "long", timeStyle: "short", timeZone: "UTC", }); const date = new Intl.DateTimeFormat("en-US", { dateStyle: "long", timeZone: "UTC", }); export default function AccountPage() { return (

Your account

}>
); } async function AccountDetails() { // Auth.js reaches for crypto before it reads the cookie; mark the request // first so prerendering stops here. await connection(); const session = await auth(); const email = session?.user?.email; if (!email) redirect(SIGN_IN_PATH); const user = await getUserByEmail(email); if (!user) redirect(SIGN_IN_PATH); const rows = [ ["Email", user.email], ["Member since", date.format(user.createdAt)], [ "Last sign-in", user.lastSignInAt ? `${dateTime.format(user.lastSignInAt)} UTC` : "Not recorded", ], ["Sign-ins", String(user.signInCount)], ]; return ( <>
{rows.map(([term, value]) => (
{term}
{value}
))}
); }