Skip to content

Commit

Permalink
fix(ui): sidenav component returning as promise
Browse files Browse the repository at this point in the history
  • Loading branch information
Nabhag8848 committed Jul 31, 2024
1 parent 4928689 commit 7bf0dce
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 20 deletions.
21 changes: 18 additions & 3 deletions packages/revert-next/app/dashboard/layout.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<div className="flex h-screen flex-col md:flex-row md:overflow-hidden">
<div className="w-full flex-none md:w-64 border border-transparent border-r-gray-25">
<SideNav />
<SideNav value={{ account, userId, user }} />
</div>
<div className="flex-grow p-6 md:overflow-y-auto md:p-12">{children}</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/revert-next/components/ui/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
26 changes: 11 additions & 15 deletions packages/revert-next/components/ui/sidenav/SideNav.tsx
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down
3 changes: 2 additions & 1 deletion packages/revert-next/components/ui/sidenav/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { EnvironmentMode } from './EnvironmentMode';
export { NavLinks } from './NavLinks';
export { NavLinks } from './NavLinks';
export { SideNav } from './SideNav';

0 comments on commit 7bf0dce

Please sign in to comment.