diff options
author | 2024-08-11 13:18:53 -0700 | |
---|---|---|
committer | 2024-08-11 13:18:53 -0700 | |
commit | 18b7853ed8909c08bf7d545613dd111a3387a1ca (patch) | |
tree | 45fc90bc762f1de1154266d4aede37d209f3f81f /frontend/src/app/dashboard/page.tsx | |
parent | f35fb7715984148990b3195d7ea8c5b355223387 (diff) | |
parent | a9ec4cdbdab6f8026128728c34afa3150663a18b (diff) | |
download | ibd-trader-18b7853ed8909c08bf7d545613dd111a3387a1ca.tar.gz ibd-trader-18b7853ed8909c08bf7d545613dd111a3387a1ca.tar.zst ibd-trader-18b7853ed8909c08bf7d545613dd111a3387a1ca.zip |
Merge remote-tracking branch 'frontend/main'
Diffstat (limited to 'frontend/src/app/dashboard/page.tsx')
-rw-r--r-- | frontend/src/app/dashboard/page.tsx | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/frontend/src/app/dashboard/page.tsx b/frontend/src/app/dashboard/page.tsx new file mode 100644 index 0000000..289dcab --- /dev/null +++ b/frontend/src/app/dashboard/page.tsx @@ -0,0 +1,34 @@ +import { Metadata } from "next"; +import { createUserServiceClient } from "@/client/client"; +import { getSession, withPageAuthRequired } from "@auth0/nextjs-auth0"; +import Layout from "@/components/Layout/Layout"; +import { redirect, RedirectType } from "next/navigation"; +import { red } from "next/dist/lib/picocolors"; + +export const metadata: Metadata = { + title: "IBD Trader Dashboard", +}; + +export default withPageAuthRequired(async function Dashboard() { + const client = createUserServiceClient(); + + const user = await getSession(); + if (!user) { + redirect("/api/auth/login", RedirectType.replace); + } + + const dbUser = await client.createUser({ + subject: user.user["sub"], + }); + + // Check if user has IBD credentials + if (!dbUser.user || !dbUser.user.ibdUsername) { + redirect("/new-user", RedirectType.replace); + } + + return ( + <Layout> + <h1>Dashboard</h1> + </Layout> + ); +}, { returnTo: "/dashboard" }); |