-
Notifications
You must be signed in to change notification settings - Fork 1
[feat] add login and signup modal #118
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 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
00a1f08
:fire: remove: styled components
naseungyeop b575425
:sparkles: feat: add signup page and css
naseungyeop 0b7eba6
:bug: fix: type error
naseungyeop 31f5d5b
:recycle: refactor: signup page css and move api folder
naseungyeop a374d2d
:sparkle: feat: add login signup modal
naseungyeop bcc9109
:bug: fix: install js-cookie
naseungyeop 58911d7
Revert ":bug: fix: install js-cookie"
naseungyeop 3dd9342
:recycle: refactor: css structure and finalize styles
naseungyeop 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,32 @@ | ||
| .modalContainer { | ||
| position: fixed; | ||
| top: 0; | ||
| left: 0; | ||
| width: 100%; | ||
| height: 100%; | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| background-color: rgba(0, 0, 0, 0.5); | ||
| z-index: 1000; | ||
| } | ||
|
|
||
| .modal { | ||
| width: 308px; | ||
| height: 152px; | ||
| background-color: white; | ||
| padding: 20px; | ||
| border-radius: 8px; | ||
| box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); | ||
| } | ||
| .message { | ||
| margin-top: 20px; | ||
| font-size: 18px; | ||
| font-weight: 500; | ||
| text-align: center; | ||
| } | ||
|
|
||
| .button { | ||
| margin-top: 30px; | ||
| height: 40px; | ||
| } | ||
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,35 @@ | ||
| import useModalStore from '../../modalStore/modalStore'; | ||
| import Button from '@/components/Button'; | ||
| import styles from './Modal.module.css'; | ||
| import { useRouter } from 'next/navigation'; | ||
|
|
||
| interface AlertModalProps { | ||
| message: string; | ||
| } | ||
|
|
||
| const AlertModal = ({ message }: AlertModalProps) => { | ||
| const { closeModal, messageType } = useModalStore(); | ||
| const router = useRouter(); | ||
|
|
||
| const handleConfirm = () => { | ||
| closeModal(); | ||
| if (messageType === 'success') { | ||
| router.push('/login'); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <div className={styles.modal}> | ||
| <div className={styles.messageContainer}> | ||
| <p className={styles.message}>{message}</p> | ||
| </div> | ||
| <div className={styles.buttonContainer}> | ||
| <Button onClick={handleConfirm} className={styles.button}> | ||
| νμΈ | ||
| </Button> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default AlertModal; |
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 useModalStore from '../../modalStore/modalStore'; | ||
| import styles from './Modal.module.css'; | ||
| import AlertModal from './Modal'; | ||
|
|
||
| const ModalContainer = () => { | ||
| const { isOpen, message } = useModalStore(); | ||
|
|
||
| if (!isOpen) return null; | ||
|
|
||
| return ( | ||
| <div className={styles.modalContainer}> | ||
| <AlertModal message={message} /> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default ModalContainer; |
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
File renamed without changes.
File renamed without changes.
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,14 +1,16 @@ | ||
| 'use client'; | ||
|
|
||
| import React from 'react'; | ||
| import axios from 'axios'; | ||
| import { useForm, FieldValues, UseFormReturn } from 'react-hook-form'; | ||
| import { useRouter } from 'next/navigation'; | ||
| import useAuthStore from '@/store/authStore'; | ||
| import Button from '@/components/Button'; | ||
| import { ERROR_MESSAGES } from '@/constants/message'; | ||
| import type { User } from '@/types/user'; | ||
| import styles from './loginPage.module.css'; | ||
| import ModalContainer from '../components/modal/ModalContainer'; | ||
| import useModalStore from '../modalStore/modalStore'; | ||
| import axios, { AxiosError, isAxiosError } from 'axios'; | ||
|
|
||
| type LoginFormInputs = { | ||
| email: string; | ||
|
|
@@ -33,6 +35,7 @@ export default function LoginPage() { | |
|
|
||
| const router = useRouter(); | ||
| const { setUser } = useAuthStore(); | ||
| const { openModal } = useModalStore(); | ||
|
|
||
| const onSubmit = async (data: LoginFormInputs) => { | ||
| try { | ||
|
|
@@ -43,78 +46,80 @@ export default function LoginPage() { | |
|
|
||
| router.replace('/mydashboard'); | ||
| } catch (error) { | ||
| console.error('λ‘κ·ΈμΈ μ€ν¨:', error); | ||
| alert('λΉλ°λ²νΈκ° μΌμΉνμ§ μμ΅λλ€.'); | ||
| openModal('λΉλ°λ²νΈκ° μΌμΉνμ§ μμ΅λλ€.', 'error'); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <form onSubmit={handleSubmit(onSubmit)} className={styles.form}> | ||
| <div className={styles.inputWrapper}> | ||
| <p className={styles.greeting}>μ€λλ λ§λμ λ°κ°μμ!</p> | ||
| <label htmlFor="email" className={styles.label}> | ||
| μ΄λ©μΌ | ||
| </label> | ||
| <input | ||
| id="email" | ||
| type="email" | ||
| className={`${styles.input} ${errors.email ? styles.inputError : ''}`} | ||
| {...register('email', { | ||
| required: ERROR_MESSAGES.REQUIRED_EMAIL, | ||
| pattern: { | ||
| value: /^[^\s@]+@[^\s@]+\.[^\s@]+$/, | ||
| message: ERROR_MESSAGES.INVALID_EMAIL, | ||
| }, | ||
| })} | ||
| /> | ||
| {errors.email && ( | ||
| <span className={styles.errorMessage}>{errors.email.message}</span> | ||
| )} | ||
| </div> | ||
| <div className={styles.loginContainer}> | ||
| <ModalContainer /> | ||
| <form onSubmit={handleSubmit(onSubmit)} className={styles.form}> | ||
| <div className={styles.inputWrapper}> | ||
| <p className={styles.greeting}>μ€λλ λ§λμ λ°κ°μμ!</p> | ||
| <label htmlFor="email" className={styles.label}> | ||
| μ΄λ©μΌ | ||
| </label> | ||
| <input | ||
| id="email" | ||
| type="email" | ||
| className={`${styles.input} ${errors.email ? styles.inputError : ''}`} | ||
| {...register('email', { | ||
| required: ERROR_MESSAGES.REQUIRED_EMAIL, | ||
| pattern: { | ||
| value: /^[^\s@]+@[^\s@]+\.[^\s@]+$/, | ||
| message: ERROR_MESSAGES.INVALID_EMAIL, | ||
| }, | ||
| })} | ||
| /> | ||
| {errors.email && ( | ||
| <span className={styles.errorMessage}>{errors.email.message}</span> | ||
| )} | ||
| </div> | ||
|
|
||
| <div className={styles.inputWrapper}> | ||
| <label htmlFor="password" className={styles.label}> | ||
| λΉλ°λ²νΈ | ||
| </label> | ||
| <input | ||
| id="password" | ||
| type="password" | ||
| className={`${styles.input} ${errors.password ? styles.inputError : ''}`} | ||
| {...register('password', { | ||
| required: ERROR_MESSAGES.PASSWORD_REQUIRE, | ||
| minLength: { | ||
| value: 8, | ||
| message: ERROR_MESSAGES.PASSWORD_TOO_SHORT, | ||
| }, | ||
| })} | ||
| /> | ||
| {errors.password && ( | ||
| <p className={styles.errorMessage}>{errors.password.message}</p> | ||
| )} | ||
| </div> | ||
| <Button | ||
| type="submit" | ||
| disabled={!isValid} | ||
| className={!isValid ? styles.disabled : ''} | ||
| style={{ height: '40px' }} | ||
| > | ||
| λ‘κ·ΈμΈ | ||
| </Button> | ||
| <div style={{ display: 'flex', justifyContent: 'center' }}> | ||
| <p> | ||
| νμμ΄ μλμ κ°μ?{' '} | ||
| <span | ||
| style={{ | ||
| color: 'var(--violet)', | ||
| textDecoration: 'underline', | ||
| cursor: 'pointer', | ||
| }} | ||
| onClick={() => router.push('/signup')} | ||
| > | ||
| νμκ°μ νκΈ° | ||
| </span>{' '} | ||
| </p> | ||
| </div> | ||
| </form> | ||
| <div className={styles.inputWrapper}> | ||
| <label htmlFor="password" className={styles.label}> | ||
| λΉλ°λ²νΈ | ||
| </label> | ||
| <input | ||
| id="password" | ||
| type="password" | ||
| className={`${styles.input} ${errors.password ? styles.inputError : ''}`} | ||
| {...register('password', { | ||
| required: ERROR_MESSAGES.PASSWORD_REQUIRE, | ||
| minLength: { | ||
| value: 8, | ||
| message: ERROR_MESSAGES.PASSWORD_TOO_SHORT, | ||
| }, | ||
| })} | ||
| /> | ||
| {errors.password && ( | ||
| <p className={styles.errorMessage}>{errors.password.message}</p> | ||
| )} | ||
| </div> | ||
| <Button | ||
| type="submit" | ||
| disabled={!isValid} | ||
| className={!isValid ? styles.disabled : ''} | ||
| style={{ height: '40px' }} | ||
| > | ||
| λ‘κ·ΈμΈ | ||
| </Button> | ||
| <div style={{ display: 'flex', justifyContent: 'center' }}> | ||
| <p> | ||
| νμμ΄ μλμ κ°μ?{' '} | ||
| <span | ||
| style={{ | ||
| color: 'var(--violet)', | ||
| textDecoration: 'underline', | ||
| cursor: 'pointer', | ||
| }} | ||
| onClick={() => router.push('/signup')} | ||
|
Owner
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. μΈλΌμΈ μ€νμΌμ΄ λ§λ€μ~ |
||
| > | ||
| νμκ°μ νκΈ° | ||
| </span>{' '} | ||
| </p> | ||
| </div> | ||
| </form> | ||
| </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,20 @@ | ||
| import { create } from 'zustand'; | ||
|
|
||
| interface ModalState { | ||
| isOpen: boolean; | ||
| message: string; | ||
| messageType: string; | ||
| openModal: (message: string, messageType: string) => void; | ||
| closeModal: () => void; | ||
| } | ||
|
|
||
| const useModalStore = create<ModalState>((set) => ({ | ||
| isOpen: false, | ||
| message: '', | ||
| messageType: '', | ||
| openModal: (message, messageType) => | ||
| set({ isOpen: true, message, messageType }), | ||
| closeModal: () => set({ isOpen: false, message: '', messageType: '' }), | ||
| })); | ||
|
|
||
| export default useModalStore; |
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.
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.
Enter π