-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
86b6480
commit 24d8645
Showing
14 changed files
with
151 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { handlers } from '@/app/auth' | ||
|
||
export const { GET, POST } = handlers | ||
export const runtime = 'edge' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import NextAuth from 'next-auth' | ||
import GitHub from 'next-auth/providers/github' | ||
|
||
export const { handlers, signIn, signOut, auth } = NextAuth({ | ||
providers: [GitHub], | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { auth, signIn } from '@/app/auth' | ||
import { Button } from '@radix-ui/themes' | ||
import { UserAuth } from './user' | ||
|
||
export const Auth = async () => { | ||
const session = await auth() | ||
|
||
if (!session?.user) { | ||
return ( | ||
<form | ||
action={async () => { | ||
'use server' | ||
await signIn() | ||
}} | ||
> | ||
<Button type="submit">Sign in</Button> | ||
</form> | ||
) | ||
} | ||
|
||
return <UserAuth user={session.user} /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use client' | ||
|
||
import { Avatar, Button, DropdownMenu, Flex } from '@radix-ui/themes' | ||
import type { User } from 'next-auth' | ||
import { signOut } from 'next-auth/react' | ||
|
||
export const UserAuth = ({ user }: { user: User }) => { | ||
return ( | ||
<Flex align="center" gap="3"> | ||
<DropdownMenu.Root> | ||
<DropdownMenu.Trigger> | ||
<Button variant="soft"> | ||
{user.name} | ||
<DropdownMenu.TriggerIcon /> | ||
</Button> | ||
</DropdownMenu.Trigger> | ||
<DropdownMenu.Content variant="soft"> | ||
<DropdownMenu.Item | ||
onSelect={async () => { | ||
await signOut() | ||
}} | ||
> | ||
Sign out | ||
</DropdownMenu.Item> | ||
</DropdownMenu.Content> | ||
</DropdownMenu.Root> | ||
<Avatar | ||
src={user.image ?? undefined} | ||
alt={user.name ?? 'User profile picture'} | ||
fallback={user.name?.charAt(0).toUpperCase() ?? '😕'} | ||
/> | ||
</Flex> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,43 @@ | ||
'use client' | ||
import { Box, Flex, Link, Reset } from '@radix-ui/themes' | ||
import NextLink from 'next/link' | ||
|
||
import * as NavigationMenu from '@radix-ui/react-navigation-menu' | ||
import { Flex, Reset } from '@radix-ui/themes' | ||
import type { Route } from 'next' | ||
import NextLink, { type LinkProps } from 'next/link' | ||
import { usePathname } from 'next/navigation' | ||
import type { FC, HTMLProps } from 'react' | ||
|
||
const Link: FC<LinkProps<Route> & HTMLProps<HTMLAnchorElement>> = ({ | ||
href, | ||
...props | ||
}) => { | ||
const pathname = usePathname() | ||
const isActive = pathname === href | ||
|
||
return ( | ||
<NavigationMenu.Link asChild active={isActive}> | ||
<NextLink href={href} className="NavigationMenuLink" {...props} /> | ||
</NavigationMenu.Link> | ||
) | ||
} | ||
import type {} from 'react' | ||
import { Auth } from './auth/auth' | ||
|
||
export const Navigation = () => { | ||
return ( | ||
<NavigationMenu.Root> | ||
<Reset> | ||
<Flex gap="3" asChild> | ||
<NavigationMenu.List> | ||
<NavigationMenu.Item> | ||
<Link href="/">Home</Link> | ||
</NavigationMenu.Item> | ||
<NavigationMenu.Item> | ||
<Link href="/companies">Companies</Link> | ||
</NavigationMenu.Item> | ||
</NavigationMenu.List> | ||
</Flex> | ||
</Reset> | ||
</NavigationMenu.Root> | ||
<Reset> | ||
<Flex | ||
width="100%" | ||
align="center" | ||
p="3" | ||
px="4" | ||
gap="3" | ||
asChild | ||
style={{ | ||
borderRadius: 'var(--radius-4)', | ||
background: 'var(--accent-2)', | ||
border: '3px solid var(--accent-3)', | ||
}} | ||
> | ||
<ul> | ||
<li> | ||
<Link underline="hover" asChild> | ||
<NextLink href="/">Home</NextLink> | ||
</Link> | ||
</li> | ||
<li> | ||
<Link underline="hover" asChild> | ||
<NextLink href="/companies">Companies</NextLink> | ||
</Link> | ||
</li> | ||
<Box ml="auto" asChild> | ||
<li> | ||
<Auth /> | ||
</li> | ||
</Box> | ||
</ul> | ||
</Flex> | ||
</Reset> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import type { User } from 'next-auth' | ||
|
||
export const isAdmin = (user?: User) => { | ||
return user && user.email === process.env.PERSONAL_EMAIL | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters