diff --git a/client/src/App.tsx b/client/src/App.tsx index ca35c189..8dce43c4 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -3,7 +3,7 @@ import MainPage from './pages/Main/MainPage'; import { Container } from '@mui/material'; import SignUp from './pages/SignUp/SignUp'; import SignIn from './pages/SignIn/SignIn'; - +import MyPage from './pages/MyPage/MyPage'; import Header from './components/Header/Header'; import Questions from './pages/Questions/Questions'; import WordPage from './pages/Word/WordPage'; @@ -32,6 +32,7 @@ export default function App() { } /> } /> } /> + } /> ); diff --git a/client/src/pages/MyPage/MyPage.tsx b/client/src/pages/MyPage/MyPage.tsx new file mode 100644 index 00000000..ce32a308 --- /dev/null +++ b/client/src/pages/MyPage/MyPage.tsx @@ -0,0 +1,213 @@ +import React, { useEffect, useState } from 'react'; +import Box from '@mui/material/Box'; +import Card from '@mui/material/Card'; +import CardContent from '@mui/material/CardContent'; +import Button from '@mui/material/Button'; +import Typography from '@mui/material/Typography'; +import { useQuery } from '@tanstack/react-query'; +import api from '../../common/utils/api'; +import TextField from '@mui/material/TextField'; +import { AxiosError } from 'axios'; +import { createTheme, ThemeProvider } from '@mui/material/styles'; +import { useAppSelector } from '../../redux/hooks'; + +const defaultTheme = createTheme({ + components: { + MuiFormControlLabel: { + styleOverrides: { + label: { + fontSize: 14 + } + } + } + } +}); + +const centerStyle = { + display: 'flex', + justifyContent: 'center', + marginTop: '70px' +}; + +const topMargin = { + display: 'flex', + justifyContent: 'center', + alignItems: 'center', + marginTop: '20px' +}; + +export default function MyPage() { + const userInfo = useAppSelector((state) => state.user); + const { isLoading, error, data } = useQuery({ + queryKey: ['username', userInfo.userId], + queryFn: () => + api(`/members/${userInfo.userId}`, 'get').then(({ data }) => data.data) + }); + if (isLoading) + return ( + theme.shadows[3] + }} + > + {' '} + 로딩중...{' '} + + ); + + if (error) { + const myError = error as AxiosError; + return ( + theme.shadows[3] + }} + > + {' '} + 에러: {myError.message}{' '} + + ); + } + const [user, setUser] = useState(false); + const [editedUser, setEditedUser] = useState({ + nickname: data.nickname, + username: data.username, + email: data.email + }); + + const handleEditClick = () => { + setUser(true); + }; + + const handleReadClick = () => { + setUser(false); + }; + + const handleFieldChange = + (fieldName: string) => (event: React.ChangeEvent) => { + setEditedUser({ + ...editedUser, + [fieldName]: event.target.value + }); + }; + + return ( + +
+ + + + {data.username} + + 2023년 8월 28일 가입 + + +
+ + 닉네임 + + +
+ +
+ + 아이디 + + +
+
+ + 이메일 + + +
+
+
+ {!user && ( + + )} + {user && ( + + )} + + +
+
+
+
+
+ ); +}