diff --git a/src/config/app.config.ts b/src/config/app.config.ts index eddb0814..607f42d6 100644 --- a/src/config/app.config.ts +++ b/src/config/app.config.ts @@ -1,3 +1,4 @@ export const ADMIN_ROLE = 'ADMIN'; +export const USER_ROLE = 'USER'; export const JOBS_PER_PAGE = 10; export const DEFAULT_PAGE = 1; diff --git a/src/layouts/header.tsx b/src/layouts/header.tsx index 54663e4a..a973966f 100644 --- a/src/layouts/header.tsx +++ b/src/layouts/header.tsx @@ -28,7 +28,12 @@ import { import icons from '@/lib/icons'; export const CompanyLogo = () => { return ( -
+
{ + window.location.href = '/'; + }} + > 100xJobs { )} )} - -
- -
- {session.status === 'loading' ? ( - - ) : session.status === 'authenticated' ? ( - <> - - - - - - - - Profile - - - { - signOut(); - }} +
+ {session.status === 'loading' ? ( + + ) : session.status === 'authenticated' ? ( + <> + + + + + - - Log out - - - - - ) : ( -
- -
- )} + + + Profile + + + { + signOut(); + }} + > + + Log out + + + + + ) : ( +
+ +
+ )} +
+ +
+ +
diff --git a/src/layouts/mobile-nav.tsx b/src/layouts/mobile-nav.tsx index fe187c76..9e77652a 100644 --- a/src/layouts/mobile-nav.tsx +++ b/src/layouts/mobile-nav.tsx @@ -28,9 +28,9 @@ import { signOut, useSession } from 'next-auth/react'; import Link from 'next/link'; import { usePathname, useRouter } from 'next/navigation'; import { CompanyLogo } from './header'; -import spotifyLogo from '../../public/spotify.svg'; -import Image from 'next/image'; -import { ADMIN_ROLE } from '@/config/app.config'; +import { ADMIN_ROLE, USER_ROLE } from '@/config/app.config'; +import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; +import { getNameInitials } from '@/lib/utils'; export function MobileNav() { const router = useRouter(); const session = useSession(); @@ -84,26 +84,25 @@ export function MobileNav() { ) : (
- company-logo + + + + {getNameInitials(session.data.user.name)} + +
)}

- {session.data?.user.role === ADMIN_ROLE - ? 'Harkirat Singh' - : 'User'} + {session.data?.user.name}

- {session.data?.user.role === ADMIN_ROLE - ? 'admin@gmail.com' - : 'work@spotify.com'} + {session.data?.user.email}

@@ -115,22 +114,23 @@ export function MobileNav() { ))} - +
- Post a job + Login
)} - {session.status !== 'loading' && session.data?.user && ( - <> - {userNavbar.map((item) => ( - - ))} - - )} + {session.status !== 'loading' && + session.data?.user.role === USER_ROLE && ( + <> + {userNavbar.map((item) => ( + + ))} + + )} {session.status !== 'loading' && session.data?.user.role === ADMIN_ROLE && ( <> diff --git a/src/types/next-auth.d.ts b/src/types/next-auth.d.ts index 71700805..4daf2a21 100644 --- a/src/types/next-auth.d.ts +++ b/src/types/next-auth.d.ts @@ -8,6 +8,7 @@ declare module 'next-auth' { interface Session { user: { id: string; + email: string; role: string; name: string; isVerified: boolean;