diff --git a/src/app/components/Menu.tsx b/src/app/components/Menu.tsx index 600a729..3258f47 100644 --- a/src/app/components/Menu.tsx +++ b/src/app/components/Menu.tsx @@ -81,6 +81,11 @@ export default function Menu({ }, ] + const handleClickEdit = () => { + setIsOpen(false) + router.push('/users/1/setting') + } + return (
@@ -99,7 +104,7 @@ export default function Menu({
router.push('/users/1/setting')} + onClick={() => handleClickEdit()} > 수정하기
diff --git a/src/app/users/[id]/page.tsx b/src/app/users/[id]/page.tsx index fb180ea..5222a9c 100644 --- a/src/app/users/[id]/page.tsx +++ b/src/app/users/[id]/page.tsx @@ -8,6 +8,7 @@ import getData from './getData' import PlaceListComponent from './components/PlaceListComponent' import CourseListComponent from './components/CourseListComponent' import { Select } from 'antd' +import { useRouter } from 'next/navigation' interface Place { id: number @@ -36,6 +37,7 @@ export default function Page() { const [order, setOrder] = useState('recent') const places: Place[] = data.place_info.places const courses: Course[] = data.course_info.courses + const router = useRouter() const onChangeOrder = (value: string) => { setOrder(value) @@ -66,7 +68,12 @@ export default function Page() {
{data.user_info.name} -
diff --git a/src/app/users/[id]/setting/page.tsx b/src/app/users/[id]/setting/page.tsx new file mode 100644 index 0000000..7919b6b --- /dev/null +++ b/src/app/users/[id]/setting/page.tsx @@ -0,0 +1,118 @@ +'use client' + +import Image from 'next/image' +import { useRouter } from 'next/navigation' +import { useState } from 'react' + +export default function Page() { + const router = useRouter() + const [imagePreview, setImagePreview] = useState('') + const [nickname, setNickname] = useState('') + const [isValidate, setIsValidate] = useState(false) + const [errorMessage, setErrorMessage] = useState('') + const [isClicked, setIsClicked] = useState(false) + + const validateInput = (value: string) => { + setNickname(value) + + if (value.includes(' ')) { + setIsValidate(false) + setErrorMessage('공백은 입력할 수 없습니다.') + return + } + if (/[`~!@#$%^&*|\\'"/?]/gi.test(value)) { + setIsValidate(false) + setErrorMessage('특수 문자는 입력할 수 없습니다.') + return + } + if (value.length < 2 || value.length > 10) { + setIsValidate(false) + setErrorMessage('2자 이상 10자 이하로 입력해주세요.') + return + } + setIsValidate(true) + setErrorMessage('') + } + + const handleImageUpload = (e: React.ChangeEvent) => { + const file = e.target.files?.[0] + + if (file) { + const previewUrl = URL.createObjectURL(file) + setImagePreview(previewUrl) + } + } + + const handleSubmit = () => { + setIsClicked(false) + router.back() + } + + return ( +
+
+ + 정보 수정 + + + +
+ + 닉네임 + +
+ validateInput(e.target.value)} + className='w-[200px] inline-block border-b text-[13px] border-gray-300' + placeholder='닉네임을 입력해주세요.' + /> + {!isValidate && ( + + {errorMessage} + + )} +
+
+
+ +
+ +
+ 로그아웃 + 회원탈퇴 +
+
+
+ ) +} diff --git a/src/app/users/setting/page.tsx b/src/app/users/setting/page.tsx deleted file mode 100644 index c174313..0000000 --- a/src/app/users/setting/page.tsx +++ /dev/null @@ -1,3 +0,0 @@ -export default function Page() { - return null -}