-
Notifications
You must be signed in to change notification settings - Fork 0
[Feat] 로그인, 회원가입 페이지 제작 #88
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
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
00f4aa5
fix: 로그인, 회원가입 폼 리뷰 반영
yoorli 24c79cd
feat: 로그인, 회원가입 UI 생성
yoorli 4f75017
Merge remote-tracking branch 'origin/main' into yoolri-feat/input
yoorli 1456c62
Merge branch 'main' into yoolri-feat/auth-pages
yoorli 294587b
Merge branch 'main' into yoolri-feat/auth-pages
yoorli b690232
Merge branch 'main' into yoolri-feat/auth-pages
yoorli 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 |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import { Icon } from '@/components/icon'; | ||
| import { LoginForm } from '@/components/pages/login'; | ||
| import { AuthSwitch } from '@/components/shared'; | ||
|
|
||
| const LoginPage = () => { | ||
| return ( | ||
| <div className='flex-col-center min-h-[calc(100dvh-113px)] gap-10 overflow-auto bg-gray-100 px-4 py-15'> | ||
| <div className='flex-col-center w-full gap-4'> | ||
| <Icon id='wego-logo' className='h-19.5 w-45' /> | ||
| <LoginForm /> | ||
| </div> | ||
| <AuthSwitch type='signup' /> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default LoginPage; |
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,17 @@ | ||
| import { Icon } from '@/components/icon'; | ||
| import { SignupForm } from '@/components/pages/signup'; | ||
| import { AuthSwitch } from '@/components/shared'; | ||
|
|
||
| const SignupPage = () => { | ||
| return ( | ||
| <div className='flex-col-center min-h-[calc(100dvh-113px)] gap-10 overflow-auto bg-gray-100 px-4 py-15'> | ||
| <div className='flex-col-center w-full gap-4'> | ||
| <Icon id='wego-logo' className='h-19.5 w-45' /> | ||
| <SignupForm /> | ||
| </div> | ||
| <AuthSwitch type='login' /> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default SignupPage; |
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,12 +1,17 @@ | ||
| 'use client'; | ||
|
|
||
| import { useForm } from '@tanstack/react-form'; | ||
| import { type AnyFieldApi, useForm } from '@tanstack/react-form'; | ||
|
|
||
| import { FormInput } from '@/components/shared'; | ||
| import { Button } from '@/components/ui'; | ||
| import { loginSchema } from '@/lib/schema/auth'; | ||
|
|
||
| const getHintMessage = (errors: unknown[], isTouched: boolean, submissionAttempts: number) => { | ||
| const getHintMessage = (field: AnyFieldApi) => { | ||
| const { | ||
| meta: { errors, isTouched }, | ||
| } = field.state; | ||
| const { submissionAttempts } = field.form.state; | ||
|
|
||
| const firstError = errors[0] as { message?: string } | undefined; | ||
| const showError = isTouched || submissionAttempts > 0; | ||
|
|
||
|
|
@@ -40,10 +45,7 @@ export const LoginForm = () => { | |
| <div className='flex-col-center w-full gap-4'> | ||
| <form.Field name='email'> | ||
| {(field) => { | ||
| const { | ||
| meta: { errors, isTouched }, | ||
| } = field.state; | ||
| const hintMessage = getHintMessage(errors, isTouched, form.state.submissionAttempts); | ||
| const hintMessage = getHintMessage(field); | ||
|
|
||
| return ( | ||
| <FormInput | ||
|
|
@@ -63,10 +65,7 @@ export const LoginForm = () => { | |
|
|
||
| <form.Field name='password'> | ||
| {(field) => { | ||
| const { | ||
| meta: { errors, isTouched }, | ||
| } = field.state; | ||
| const hintMessage = getHintMessage(errors, isTouched, form.state.submissionAttempts); | ||
| const hintMessage = getHintMessage(field); | ||
|
|
||
| return ( | ||
| <FormInput | ||
|
|
@@ -88,19 +87,14 @@ export const LoginForm = () => { | |
| selector={(state) => ({ | ||
| canSubmit: state.canSubmit, | ||
| isSubmitting: state.isSubmitting, | ||
| isPristine: state.isPristine, | ||
| })} | ||
| > | ||
| {({ canSubmit, isSubmitting }) => { | ||
| const disabled = !canSubmit || isSubmitting; | ||
| {({ canSubmit, isSubmitting, isPristine }) => { | ||
| const disabled = !canSubmit || isSubmitting || isPristine; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isPristine이 isDirty의 반대군요 신기하네요 isPristine 조건은 혹시 모를 상황을 대비해 넣으신거라고 이해하면 될까요??
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 그것도 있고, 맨 처음 페이지에 들어갔을 때 버튼이 비활성화 상태인게 고정되어 있었으면 해서 한 번 써봤습니다. |
||
|
|
||
| return ( | ||
| <Button | ||
| className='border-none' | ||
| disabled={disabled} | ||
| size='md' | ||
| type='submit' | ||
| variant='primary' | ||
| > | ||
| <Button disabled={disabled} size='md' type='submit' variant='primary'> | ||
| 로그인하기 | ||
| </Button> | ||
| ); | ||
|
|
||
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,33 @@ | ||
| import Link from 'next/link'; | ||
|
|
||
| const authSwitchContent = { | ||
| login: { | ||
| description: '이미 회원이신가요?', | ||
| linkText: '로그인하기', | ||
| href: '/login', | ||
| }, | ||
| signup: { | ||
| description: 'WEGO가 처음이신가요?', | ||
| linkText: '회원가입하기', | ||
| href: '/signup', | ||
| }, | ||
| } as const; | ||
|
|
||
| type AuthSwitchType = keyof typeof authSwitchContent; | ||
|
|
||
| interface AuthSwitchProps { | ||
| type?: AuthSwitchType; | ||
| } | ||
|
|
||
| export const AuthSwitch = ({ type = 'login' }: AuthSwitchProps) => { | ||
| const content = authSwitchContent[type]; | ||
|
|
||
| return ( | ||
| <p className='flex-center bg-mono-white text-text-sm-medium gap-1 rounded-full px-4 py-2 text-gray-600'> | ||
| {content.description} | ||
| <Link href={content.href} className='text-mint-600 text-text-sm-semibold'> | ||
| {content.linkText} | ||
| </Link> | ||
| </p> | ||
| ); | ||
| }; |
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,4 @@ | ||
| export { AuthSwitch } from './auth-switch-link'; | ||
| export { FormInput } from './form-input'; | ||
| export { SearchBar } from './search-bar'; | ||
| export { TabNavigation } from './tab-navigation'; |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍👍👍