-
Notifications
You must be signed in to change notification settings - Fork 2
Feat/11/signup page #35
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 all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
406ffc9
:recycle: refactor : 회원가입 폼 스키마, 타입 분리
ToKyun02 e4986e0
:sparkles: feat : 회원가입 폼 제출 API 기능 구현
ToKyun02 2652a92
:lipstick: feat : Auth관련 페이지 Header 컴포넌트 구현
ToKyun02 46c45eb
:lipstick: feat : 회원가입 페이지, 로그인 페이지 레이아웃 구현
ToKyun02 5d19a7e
:truck: chore : 오타 수정
ToKyun02 7e1f655
:recycle: refactor : axios 상태코드 확인 로직 삭제
ToKyun02 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,18 @@ | ||
| import axiosHelper from '@/utils/network/axiosHelper'; | ||
| import { SignupFormData } from './types'; | ||
| import { isAxiosError } from 'axios'; | ||
| import { SignupResponse } from './types'; | ||
| import { isError } from 'es-toolkit/compat'; | ||
|
|
||
| export const signup = async (signupFormData: SignupFormData): SignupResponse => { | ||
| try { | ||
| const response = await axiosHelper.post('/users', signupFormData); | ||
| return response.data; | ||
| } catch (error) { | ||
| if (isAxiosError(error)) return error.response?.data; | ||
|
|
||
| return { | ||
| message: isError(error) ? error.message : String(error), | ||
| }; | ||
| } | ||
| }; |
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,36 @@ | ||
| import { z } from 'zod'; | ||
| import { SINGUP_FORM_VALID_LENGTH, SIGNUP_FORM_ERROR_MESSAGE } from '@/constants/auth'; | ||
|
|
||
| export const signupSchema = z | ||
| .object({ | ||
| email: z.string().min(SINGUP_FORM_VALID_LENGTH.EMAIL.MIN, SIGNUP_FORM_ERROR_MESSAGE.EMAIL.MIN).email(SIGNUP_FORM_ERROR_MESSAGE.EMAIL.NOT_FORM), | ||
| nickname: z.string().min(SINGUP_FORM_VALID_LENGTH.NICKNAME.MIN, SIGNUP_FORM_ERROR_MESSAGE.NICKNAME.MIN).max(SINGUP_FORM_VALID_LENGTH.NICKNAME.MAX, SIGNUP_FORM_ERROR_MESSAGE.NICKNAME.MAX), | ||
| password: z.string().min(SINGUP_FORM_VALID_LENGTH.PASSWORD.MIN, SIGNUP_FORM_ERROR_MESSAGE.PASSWORD.MIN), | ||
| passwordConfirm: z.string(), | ||
| terms: z.boolean(), | ||
| }) | ||
| .refine((check) => check.password === check.passwordConfirm, { | ||
| message: SIGNUP_FORM_ERROR_MESSAGE.PASSWORD_CONFIRM.NOT_MATCH, | ||
| path: ['passwordConfirm'], | ||
| }) | ||
| .refine((check) => check.terms, { | ||
| message: SIGNUP_FORM_ERROR_MESSAGE.TERMS.NOT_TOS, | ||
| path: ['terms'], | ||
| }); | ||
|
|
||
| export type SignupFormData = z.infer<typeof signupSchema>; | ||
|
|
||
| export interface SignupSuccessResponse { | ||
| id: number; | ||
| email: string; | ||
| nickname: string; | ||
| profileImageUrl: string | null; | ||
| createdAt: string | Date; | ||
| updatedAt: string | Date; | ||
| } | ||
|
|
||
| export interface SignupFailResponse { | ||
| message: string; | ||
| } | ||
|
|
||
| export type SignupResponse = Promise<SignupSuccessResponse | SignupFailResponse>; |
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 Image from 'next/image'; | ||
| import Link from 'next/link'; | ||
| import LogoCi from '@/assets/images/logo_ci.png'; | ||
| import LogoBi from '@/assets/images/logo_bi.png'; | ||
| import { ReactNode } from 'react'; | ||
|
|
||
| export default function Header({ children }: { children: ReactNode }) { | ||
| return ( | ||
| <header className='flex flex-col items-center gap-[10px]'> | ||
| <Link href={'/'} className='flex flex-col gap-[30px]'> | ||
| <Image src={LogoCi} alt='로고 CI 이미지' width={200} height={200} /> | ||
| <Image src={LogoBi} alt='로고 BI 이미지' width={200} height={56} /> | ||
| </Link> | ||
| <p className='text-xl font-medium text-gray-70'>{children}</p> | ||
| </header> | ||
| ); | ||
| } |
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,17 +1,7 @@ | ||
| function Header() { | ||
| //TODO: Header 레이아웃 작업 | ||
| return <header></header>; | ||
| } | ||
|
|
||
| export default function Layout({ | ||
| children, | ||
| }: Readonly<{ | ||
| children: React.ReactNode; | ||
| }>) { | ||
| return ( | ||
| <> | ||
| <Header /> | ||
| {children} | ||
| </> | ||
| ); | ||
| return <div className='mx-3 flex min-h-dvh flex-col items-center justify-center gap-9 bg-gray-10'>{children}</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
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,9 +1,19 @@ | ||
| import Link from 'next/link'; | ||
| import LoginForm from './_components/LoginForm'; | ||
| //TODO: 로그인 페이지 작업 | ||
| import Header from '../_components/Header'; | ||
| export default function Login() { | ||
| return ( | ||
| <main> | ||
| <LoginForm /> | ||
| </main> | ||
| <> | ||
| <Header>오늘도 만나서 반가워요!</Header> | ||
| <main className='w-full max-w-[520px]'> | ||
| <LoginForm /> | ||
| <nav className='mt-9 flex items-center justify-center gap-2'> | ||
| <span>회원이 아니신가요?</span> | ||
| <Link href={'/signup'} className='text-violet-20 underline'> | ||
| 회원가입하기 | ||
| </Link> | ||
| </nav> | ||
| </main> | ||
| </> | ||
| ); | ||
| } |
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 |
|---|---|---|
| @@ -1,9 +1,19 @@ | ||
| import Link from 'next/link'; | ||
| import SignupForm from './_components/SignupForm'; | ||
| //TODO: 회원가입 페이지 작업 | ||
| import Header from '../_components/Header'; | ||
| export default function Signup() { | ||
| return ( | ||
| <main> | ||
| <SignupForm /> | ||
| </main> | ||
| <> | ||
| <Header>첫 방문을 환영합니다!</Header> | ||
| <main className='w-full max-w-[520px]'> | ||
| <SignupForm /> | ||
| <nav className='mt-9 flex items-center justify-center gap-2'> | ||
| <span>이미 회원이신가요?</span> | ||
| <Link href={'/login'} className='text-violet-20 underline'> | ||
| 로그인하기 | ||
| </Link> | ||
| </nav> | ||
| </main> | ||
| </> | ||
| ); | ||
| } |
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,26 @@ | ||
| interface SubmitButtonProps { | ||
| isValid: boolean; | ||
| text: string; | ||
| isSubmitting: boolean; | ||
| } | ||
|
|
||
| export default function SubmitButton({ isValid, text }: SubmitButtonProps) { | ||
| function BouncingLoader() { | ||
| return ( | ||
| <button disabled={!isValid} className={`rounded-lg ${isValid ? 'cursor-pointer bg-violet-20' : 'cursor-not-allowed bg-gray-40'} py-3 text-2lg font-medium text-white`}> | ||
| {text} | ||
| <div className='flex h-[26px] items-center justify-center space-x-2'> | ||
| <div className='h-2 w-2 animate-bounce rounded-full bg-violet-20'></div> | ||
| <div className='h-2 w-2 animate-bounce rounded-full bg-violet-20 [animation-delay:0.2s]'></div> | ||
| <div className='h-2 w-2 animate-bounce rounded-full bg-violet-20 [animation-delay:0.4s]'></div> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| export default function SubmitButton({ isValid, text, isSubmitting }: SubmitButtonProps) { | ||
| return ( | ||
| <button | ||
| disabled={!isValid || isSubmitting} | ||
| className={`rounded-lg ${isValid && !isSubmitting ? 'cursor-pointer bg-violet-20' : 'cursor-not-allowed bg-gray-40'} py-3 text-2lg font-medium text-white`} | ||
| > | ||
| {!isSubmitting ? text : <BouncingLoader />} | ||
| </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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import axios from 'axios'; | ||
|
|
||
| const axiosHelper = axios.create({ | ||
| baseURL: process.env.NEXT_PUBLIC_API_URL, | ||
| }); | ||
|
|
||
| export default axiosHelper; |
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.