-
Notifications
You must be signed in to change notification settings - Fork 0
X/auth page #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
X/auth page #54
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,3 +1,85 @@ | ||
| 'use client'; | ||
| import Link from 'next/link'; | ||
| import { loginAction } from '@/lib/auth/auth-service'; | ||
| import { useActionState, useEffect } from 'react'; | ||
|
|
||
| export interface LoginState { | ||
| success: boolean; | ||
| errors: { | ||
| email?: string[]; | ||
| password?: string[]; | ||
| }; | ||
| message: string; | ||
| } | ||
|
|
||
| const initialState: LoginState = { | ||
| success: true, | ||
| errors: {}, | ||
| message: '', | ||
| }; | ||
|
|
||
| export default function LoginPage() { | ||
| return <div className="">login</div>; | ||
| const [state, formAction] = useActionState(loginAction, initialState); | ||
|
|
||
| useEffect(() => { | ||
| if (state && !state.success && Object.keys(state.errors).length === 0 && state.message) { | ||
| alert(state.message); | ||
| } | ||
|
Comment on lines
+25
to
+27
|
||
| }, [state]); | ||
|
|
||
| return ( | ||
| <div className="flex min-h-screen items-center"> | ||
| <div className="border-s-lightgrey container mx-auto max-w-md rounded-lg border-2 p-9"> | ||
| <h1 className="mb-6 text-center text-xl font-medium">Sign In</h1> | ||
|
|
||
| <form action={formAction} className="flex flex-col gap-y-4"> | ||
| <div className="flex flex-col gap-y-4"> | ||
| <div className="flex flex-col gap-0.5"> | ||
| <label htmlFor="email" className="font-semibold"> | ||
| </label> | ||
| <input | ||
| type="email" | ||
| name="email" | ||
| id="email" | ||
| className="bg-s-lightgrey rounded-lg px-2 py-3" | ||
| /> | ||
| {state?.errors?.email && ( | ||
| <p className="text-sm text-red-500">{state.errors.email[0]}</p> | ||
| )} | ||
| </div> | ||
|
|
||
| <div className="flex flex-col gap-0.5"> | ||
| <label htmlFor="password" className="font-semibold"> | ||
| Password | ||
| </label> | ||
| <input | ||
| type="password" | ||
| name="password" | ||
| id="password" | ||
| className="bg-s-lightgrey rounded-lg px-2 py-3" | ||
| /> | ||
| {state?.errors?.password && ( | ||
| <p className="text-sm text-red-500">{state.errors.password[0]}</p> | ||
| )} | ||
| </div> | ||
| </div> | ||
|
|
||
| <button | ||
| type="submit" | ||
| className="bg-s-purple hover:bg-s-purple/90 rounded-lg py-3 text-white transition-colors duration-200" | ||
| > | ||
| Continue | ||
| </button> | ||
|
|
||
| <div className="flex gap-x-1 text-sm"> | ||
| <p>Don't have an account?</p> | ||
| <Link href={'/signup'} className="text-s-purple"> | ||
| Sign Up | ||
| </Link> | ||
| </div> | ||
| </form> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
This file contains hidden or 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,3 +1,102 @@ | ||
| 'use client'; | ||
| import Link from 'next/link'; | ||
| import { signup } from '@/lib/auth/auth-service'; | ||
| import { useFormState } from 'react-dom'; | ||
| import { useEffect } from 'react'; | ||
|
|
||
| export interface SignupState { | ||
| success: boolean; | ||
| errors: { | ||
| name?: string[]; | ||
| email?: string[]; | ||
| password?: string[]; | ||
| }; | ||
| message: string; | ||
| } | ||
|
|
||
|
cherman23 marked this conversation as resolved.
|
||
| const initialState: SignupState = { | ||
| success: true, | ||
| errors: {}, | ||
| message: '', | ||
| }; | ||
|
|
||
| export default function SignupPage() { | ||
| return <div className="">signup</div>; | ||
| const [state, formAction] = useFormState(signup, initialState); | ||
|
|
||
| useEffect(() => { | ||
| if (state && !state.success && Object.keys(state.errors).length === 0 && state.message) { | ||
| alert(state.message); | ||
| } | ||
|
cherman23 marked this conversation as resolved.
|
||
| }, [state]); | ||
|
|
||
| return ( | ||
| <div className="flex min-h-screen items-center"> | ||
| <div className="border-s-lightgrey container mx-auto max-w-md rounded-lg border-2 p-9"> | ||
| <h1 className="mb-6 text-center text-xl font-medium">Create an account</h1> | ||
|
|
||
| <form action={formAction} className="flex flex-col gap-y-4"> | ||
| <div className="flex flex-col gap-y-4"> | ||
| <div className="flex flex-col gap-0.5"> | ||
| <label htmlFor="fullName" className="font-semibold"> | ||
| Full Name | ||
| </label> | ||
| <input | ||
| type="text" | ||
| name="fullName" | ||
| id="fullName" | ||
| className="bg-s-lightgrey rounded-lg px-2 py-3" | ||
| /> | ||
| {state?.errors?.name && ( | ||
| <p className="text-sm text-red-500">{state.errors.name[0]}</p> | ||
| )} | ||
| </div> | ||
|
|
||
| <div className="flex flex-col gap-0.5"> | ||
| <label htmlFor="email" className="font-semibold"> | ||
| </label> | ||
| <input | ||
| type="email" | ||
| name="email" | ||
| id="email" | ||
| className="bg-s-lightgrey rounded-lg px-2 py-3" | ||
| /> | ||
| {state?.errors?.email && ( | ||
| <p className="text-sm text-red-500">{state.errors.email[0]}</p> | ||
| )} | ||
| </div> | ||
|
|
||
| <div className="flex flex-col gap-0.5"> | ||
| <label htmlFor="password" className="font-semibold"> | ||
| Password | ||
| </label> | ||
| <input | ||
| type="password" | ||
| name="password" | ||
| id="password" | ||
| className="bg-s-lightgrey rounded-lg px-2 py-3" | ||
| /> | ||
| {state?.errors?.password && ( | ||
| <p className="text-sm text-red-500">{state.errors.password[0]}</p> | ||
| )} | ||
| </div> | ||
| </div> | ||
|
|
||
| <button | ||
| type="submit" | ||
| className="bg-s-purple hover:bg-s-purple/90 rounded-lg py-3 text-white transition-colors duration-200" | ||
| > | ||
| Continue | ||
| </button> | ||
|
|
||
| <div className="flex gap-x-1 text-sm"> | ||
| <p>Already have an account?</p> | ||
| <Link href={'/login'} className="text-s-purple"> | ||
| Sign In | ||
| </Link> | ||
| </div> | ||
| </form> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
This file contains hidden or 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,7 @@ | ||
| import { getCurrentUser } from '@/lib/auth/auth-service'; | ||
|
|
||
| export default async function DashboardPage() { | ||
| const name = await getCurrentUser(); | ||
|
|
||
| return <div className="">{name?.name}</div>; | ||
| } |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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,26 +1,31 @@ | ||
| @import 'tailwindcss'; | ||
| @import url('https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap'); | ||
|
|
||
| :root { | ||
| --background: #ffffff; | ||
| --foreground: #171717; | ||
| --background: #171717; | ||
| --foreground: #ffffff; | ||
| --sarge-purple: #5d5bf7; | ||
| --sarge-lightgrey: #f3f3f5; | ||
| } | ||
|
|
||
| @theme inline { | ||
| --color-background: var(--background); | ||
| --color-foreground: var(--foreground); | ||
| --font-sans: var(--font-geist-sans); | ||
| --color-s-purple: var(--sarge-purple); | ||
| --color-s-lightgrey: var(--sarge-lightgrey); | ||
| --font-sans: 'Inter', 'system-ui'; | ||
| --font-mono: var(--font-geist-mono); | ||
| } | ||
|
|
||
| @media (prefers-color-scheme: dark) { | ||
| :root { | ||
| --background: #0a0a0a; | ||
| --foreground: #ededed; | ||
| --background: #ffffff; | ||
| --foreground: #0a0a0a; | ||
| } | ||
| } | ||
|
|
||
| body { | ||
| background: var(--background); | ||
| color: var(--foreground); | ||
| font-family: Arial, Helvetica, sans-serif; | ||
| font-family: var(--font-sans); | ||
| } |
This file contains hidden or 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 hidden or 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,3 @@ | ||
| 'use client'; | ||
|
|
||
| // We need to create a React context to get the current user on the frontend in the authenticated pages |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.