-
Notifications
You must be signed in to change notification settings - Fork 1
[feat] add mypage layout and responsive CSS #26
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| .modal { | ||
| display: flex; | ||
| flex-direction: column; | ||
| align-items: center; | ||
| gap: 32px; | ||
| font-size: 16px; | ||
| font-weight: 500; | ||
| line-height: 26px; | ||
| color: var(--black-100); | ||
| padding: 32px 40px; | ||
| } | ||
|
|
||
| .button { | ||
| font-size: 14px; | ||
| font-weight: 600; | ||
| line-height: 24px; | ||
| padding: 9px 83.5px; | ||
| } | ||
|
|
||
| @media screen and (min-width: 768px) { | ||
| .modal { | ||
| font-size: 20px; | ||
| line-height: 32px; | ||
| padding: 40px 64px; | ||
| } | ||
| .button { | ||
| font-size: 16px; | ||
| line-height: 26px; | ||
| padding: 11px 106px; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import { ReactNode } from 'react'; | ||
| import Button from '@/components/Button'; | ||
| import styles from './AlertModal.module.css'; | ||
| import useModalStore from '../_store/modalStore'; | ||
|
|
||
| export default function AlertModal({ children }: { children: ReactNode }) { | ||
| const { closeModal } = useModalStore(); | ||
|
|
||
| return ( | ||
| <div className={styles.modal}> | ||
| {children} | ||
| <Button className={styles.button} onClick={closeModal}> | ||
| ํ์ธ | ||
| </Button> | ||
| </div> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| .form { | ||
| background-color: var(--white); | ||
| border-radius: 8px; | ||
| padding: 16px; | ||
| } | ||
|
|
||
| .profile { | ||
| display: flex; | ||
| flex-direction: column; | ||
| gap: 40px; | ||
| } | ||
|
|
||
| .userInfo { | ||
| flex: 1; | ||
| } | ||
|
|
||
| .form h2 { | ||
| font-size: 18px; | ||
| font-weight: 700; | ||
| line-height: 26px; | ||
| color: var(--black-100); | ||
| margin-bottom: 40px; | ||
| } | ||
|
|
||
| .input { | ||
| margin-bottom: 16px; | ||
| } | ||
|
|
||
| .button { | ||
| line-height: 24px; | ||
| margin-top: 24px; | ||
| padding: 15px 0; | ||
| } | ||
|
|
||
| @media screen and (min-width: 768px) { | ||
| .form { | ||
| padding: 24px; | ||
| } | ||
|
|
||
| .form h2 { | ||
| font-size: 24px; | ||
| line-height: 32px; | ||
| margin-bottom: 24px; | ||
| } | ||
|
|
||
| .profile { | ||
| flex-direction: row; | ||
| gap: 42px; | ||
| } | ||
|
|
||
| .button { | ||
| padding: 14px 0; | ||
| } | ||
| } | ||
|
|
||
| @media screen and (min-width: 1200px) { | ||
| .form { | ||
| max-width: 672px; | ||
| } | ||
|
|
||
| .userInfo { | ||
| max-width: 400px; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| .overlay { | ||
| position: fixed; | ||
| top: 0; | ||
| left: 0; | ||
| width: 100%; | ||
| height: 100%; | ||
| background-color: rgba(0, 0, 0, 0.5); | ||
| display: flex; | ||
| justify-content: center; | ||
| align-items: center; | ||
| z-index: 9999; | ||
| } | ||
|
|
||
| .modal { | ||
| background: var(--white); | ||
| border-radius: 16px; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import { useEffect } from 'react'; | ||
| import { createPortal } from 'react-dom'; | ||
| import useModalStore from '../_store/modalStore'; | ||
| import styles from './modal.module.css'; | ||
|
|
||
| export default function Modal() { | ||
| const { modals, closeModal } = useModalStore(); | ||
|
|
||
| useEffect(() => { | ||
| const handleKeyDown = (event: KeyboardEvent) => { | ||
| if (event.key === 'Escape') { | ||
| closeModal(); | ||
| } | ||
| }; | ||
|
|
||
| window.addEventListener('keydown', handleKeyDown); | ||
|
|
||
| return () => { | ||
| window.removeEventListener('keydown', handleKeyDown); | ||
| }; | ||
| }, [closeModal]); | ||
|
|
||
| if (modals.length === 0) return null; | ||
|
|
||
| return createPortal( | ||
| <div className={styles.overlay}> | ||
| {modals.map((content, index) => ( | ||
| <div key={index} className={styles.modal}> | ||
| {content} | ||
| </div> | ||
| ))} | ||
| </div>, | ||
| document.body | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,10 +1,14 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'use client'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { useEffect } from 'react'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { useForm } from 'react-hook-form'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import Input from './Input'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import Button from '@/components/Button'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { ERROR_MESSAGES } from '../constants/message'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { ERROR_MESSAGES } from '../_constants/message'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import styles from './Form.module.css'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { updatePassword } from '../lib/authHelper'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import useModalStore from '../_store/modalStore'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import axios from '../_lib/axios'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import AlertModal from './AlertModal'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export interface PasswordFormValues { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| currentPassword: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -16,18 +20,43 @@ export default function PasswordForm() { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| register, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| handleSubmit, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| formState: { errors }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| formState: { errors, isValid }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| watch, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| trigger, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setError, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| reset, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } = useForm<PasswordFormValues>({ mode: 'onChange' }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { openModal } = useModalStore(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const customIsValid = Object.keys(errors).length === 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const watchedPassword = watch('newPassword'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const onSubmit = async (data: PasswordFormValues) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| updatePassword(data, reset, setError); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const onSubmit = async (data: PasswordFormValues) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await axios.put('/auth/password', { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| password: data.currentPassword, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| newPassword: data.newPassword, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| reset(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (error instanceof Error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Collaborator
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. Error ์ธ์คํด์ค๊ฐ ์๋๊ฒฝ์ฐ๋ ์๋์..!?
Owner
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. catch์ error ํ์ ์ด unkown์ด๋ผ ํ์ ์ขํ๊ธฐ๋ก ์ฌ์ฉํ ๊ฒ ์ ๋๋ค.!! |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (error.message === ERROR_MESSAGES.CURRENT_PASSWORD_INCORRECT) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| openModal(<AlertModal>{error.message}</AlertModal>); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setError('currentPassword', { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: 'manual', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| message: error.message, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (error.message === ERROR_MESSAGES.SAME_AS_OLD_PASSWORD) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| openModal(<AlertModal>{error.message}</AlertModal>); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setError('newPassword', { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: 'manual', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| message: error.message, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+43
to
+56
Collaborator
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. ๋ชฌ๊ฐ..if๋ฌธ์์ if๋ฌธ์ ์ง์ํ๋ ๋๋์ด์ฌ์
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| useEffect(() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (watchedPassword) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -44,7 +73,9 @@ export default function PasswordForm() { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name="currentPassword" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| label="ํ์ฌ ๋น๋ฐ๋ฒํธ" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| placeholder="๋น๋ฐ๋ฒํธ ์ ๋ ฅ" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| register={register('currentPassword')} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| register={register('currentPassword', { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| required: ERROR_MESSAGES.PASSWORD_REQUIRE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| })} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| error={errors.currentPassword} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Input | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -54,6 +85,7 @@ export default function PasswordForm() { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| label="์ ๋น๋ฐ๋ฒํธ" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| placeholder="์ ๋น๋ฐ๋ฒํธ ์ ๋ ฅ" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| register={register('newPassword', { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| required: ERROR_MESSAGES.PASSWORD_REQUIRE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| minLength: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| value: 8, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| message: ERROR_MESSAGES.PASSWORD_TOO_SHORT, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -70,11 +102,17 @@ export default function PasswordForm() { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| validate: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| matchesPassword: (value) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| value === watchedPassword || ERROR_MESSAGES.PASSWORDS_MATCH, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| required: (value) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| value !== '' || ERROR_MESSAGES.PASSWORD_REQUIRE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| })} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| error={errors.newPasswordConfirmation} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Button className={styles.button} type="submit" disabled={!customIsValid}> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Button | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| className={styles.button} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type="submit" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| disabled={!(isValid && customIsValid)} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ๋ณ๊ฒฝ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </Button> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </form> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
๋ชฌ๊ฐ.. ์ ๋ apiํธ์ถํ๋ ๋ถ๋ถ์ ๋ณ๋๋ก ๋นผ์ ์ปดํฌ๋ํธ์์๋ ํจ์ ํธ์ถ๋งํด์ ์ฐ๋ ๋ฐฉํฅ์ผ๋ก ํ๊ณ ์๋๋ฐ
์ด๋ ์ ๊ฐ์~?
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.
@devmanta ์ ์ ์์ ํฌ์คํธ ์์ฒญ์ ํ๊ธ ๋๋ค์ ์๋๋๋ฐ์???
๋ณ๋๋ก ๋นผ๋ฉด ์ข์ฃ !!! ๊ท์ฐฎ์์ ์ํ์ต๋๋ค.. ๐ค
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.
@najitwo ๊ทธ๋ฐ์ด์ ๋ผ๋ฉด ๋นผ.์ฃผ.์ธ.์. ๐
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.
๋ฑ๋ก๋ง ๊ทธ๋ผ ํ๊ธ์ด์๋๋๊ฑด๊ฐ. . . . . .