diff --git a/src/components/board/BoardList.tsx b/src/components/board/BoardList.tsx index b03dc4c..3130849 100644 --- a/src/components/board/BoardList.tsx +++ b/src/components/board/BoardList.tsx @@ -63,6 +63,7 @@ function BoardList(): JSX.Element { useEffect(() => { fetchBoardList(currentPage); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [currentPage, selectedCategory, status, keyword, search]); diff --git a/src/components/board/reply/Reply.tsx b/src/components/board/reply/Reply.tsx index 5090d6d..ce2ad07 100644 --- a/src/components/board/reply/Reply.tsx +++ b/src/components/board/reply/Reply.tsx @@ -36,6 +36,7 @@ const Reply = () => { useEffect(() => { GetReplyList(); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [refresh]) diff --git a/src/components/member/Signup.tsx b/src/components/member/Signup.tsx index 3eb3d1c..70fdce5 100644 --- a/src/components/member/Signup.tsx +++ b/src/components/member/Signup.tsx @@ -151,7 +151,7 @@ const Signup = () => { + sx={{ backgroundColor: '#969696', boxShadow: 'none', paddingY: 1 }} >중복확인 비밀번호 @@ -225,7 +225,7 @@ const Signup = () => { + sx={{ backgroundColor: '#969696', boxShadow: 'none', paddingY: 1 }} >중복확인 diff --git a/src/components/member/mypage/EditNick.tsx b/src/components/member/mypage/EditNick.tsx index 222686a..c25404d 100644 --- a/src/components/member/mypage/EditNick.tsx +++ b/src/components/member/mypage/EditNick.tsx @@ -1,15 +1,16 @@ -import { useState } from "react"; +import { useEffect, useState } from "react"; import { useForm } from "react-hook-form"; import { useNavigate } from "react-router-dom"; import api from "lib/api"; import useNicknameChecker from "lib/useNicknameChecker"; -import { Container, Typography, Grid, TextField, Box, Button, Card } from '@mui/material'; +import { Container, Typography, Grid, TextField, Box, Button, Card, Divider } from '@mui/material'; interface FormData { nickname: string; } const EditNick = () => { + const [nowNick, setNowNick] = useState(String || null) const { register, handleSubmit, formState: { errors } } = useForm({ mode: 'all' }); const navigate = useNavigate(); @@ -43,8 +44,16 @@ const EditNick = () => { } }; + useEffect(() => { + getNick(); + }, [setNowNick]) - + const getNick = async () => { + const result = await api.get("member/myInfo") + setNowNick(result.data.data.nickname) + console.log("nowNick:" + result.data.data.nickname) + } + return ( <> @@ -59,32 +68,28 @@ const EditNick = () => { padding: 4, backgroundColor: 'white' }} > - + 닉네임 변경 - + 현재 닉네임 - - + + {nowNick} + - 새 닉네임 + + + + + 바꿀 닉네임 - + { + sx={{ backgroundColor: '#969696', boxShadow: 'none' }} >중복확인 + + + + + diff --git a/src/components/member/mypage/EditPw.tsx b/src/components/member/mypage/EditPw.tsx index ea7fa4b..9607445 100644 --- a/src/components/member/mypage/EditPw.tsx +++ b/src/components/member/mypage/EditPw.tsx @@ -2,7 +2,7 @@ import { useRef } from "react"; import { useForm } from "react-hook-form"; import { useNavigate } from "react-router-dom"; import api from "lib/api"; -import { Container, Typography, Grid, TextField, Box, Button, Card } from '@mui/material'; +import { Container, Typography, Grid, TextField, Box, Button, Card, Divider } from '@mui/material'; // components interface FormData { @@ -52,10 +52,11 @@ const EditPw = () => { - + + 현재 비밀번호 - + { /> - 새 비밀번호 + - + + 바꿀 비밀번호 + + { helperText={errors.updatePW?.message} /> - - 새 비밀번호 확인 + - + + 비밀번호 확인 + + { helperText={errors.passwordCheck?.message} /> + + + + + + + + + + + :
Loading
} + + ) + +} + + +export default MyInfo; + diff --git a/src/components/pet/PetEdit.tsx b/src/components/pet/PetEdit.tsx index c81ba29..733327b 100644 --- a/src/components/pet/PetEdit.tsx +++ b/src/components/pet/PetEdit.tsx @@ -4,6 +4,7 @@ import api from "lib/api"; import PetImgUpload from "./PetImgUpload"; import { uploadS3 } from "lib/s3"; import { Container, Typography, Grid, TextField, Box, Button, Card } from '@mui/material'; +import { useNavigate } from "react-router-dom"; interface PetFormData { petname: string; @@ -26,12 +27,14 @@ const minutes = String(currentDate.getMinutes()).padStart(2, '0'); export const PetEdit = () => { + const navigate = useNavigate(); const [petData, setPetData] = useState(null); const [formattedDate, setFormattedDate] = useState(''); - const { register, handleSubmit, formState: { errors } } = useForm({ mode: 'all', - defaultValues: petData - }); + const { register, handleSubmit, formState: { errors } } = useForm({ + mode: 'all', + defaultValues: petData + }); const [imageFile, setImageFile] = useState(null); const [fileName, setFileName] = useState(null); const [fileType, setFileType] = useState(null); @@ -48,11 +51,11 @@ export const PetEdit = () => { formData.append('name', fileName2); formData.append('type', fileType); - console.log("formData "+ formData.get('file')); + console.log("formData " + formData.get('file')); //s3에 파일 업로드 및 링크 반환 const petUrl = await uploadS3(formData) - console.log("peturl "+petUrl) + console.log("peturl " + petUrl) data.petUrl = petUrl; api.put(`pet/edit/${petData.petId}`, JSON.stringify(data)) @@ -69,177 +72,179 @@ export const PetEdit = () => { } - useEffect(()=>{ + useEffect(() => { getPetData() - },[]) - - //펫 정보 받아오는 함수 - const getPetData= () => { + }, []) + + //펫 정보 받아오는 함수 + const getPetData = () => { api.get("pet/petinfo") - .then((res)=>{ - const petData: PetFormData = { - ...res.data.data - } - setPetData(petData); - setFormattedDate(new Date(petData.firstmet).toISOString().split('T')[0]); + .then((res) => { + const petData: PetFormData = { + ...res.data.data + } + setPetData(petData); + setFormattedDate(new Date(petData.firstmet).toISOString().split('T')[0]); - }).catch((error)=>{ + }).catch((error) => { + alert('펫을 먼저 등록해주세요!') + navigate("/pet/petform") - console.log(error.message) - }) - } + console.log(error.message) + }) + } return ( <> - {petData ? - <> - - - - 펫 수정 - - - - - - - - - - - - 이름 - - - - - - - 나이 - - - - - - - 종류 - - - - - - 몸무게 - - - - - - - 처음 만난 날 - - - - - - - - - - -: <>} + + 펫 수정 + + + + + + + + + + + + 이름 + + + + + + + 나이 + + + + + + + 종류 + + + + + + 몸무게 + + + + + + + 처음 만난 날 + + + + + + + + + + + : <>} ) } -; + ; diff --git a/src/components/pet/PetImgUpload.tsx b/src/components/pet/PetImgUpload.tsx index b080b99..649000f 100644 --- a/src/components/pet/PetImgUpload.tsx +++ b/src/components/pet/PetImgUpload.tsx @@ -41,7 +41,7 @@ export default function PetImgUpload({ setImageFile, setFilename, setFileType, n aria-label="upload picture" component="span" > - + diff --git a/src/layouts/dashboard/header/AccountPopover.js b/src/layouts/dashboard/header/AccountPopover.js index 25e5e2d..8b96678 100644 --- a/src/layouts/dashboard/header/AccountPopover.js +++ b/src/layouts/dashboard/header/AccountPopover.js @@ -10,15 +10,18 @@ import { Link } from 'react-router-dom'; import { atom, useRecoilState } from 'recoil'; export const petState = atom({ - key:'petImg', - default:'' + key: 'petImg', + default: '' }) // ---------------------------------------------------------------------- export default function AccountPopover({ isLoggedIn }) { - const [open, setOpen] = useState(null); + const [open, setOpen] = useState(null); + const [email, setEmail] = useState(''); + const [nick, setNick] = useState('') + const handleOpen = (event) => { setOpen(event.currentTarget); @@ -32,30 +35,39 @@ export default function AccountPopover({ isLoggedIn }) { useEffect(() => { handlePetUrl() + getMemberInfo() // eslint-disable-next-line react-hooks/exhaustive-deps - }, [petImg]) + }, [petImg, nick]) const settings = isLoggedIn - ? [ - { label: "마이 페이지", href: "/member/mypage" }, - { label: "펫 등록", href: "/pet/petform" }, - { label: "펫 수정", href: "/pet/edit" }, - { label: "로그아웃", href: "/logout" } - ] - : [{ label: "로그인", href: "/login" }, - { label: "회원가입", href: "/signup" } - ]; - + ? [ + { label: "마이 페이지", href: "/member/myInfo" }, + { label: "펫 등록", href: "/pet/petform" }, + { label: "펫 수정", href: "/pet/edit" }, + { label: "로그아웃", href: "/logout" } + ] + : [{ label: "로그인", href: "/login" }, + { label: "회원가입", href: "/signup" } + ]; + //헤더 아바타에 들어갈 펫 이미지 const handlePetUrl = async () => { if (Cookies.get("key")) { const result = await api.get("pet/petinfo"); - setPetImg(result.data.data.petUrl); + if (result) { + setPetImg(result.data.data.petUrl); + } + } } -} - console.log("isLoggedIn"+isLoggedIn) + console.log("isLoggedIn" + isLoggedIn) + const getMemberInfo = async () => { + const result = await api.get("member/myInfo") + setNick(result.data.data.nickname) + setEmail(result.data.data.email) + console.log("nowNick:" + result.data.data.nickname) + } return ( @@ -77,7 +89,7 @@ export default function AccountPopover({ isLoggedIn }) { }), }} > - + - {account.displayName} + {nick} 님 - {account.email} + {email} diff --git a/src/layouts/dashboard/nav/navList.tsx b/src/layouts/dashboard/nav/navList.tsx index a40c97d..8f3995e 100644 --- a/src/layouts/dashboard/nav/navList.tsx +++ b/src/layouts/dashboard/nav/navList.tsx @@ -45,7 +45,7 @@ export default function NavList() { - } plSize={4} /> + } plSize={4} /> } plSize={4} /> } plSize={4} /> @@ -79,7 +79,7 @@ const CustomListItem = ({ href, primaryText, icon, plSize }: {icon} - + ); }; diff --git a/src/routes.js b/src/routes.js index 105468e..675aa24 100644 --- a/src/routes.js +++ b/src/routes.js @@ -19,6 +19,7 @@ import EditNick from 'components/member/mypage/EditNick'; import EditPw from 'components/member/mypage/EditPw'; import PetEditPage from 'pages/PetEditPage'; import DiaryPage from './pages/DiaryPage'; +import MyInfo from 'components/member/mypage/MyInfo'; import { PrivateRoute } from 'components/member/PrIvateRoute'; // ---------------------------------------------------------------------- @@ -79,6 +80,7 @@ export default function Router() { children: [ {element: , path:'editNick' }, {element: , path:'editPw' }, + {element: , path:'myInfo' }, ] }, {