Skip to content
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

[PR] 유저 프로필 #62

Merged
merged 5 commits into from
May 17, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 49 additions & 18 deletions src/components/mypage/profileTable/index.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,63 @@
import * as S from './styles.ts';

import { useEffect } from 'react';
import * as S from './styles';
import { getUserInfo, putUser } from '@/apis/user';
import { User } from '@/types/auth';
import { UserCircle } from '@/components/shared';
import { SubmitHandler, useForm } from 'react-hook-form';
interface UserModify extends Omit<User, 'email'> {}
const ProfileTable = () => {
const { register, handleSubmit, reset } = useForm<UserModify>();

useEffect(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기 왜 react-query 안 쓰셨죠? get해오는 부분 같은데 이부분은 수정이 이루어졌으면 합니다.

const fetchUserData = async () => {
const userData = await getUserInfo();
reset(userData);
};
fetchUserData();
}, []);

const onSubmit: SubmitHandler<UserModify> = async (data: UserModify) => {
try {
await putUser(data);
alert('수정 완료');
} catch (error) {
alert('수정 실패');
}
};

return (
<S.Container>
<S.Table>
<S.Thead>
<S.Th height={250}>프로필 사진</S.Th>
<S.Th height={100}>별명</S.Th>
<S.Th height={100}>깃허브</S.Th>
<S.Th height={100}>블로그</S.Th>
<tr>
<S.Th height={250}>프로필 사진</S.Th>
<S.Th height={100}>별명</S.Th>
<S.Th height={100}>깃허브</S.Th>
<S.Th height={100}>블로그</S.Th>
</tr>
</S.Thead>
<S.Tbody>
<S.Td height={250}>프로필 사진</S.Td>
<S.Td height={100}>
<S.Input />
</S.Td>
<S.Td height={100}>
<S.Input />
</S.Td>
<S.Td height={100}>
<S.Input />
</S.Td>
<tr>
<S.Td height={250}>
<UserCircle size={150} />
</S.Td>
<S.Td height={100}>
<S.Input {...register('nickname')} />
</S.Td>
<S.Td height={100}>
<S.Input {...register('github')} />
</S.Td>
<S.Td height={100}>
<S.Input {...register('blog')} />
</S.Td>
</tr>
</S.Tbody>
</S.Table>
<S.Block>
<S.Button>적용</S.Button>
<S.Button>취소</S.Button>
<S.Button onClick={handleSubmit(onSubmit)}>적용</S.Button>
<S.Button onClick={() => reset()}>취소</S.Button>
</S.Block>
<div></div>
</S.Container>
);
};
Expand Down