diff --git a/packages/revert-next/app/dashboard/layout.tsx b/packages/revert-next/app/dashboard/layout.tsx index 4ef3ab48..7f8e38bd 100644 --- a/packages/revert-next/app/dashboard/layout.tsx +++ b/packages/revert-next/app/dashboard/layout.tsx @@ -1,15 +1,30 @@ -import { SideNav } from '@revertdotdev/components/sidenav/SideNav'; import { Metadata } from 'next'; +import { fetchAccountDetails } from '@revertdotdev/lib/api'; +import { auth, currentUser } from '@clerk/nextjs/server'; +import { SideNav } from '@revertdotdev/components'; export const metadata: Metadata = { title: 'Dashboard', }; -export default function Layout({ children }: { children: React.ReactNode }) { +export default async function Layout({ children }: { children: React.ReactNode }) { + const { userId } = auth(); + const user = await currentUser(); + + if (!userId || !user) { + return null; + } + + const account = await fetchAccountDetails(userId); + + if ('message' in account) { + return null; + } + return (
- +
{children}
diff --git a/packages/revert-next/components/ui/index.ts b/packages/revert-next/components/ui/index.ts index 4dcee73f..e82154e0 100644 --- a/packages/revert-next/components/ui/index.ts +++ b/packages/revert-next/components/ui/index.ts @@ -38,7 +38,7 @@ export { FancyInputBox, } from '@revertdotdev/components/common'; export { OnboardingNavLink } from '@revertdotdev/components/onboarding'; -export { EnvironmentMode, NavLinks } from '@revertdotdev/components/sidenav'; +export { EnvironmentMode, NavLinks, SideNav } from '@revertdotdev/components/sidenav'; export { CreatedApplications, ApplicationCards, diff --git a/packages/revert-next/components/ui/sidenav/SideNav.tsx b/packages/revert-next/components/ui/sidenav/SideNav.tsx index 7f1116c3..95f6336e 100644 --- a/packages/revert-next/components/ui/sidenav/SideNav.tsx +++ b/packages/revert-next/components/ui/sidenav/SideNav.tsx @@ -1,24 +1,20 @@ import Link from 'next/link'; import { OnboardingNavLink, EnvironmentMode, NavLinks } from '@revertdotdev/components'; import { BookOpenIcon } from '@revertdotdev/icons'; -import { fetchAccountDetails } from '@revertdotdev/lib/api'; -import { auth, currentUser } from '@clerk/nextjs/server'; import { UserButton } from '@clerk/nextjs'; +import { AccountResponseSchema } from '@revertdotdev/types/schemas/accountSchema'; +import { User } from '@clerk/nextjs/dist/types/server'; -export async function SideNav() { - const { userId } = auth(); - const user = await currentUser(); - - if (!userId || !user) { - return null; - } - - const account = await fetchAccountDetails(userId); - - if ('message' in account) { - return null; - } +type SideNavProps = { + value: { + account: AccountResponseSchema; + userId: string; + user: User | null; + }; +}; +export function SideNav({ value }: SideNavProps) { + const { account, user, userId } = value; const { isDefaultEnvironment, prodPrivateToken } = account; return ( diff --git a/packages/revert-next/components/ui/sidenav/index.ts b/packages/revert-next/components/ui/sidenav/index.ts index 49a28006..7ff32bf3 100644 --- a/packages/revert-next/components/ui/sidenav/index.ts +++ b/packages/revert-next/components/ui/sidenav/index.ts @@ -1,2 +1,3 @@ export { EnvironmentMode } from './EnvironmentMode'; -export { NavLinks } from './NavLinks'; \ No newline at end of file +export { NavLinks } from './NavLinks'; +export { SideNav } from './SideNav';