diff --git a/src/widgets/SettingUser/SetProfile.tsx b/src/widgets/SettingUser/SetProfile.tsx
index 4b3f35b..7da13ac 100644
--- a/src/widgets/SettingUser/SetProfile.tsx
+++ b/src/widgets/SettingUser/SetProfile.tsx
@@ -1,17 +1,125 @@
import styles from './SetProfile.module.scss';
-import { ProfileForm, profileFormConfig } from '@/features/auth';
-import { Button } from '@/shared/ui';
+import type { PortfolioFormValues } from '@/features/auth';
+import {
+ handleImageUpload,
+ JOB_CATEGORIES,
+ JOB_SUB_CATEGORY,
+ ProfileForm,
+ profileFormConfig,
+} from '@/features/auth';
+import type { UserDataState } from '@/features/user/model/user.store';
+import { useUserStore } from '@/features/user/model/user.store';
+import type { EditUserDTO, PutUserDTO } from '@/features/user/user.dto';
+import { useEditUser, useGetUserEdit } from '@/features/user/user.hook';
+import { Button, customConfirm } from '@/shared/ui';
+
+interface SetProfileProps {
+ userData: UserDataState;
+}
+
+export const SetProfile = ({ userData }: SetProfileProps) => {
+ const { updateUserData } = useUserStore(state => state.actions);
+ const { data, isLoading } = useGetUserEdit(userData.userId);
+ const { mutate: editUser } = useEditUser(userData.userId);
+
+ const convertDataType = (data: EditUserDTO): PortfolioFormValues => {
+ const { socials, majorJobGroup, minorJobGroup, ...rest } = data;
+
+ const majorOption = {
+ value: majorJobGroup,
+ label:
+ JOB_CATEGORIES.find(majorCatergory => majorCatergory.value === majorJobGroup)?.label ??
+ '알 수 없음',
+ };
+
+ const minorOption = {
+ value: minorJobGroup,
+ label:
+ JOB_SUB_CATEGORY.find(minorCategory => minorCategory.value === minorJobGroup)?.label ??
+ '알 수 없음',
+ };
+ return {
+ name: rest.name || '',
+ email: rest.email || '',
+ briefIntro: rest.briefIntro || '',
+ imageUrl: {
+ url: rest.imageUrl || '',
+ file: null,
+ },
+ portfolioLink: rest.portfolioLink || '',
+ jobTitle: rest.jobTitle || '',
+ division: rest.division || '',
+ majorJobGroup: majorOption,
+ minorJobGroup: minorOption,
+ url: socials.map(link => ({ value: link })),
+ };
+ };
+
+ const handleSubmit = async (data: PortfolioFormValues) => {
+ const profileImageUrl = (await handleImageUpload(data.imageUrl)) || data.imageUrl.url;
+
+ const putUserData: PutUserDTO = {
+ name: data.name,
+ briefIntro: data.briefIntro,
+ portfolioLink: data.portfolioLink,
+ jobTitle: data.jobTitle,
+ division: data.division,
+ imageUrl: profileImageUrl,
+ majorJobGroup: data.majorJobGroup?.value || '',
+ minorJobGroup: data.minorJobGroup?.value || '',
+ socials: data.url.map(link => link.value),
+ s3StoredImageUrls: [],
+ };
+
+ console.log(putUserData);
+
+ editUser(
+ {
+ data: putUserData,
+ },
+ {
+ onSuccess: () => {
+ if (userData.role === 'JUST_NEWBIE' && data.portfolioLink) {
+ updateUserData({
+ name: data.name,
+ imageUrl: profileImageUrl,
+ role: 'OLD_NEWBIE',
+ });
+ }
+
+ void customConfirm({
+ title: '성공',
+ text: '유저 프로필를 수정하였습니다.',
+ icon: 'success',
+ showCancelButton: false,
+ });
+ },
+ onError: () => {
+ void customConfirm({
+ title: '오류',
+ text: '유저 프로필 수정에 실패하였습니다. 다시 시도해주세요. ',
+ icon: 'error',
+ showCancelButton: false,
+ });
+ },
+ },
+ );
+ };
-export const SetProfile = () => {
return (
-
{
- console.log(data);
- }}
- />
+ {isLoading ? (
+ <>>
+ ) : (
+ data && (
+
+ )
+ )}
From 7484dd5bdb352bcb38200504c664d5e27418ab8d Mon Sep 17 00:00:00 2001
From: Cho-heejung <66050038+he2e2@users.noreply.github.com>
Date: Fri, 6 Dec 2024 16:27:34 +0900
Subject: [PATCH 4/4] =?UTF-8?q?[Feat]=20=EC=95=84=EC=B9=B4=EC=9D=B4?=
=?UTF-8?q?=EB=B8=8C=20=EC=B0=A8=ED=8A=B8=20=EB=B0=8F=20=EB=A9=94=EC=9D=B8?=
=?UTF-8?q?=20=EC=95=84=EC=B9=B4=EC=9D=B4=EB=B8=8C=20=EC=97=B0=EA=B2=B0=20?=
=?UTF-8?q?(#94)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* feat: 아카이브 차트 연결
* feat: 인기 아카이브 훅 작성
* feat: 메인 페이지 인기 아카이브 연결
* feat: 헤더 로그아웃 버튼 /user 이동 플로우로 변경
* design: 메인 페이지 transfrom 속성 세분화
---
src/features/archive/archive.api.ts | 3 +
src/features/archive/archive.hook.ts | 7 ++
src/features/user/ui/UserProfileInfo.tsx | 7 +-
src/pages/UserPage/UserPage.module.scss | 1 +
.../Layout/ui/Header/Header.module.scss | 8 +++
src/widgets/Layout/ui/Header/Header.tsx | 23 ++----
.../MainContents/MainContents.module.scss | 2 +
.../MainGridItem/MainGridItem.module.scss | 50 ++++++++++++-
src/widgets/MainGridItem/MainGridItem.tsx | 29 +++-----
src/widgets/MenuModal/MenuModal.module.scss | 8 +++
src/widgets/MenuModal/MenuModal.tsx | 15 ++--
src/widgets/UserContents/UserContents.tsx | 71 ++++++++++---------
12 files changed, 133 insertions(+), 91 deletions(-)
diff --git a/src/features/archive/archive.api.ts b/src/features/archive/archive.api.ts
index f65a12e..2bc4531 100644
--- a/src/features/archive/archive.api.ts
+++ b/src/features/archive/archive.api.ts
@@ -86,3 +86,6 @@ export const getMyArchiveList = () =>
api.get('/archive/me').then(res => res.data);
export const patchArchiveOrder = (data: PatchArchiveOrderDTO) => api.patch('/archive', data);
+
+export const getPopularArchive = () =>
+ api.get('/archive/main').then(res => res.data);
diff --git a/src/features/archive/archive.hook.ts b/src/features/archive/archive.hook.ts
index 1878419..c480b40 100644
--- a/src/features/archive/archive.hook.ts
+++ b/src/features/archive/archive.hook.ts
@@ -17,6 +17,7 @@ import {
putComment,
getMyArchiveList,
patchArchiveOrder,
+ getPopularArchive,
} from './archive.api';
import type {
BaseArchiveDTO,
@@ -62,6 +63,12 @@ export const useArchive = (archiveId: number) =>
queryFn: () => getArchive(archiveId),
});
+export const usePopularArchive = () =>
+ useQuery({
+ queryKey: ['/archive/main'],
+ queryFn: () => getPopularArchive(),
+ });
+
export const useComments = (archiveId: number) => {
return useCustomInfiniteQuery(
['/archive', archiveId, 'comment'],
diff --git a/src/features/user/ui/UserProfileInfo.tsx b/src/features/user/ui/UserProfileInfo.tsx
index bd00c84..f8c3c9d 100644
--- a/src/features/user/ui/UserProfileInfo.tsx
+++ b/src/features/user/ui/UserProfileInfo.tsx
@@ -15,12 +15,7 @@ export const UserProfileInfo = () => {
채승규
- {
- // TODO : 내 정보일 경우 /my로 이동
- }}
- />
+ {}} />
프론트엔드 개발자
diff --git a/src/pages/UserPage/UserPage.module.scss b/src/pages/UserPage/UserPage.module.scss
index 210ffa3..d20bc16 100644
--- a/src/pages/UserPage/UserPage.module.scss
+++ b/src/pages/UserPage/UserPage.module.scss
@@ -46,6 +46,7 @@ $colors: (
@media (width <= 768px) {
flex-direction: column;
row-gap: 2rem;
+ align-items: center;
padding: 0 2rem;
}
diff --git a/src/widgets/Layout/ui/Header/Header.module.scss b/src/widgets/Layout/ui/Header/Header.module.scss
index 6de34ad..a1b256d 100644
--- a/src/widgets/Layout/ui/Header/Header.module.scss
+++ b/src/widgets/Layout/ui/Header/Header.module.scss
@@ -133,3 +133,11 @@
display: flex;
min-width: 320px;
}
+
+.userProfile {
+ width: 2rem;
+ aspect-ratio: 1/1;
+ object-fit: cover;
+ border: 1px solid #cfcfcf;
+ border-radius: 4px;
+}
diff --git a/src/widgets/Layout/ui/Header/Header.tsx b/src/widgets/Layout/ui/Header/Header.tsx
index 31067b4..51166fb 100644
--- a/src/widgets/Layout/ui/Header/Header.tsx
+++ b/src/widgets/Layout/ui/Header/Header.tsx
@@ -11,7 +11,6 @@ import { NAV_LINKS } from '../../constants';
//assets
import { SearchBar } from '@/features';
-import { logout } from '@/features/auth/auth.api';
import { useUserStore } from '@/features/user/model/user.store';
import Logo from '@/shared/assets/paletteLogo.svg?react';
import { useModalStore } from '@/shared/model/modalStore';
@@ -24,7 +23,7 @@ export const Header = () => {
const { pathname } = useLocation();
const navigate = useNavigate();
const open = useModalStore(state => state.actions.open);
- const { userData, actions } = useUserStore(
+ const { userData } = useUserStore(
useShallow(state => ({
userData: state.userData,
actions: state.actions,
@@ -33,17 +32,6 @@ export const Header = () => {
const [isMobile, setIsMobile] = useState(false);
const [menuOpen, setMenuOpen] = useState(false);
- const logoutHandler = async () => {
- navigate('/');
- await logout();
- actions.setUserData(null);
- await customConfirm({
- title: '로그아웃',
- text: '로그아웃 되었습니다.',
- icon: 'info',
- showCancelButton: false,
- });
- };
const [isSearch, setIsSearch] = useState(false);
const [isNotice, setIsNotice] = useState(false);
@@ -109,7 +97,6 @@ export const Header = () => {
isOpen={menuOpen}
isUserData={userData ? true : false}
onClose={setMenuOpen}
- onLogout={logoutHandler}
/>
)}{' '}
>
@@ -155,13 +142,13 @@ export const Header = () => {
}}
/>
{userData ? (
-
+

+
) : (