Skip to content

Commit

Permalink
Merge pull request #93 from BCSDLab/feature/#84
Browse files Browse the repository at this point in the history
[USER] 마이페이지 구현
  • Loading branch information
kimeodml authored Oct 16, 2023
2 parents da973aa + 0690792 commit 5308a73
Show file tree
Hide file tree
Showing 37 changed files with 1,261 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import Notice from 'pages/Notice';
import KakaoLogin from 'pages/Auth/OAuth/KakaoLogin';
import NaverLogin from 'pages/Auth/OAuth/NaverLogin';
import GoogleLogin from 'pages/Auth/OAuth/GoogleLogin';
import MyPage from 'pages/MyPage';
import NotFoundPage from 'pages/Search/components/NotFoundPage';
import FollowProfile from 'pages/Follow/components/FollowProfile';

Expand All @@ -46,6 +47,7 @@ export default function App(): JSX.Element {
<Route path="/friend-list/:id" element={<FollowProfile />} />
</Route>
<Route path="/withdrawal" element={<Withdrawal />} />
<Route path="/profile" element={<MyPage />} />
<Route path="/post/:name" element={<Post />} />
</Route>
<Route element={<AuthRoute needAuth={false} redirectRoute="/" />}>
Expand Down
57 changes: 57 additions & 0 deletions src/api/mypage/entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { User } from 'api/user/entity';

export interface Shop {
shopId: number,
placeId: string,
name: string,
category: string,
}

export interface ReviewedShopsResponse {
content: Shop[],
totalPages: number,
totalElements: number
}

export interface Review {
id: number,
content: string,
rate: number,
createdAt: string
}

export interface ReviewsResponse {
content: Review[]
}

export type Scrap = {
placeId: string,
category: string,
name: string,
photo: string,
ratingCount: number,
scrapId: number,
totalRating: number
};
export interface ScrapResponse {
content: Scrap[],
totalPages: number,
totalElements: number
}

export interface PatchProfileImageResponse {
profileImage: {
id: number,
originalName: string,
path: string,
url: string
}
}

export interface PatchNicknameResponse {
nickname: string
}

export interface FollowersResponse {
content: User[],
}
29 changes: 29 additions & 0 deletions src/api/mypage/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import followApi from 'api/follow/followApiClient';
import {
FollowersResponse,
PatchNicknameResponse,
PatchProfileImageResponse, ReviewedShopsResponse, ReviewsResponse, ScrapResponse,
} from './entity';
import myPageApi from './mypageApiClient';

export const getReviewedShops = async () => myPageApi.get<ReviewedShopsResponse>('/review/shops');

export const getReviews = async (placeId:string) => myPageApi.get<ReviewsResponse>(`/review/shop/${placeId}`);

export const getScraps = async (pageParam:number) => myPageApi.get<ScrapResponse>(`/scraps?cursor=${pageParam}`);

export const patchProfileImage = async (image:FormData | null) => myPageApi.patch<PatchProfileImageResponse>('/user/profile', image, {
headers: {
'Content-Type': 'multipart/form-data',
},
});

export const patchDefaultImage = async () => myPageApi.patch<PatchProfileImageResponse>('/user/profile', {
headers: {
'Content-Type': 'multipart/form-data',
},
});

export const patchNickname = async (nickname:string) => myPageApi.patch<PatchNicknameResponse>('/user/me', { nickname });

export const getFollwers = async () => followApi.get<FollowersResponse>('/follow/followers');
18 changes: 18 additions & 0 deletions src/api/mypage/mypageApiClient.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { API_PATH } from 'config/constants';
import axios from 'axios';

const myPageApi = axios.create({
baseURL: `${API_PATH}`,
timeout: 2000,
});

myPageApi.interceptors.request.use(
(config) => {
const accessToken = sessionStorage.getItem('accessToken');
// eslint-disable-next-line no-param-reassign
if (config.headers && accessToken) config.headers.Authorization = `Bearer ${accessToken}`;
return config;
},
);

export default myPageApi;
6 changes: 6 additions & 0 deletions src/assets/svg/mypage/checkerboard-filled.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions src/assets/svg/mypage/checkerboard.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/svg/mypage/close-arrow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/assets/svg/mypage/hamberger-filled.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/assets/svg/mypage/hamberger.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 5308a73

Please sign in to comment.