-
Notifications
You must be signed in to change notification settings - Fork 70
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
StephDietz
committed
Mar 13, 2024
1 parent
6f174a9
commit d01cdfb
Showing
4 changed files
with
67 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
'use client'; | ||
|
||
import { Label } from '@/components/ui/label'; | ||
import { Input } from '@/components/ui/input'; | ||
import Link from 'next/link'; | ||
import { Button } from '@/components/ui/button'; | ||
import { Checkbox } from '@/components/ui/checkbox'; | ||
import { login } from '@/lib/auth'; | ||
import { useFormState, useFormStatus } from 'react-dom'; | ||
|
||
export default function Login() { | ||
const [state, action] = useFormState(login, undefined); | ||
|
||
return ( | ||
<div className="flex w-1/4 items-center px-4 sm:px-6 lg:px-8"> | ||
<div className="mx-auto w-full space-y-8"> | ||
|
@@ -14,12 +20,13 @@ export default function Login() { | |
Enter your email below to login to your account | ||
</p> | ||
</div> | ||
<form> | ||
<form action={action}> | ||
<div className="space-y-4"> | ||
<div className="space-y-2"> | ||
<Label htmlFor="email">Email</Label> | ||
<Input | ||
id="email" | ||
name="email" | ||
placeholder="[email protected]" | ||
required | ||
type="email" | ||
|
@@ -35,14 +42,15 @@ export default function Login() { | |
Forgot your password? | ||
</Link> | ||
</div> | ||
<Input id="password" required type="password" /> | ||
<Input id="password" required type="password" name="password" /> | ||
</div> | ||
<div className="flex items-center space-x-2"> | ||
<Checkbox id="remember" /> | ||
<Label className="text-sm" htmlFor="remember"> | ||
Remember me | ||
</Label> | ||
</div> | ||
{state?.message && <p className="text-red-500">{state.message}</p>} | ||
<Button className="w-full">Login</Button> | ||
<Button className="w-full" variant="outline"> | ||
Login with Google | ||
|
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,17 @@ | ||
'use client'; | ||
|
||
import { logout } from '@/lib/auth'; | ||
import { LogOutIcon } from '@/components/ui/icons'; | ||
export default function LogoutButton() { | ||
return ( | ||
<button | ||
className="flex items-center gap-3 rounded-lg px-3 py-2 text-sm font-medium text-gray-500 transition-all hover:text-gray-900 hover:dark:text-gray-300" | ||
onClick={async () => { | ||
await logout(); | ||
}} | ||
> | ||
<LogOutIcon className="h-4 w-4" /> | ||
Logout | ||
</button> | ||
); | ||
} |
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