-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## 1️⃣ 작업 내용 Summary 일반유저 및 자치기구 내정보 api 연동 자치기구 정보수정 api 연동 - resolved #399 ## 2️⃣ 추후 작업할 내용 - 마이페이지 작성글보기 api 연동 ## 3️⃣ 체크리스트 - [x] `develop` 브랜치의 최신 코드를 `pull` 받았나요?
- Loading branch information
Showing
14 changed files
with
309 additions
and
235 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { getUserProfileResponse } from '@/types/apis/get'; | ||
import axios, { AxiosResponse } from 'axios'; | ||
|
||
export const getUserProfile = async () => { | ||
const accessToken = localStorage.getItem('accessToken'); | ||
const response: AxiosResponse<getUserProfileResponse> = await axios({ | ||
baseURL: 'http://13.125.101.7:8080', | ||
url: '/users/mypage', | ||
method: 'get', | ||
headers: { | ||
Authorization: `Bearer ${accessToken}`, | ||
}, | ||
}); | ||
return response.data; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { clientAuth } from './client'; | ||
import { patchUserProfileResponse } from '@/types/apis/get'; | ||
import { AxiosResponse } from 'axios'; | ||
|
||
export const patchUserProfile = async (data: { | ||
nickname: string; | ||
currentPassword: string; | ||
newPassword: string; | ||
confirmNewPassword: string; | ||
}) => { | ||
const accessToken = localStorage.getItem('accessToken'); | ||
const response: AxiosResponse<patchUserProfileResponse> = await clientAuth({ | ||
baseURL: 'http://13.125.101.7:8080', | ||
url: '/users/mypage', | ||
method: 'PATCH', | ||
headers: { | ||
Authorization: `Bearer ${accessToken}`, | ||
}, | ||
data, | ||
}); | ||
return response.data; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,58 @@ | ||
import { UserContainerProps } from '../types'; | ||
import { useGetUserProfile } from '../profile/hooks/useGetUserProfile'; | ||
|
||
export default function UserContainer() { | ||
const { data, isLoading, error } = useGetUserProfile(); | ||
const userData = data?.data; | ||
|
||
if (isLoading) console.log('loading'); | ||
if (error) console.log('error : ', error); | ||
|
||
export default function UserContainer({ isAssociation, userInfo, associationInfo }: UserContainerProps) { | ||
return ( | ||
// props ? api ? | ||
<> | ||
{isAssociation && associationInfo ? ( | ||
<div className="mb-16 ml-16 mr-20 mt-16 flex flex-col items-center rounded-lg border-2 border-[#D9D9D9] bg-white p-10 py-8 sm:flex-col"> | ||
<img className="mr-8 h-24 w-24" src="/image/mypage/profile_img.png" alt="profile_default_img" /> | ||
<div> | ||
<div className="mb-2"> | ||
<span className="text-lg font-bold">{associationInfo.nickname}</span> | ||
<div className="w-full px-4"> | ||
{userData?.isUnion && userData ? ( | ||
<div className="mx-auto mb-10 mt-16 flex flex-row items-center rounded-2xl border-2 border-[#D9D9D9] bg-white px-10 py-8 xs:mx-[20%] xs:flex-col xs:pb-4 sm:mx-[22%] sm:flex-col md:mx-10 md:py-6 lg:mx-10 xl:mx-10 xxl:mx-10"> | ||
<img | ||
className="mr-8 h-24 w-24 xs:mb-4 xs:mr-0 xs:h-20 xs:w-20 sm:mr-0 md:mr-6" | ||
src="/image/mypage/profile_img.png" | ||
alt="profile_default_img" | ||
/> | ||
<div className="mb-4"> | ||
<div className="mb-2 flex items-center xs:justify-center sm:mt-6 sm:justify-center md:mt-6"> | ||
<span className="text-lg font-bold">{userData.nickname}</span> | ||
</div> | ||
<div> | ||
<span>{associationInfo.college} • </span> | ||
<span>{associationInfo.department}</span>ㅂ | ||
<div className="mb-1 text-sm xs:text-xs sm:mb-3 sm:text-xs md:mb-2"> | ||
<span>{userData?.memberCode}</span> | ||
{userData?.majorCode ? <span>•</span> : ''} | ||
<span>{userData?.majorCode}</span> | ||
</div> | ||
</div> | ||
</div> | ||
) : ( | ||
<div className="sm:mx-18 m-16 flex flex-row items-center rounded-2xl border-2 border-[#D9D9D9] bg-white px-10 py-8 sm:flex-col md:py-6"> | ||
<div className="mx-auto mb-10 mt-16 flex flex-row items-center rounded-2xl border-2 border-[#D9D9D9] bg-white px-10 py-8 xs:mx-[20%] xs:flex-col xs:pb-4 sm:mx-[20%] sm:flex-col md:mx-10 md:py-6 lg:mx-10 xl:mx-10 xxl:mx-10"> | ||
<img | ||
className="mr-8 h-24 w-24 sm:mr-0 md:mr-6" | ||
className="mr-8 h-24 w-24 xs:mb-4 xs:mr-0 xs:h-20 xs:w-20 sm:mr-0 md:mr-6" | ||
src="/image/mypage/profile_img.png" | ||
alt="profile_default_img" | ||
/> | ||
<div className="mb-4"> | ||
<div className="mb-2 flex items-center sm:mt-6 sm:justify-center md:mt-6"> | ||
<span className="text-lg font-bold sm:text-base">{userInfo?.name}</span> | ||
<div className="mb-2 flex items-center xs:justify-center sm:mt-6 sm:justify-center md:mt-6"> | ||
<span className="text-lg font-bold xs:text-sm sm:text-base">{userData?.name}</span> | ||
<span className="ml-1 mr-1 text-xl font-light"> | </span> | ||
<span className="text-lg font-bold sm:text-base">{userInfo?.studentId}</span> | ||
<span className="text-lg font-bold xs:m-0 xs:text-sm sm:text-base">{userData?.studentId}</span> | ||
</div> | ||
<div className="mb-1 text-sm sm:mb-3 sm:text-xs md:mb-2"> | ||
<span>{userInfo?.college} • </span> | ||
<span>{userInfo?.department} • </span> | ||
<div className="mb-1 text-sm xs:text-xs sm:mb-3 sm:text-xs md:mb-2"> | ||
<span>{userData?.memberCode}•</span> | ||
<span>{userData?.majorCode}•</span> | ||
<span>재학</span> | ||
</div> | ||
<div className="flex text-sm sm:flex-col sm:items-center sm:text-xs md:flex-col"> | ||
{/* <div className="flex text-sm xs:flex-col xs:items-center xs:text-xs sm:flex-col sm:items-center sm:text-xs md:flex-col"> | ||
<span>총학생회비 납부</span> | ||
<span className="hidden lg:block xl:block xxl:block"> • </span> | ||
<span>글로벌미디어학부 학생회비 납부</span> | ||
</div> | ||
</div> */} | ||
</div> | ||
</div> | ||
)} | ||
</> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { getUserProfile } from '@/apis/getUserProfile'; | ||
import { getUserProfileResponse } from '@/types/apis/get'; | ||
import { useQuery, UseQueryResult } from '@tanstack/react-query'; | ||
import { AxiosError } from 'axios'; | ||
|
||
export const useGetUserProfile = (): UseQueryResult<getUserProfileResponse, AxiosError> => { | ||
return useQuery<getUserProfileResponse, AxiosError>({ | ||
queryKey: ['get-user-profile'], | ||
queryFn: getUserProfile, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { useMutation, useQueryClient } from '@tanstack/react-query'; | ||
import { patchUserProfile } from '@/apis/patchUserProfile'; | ||
import { AxiosError } from 'axios'; | ||
import { patchUserProfileRequest, patchUserProfileResponse } from '@/types/apis/get'; | ||
|
||
export const usePatchUserProfile = () => { | ||
const queryClient = useQueryClient(); | ||
|
||
return useMutation<patchUserProfileResponse, AxiosError, patchUserProfileRequest>({ | ||
mutationFn: async (patchData) => { | ||
return await patchUserProfile(patchData); | ||
}, | ||
onSuccess: () => { | ||
queryClient.invalidateQueries({ queryKey: ['get-user-profile'] }); | ||
}, | ||
// onError: (error) => { | ||
// console.error('정보 수정 실패:', error.response?.data); | ||
// }, | ||
}); | ||
}; |
Oops, something went wrong.