Skip to content

Commit 5802747

Browse files
committed
feat: wip (#develop)
1 parent 91cb6b5 commit 5802747

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1566
-3621
lines changed

pnpm-lock.yaml

Lines changed: 45 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

services/ahhachul.com/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"@lexical/react": "^0.23.1",
3838
"@lottiefiles/react-lottie-player": "^3.6.0",
3939
"@radix-ui/react-dropdown-menu": "^2.1.4",
40+
"@radix-ui/react-icons": "^1.3.2",
4041
"@stackflow/core": "^1.0.10",
4142
"@stackflow/link": "^1.4.0",
4243
"@stackflow/plugin-basic-ui": "^1.5.3",
@@ -56,6 +57,7 @@
5657
"react-lazy-load-image-component": "^1.6.3",
5758
"react-loading-skeleton": "^3.5.0",
5859
"react-swipeable": "^7.0.2",
60+
"react-use-measure": "^2.1.7",
5961
"react-zoom-pan-pinch": "3.6.0",
6062
"rxjs": "^7.8.1",
6163
"swiper": "^11.1.15",

services/ahhachul.com/src/assets/fonts/pretendard-variable.woff2 renamed to services/ahhachul.com/public/fonts/pretendard-variable.woff2

File renamed without changes.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { sleep } from '@ahhachul/utils';
2+
3+
import axiosInstance from '@/apis/fetcher';
4+
import type { ApiResponse, Comment } from '@/types';
5+
6+
export const postComment = async (data: {
7+
servicePath: string;
8+
postId: number;
9+
content: string;
10+
upperCommentId: number;
11+
isPrivate: boolean;
12+
}) => {
13+
const { servicePath, postId, content, upperCommentId, isPrivate } = data;
14+
15+
const response = await axiosInstance.post<
16+
ApiResponse<Pick<Comment, 'id' | 'upperCommentId' | 'content'>>
17+
>(`/${servicePath}/${postId}/comments`, {
18+
content,
19+
upperCommentId,
20+
isPrivate,
21+
});
22+
23+
return response.data;
24+
};
25+
26+
export const deleteComment = async (commentId: number) => {
27+
const [response] = await Promise.allSettled([
28+
axiosInstance.delete<ApiResponse<Pick<Comment, 'id'>>>(`/comments/${commentId}`),
29+
sleep(750),
30+
]);
31+
32+
if (response.status === 'rejected') {
33+
throw response.reason;
34+
}
35+
36+
if (response.status === 'fulfilled') {
37+
return response.value.data;
38+
}
39+
40+
// TODO: sentry에 로그 남기기
41+
throw new Error('Unexpected state in Promise.allSettled');
42+
};
43+
44+
export const updateComment = async (data: { content: string; commentId: number }) => {
45+
const { content, commentId } = data;
46+
const response = await axiosInstance.patch<ApiResponse<Pick<Comment, 'id' | 'content'>>>(
47+
`/comments/${commentId}`,
48+
{
49+
content,
50+
},
51+
);
52+
return response.data;
53+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export * from './auth';
22
export * from './user';
33
export * from './token';
4+
export * from './comment';
45
export * from './lostFound';
56
export * from './community';
67
export * from './complaint';

services/ahhachul.com/src/apis/request/user.ts

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import axios from 'axios';
22

33
import axiosInstance from '@/apis/fetcher';
4-
import type { ApiResponse, UserProfileResponseDto } from '@/types';
4+
import type { ApiResponse, UserFavoriteStations, UserProfileResponseDto } from '@/types';
55
import { getAccessTokenInLocalStorage } from '@/utils/localStorage';
66

77
import { BASE_URL } from '../baseUrl';
@@ -29,11 +29,33 @@ export const prefetchUserProfile = async () => {
2929
};
3030

3131
export const fetchUserFavoriteStations = async () => {
32-
const { data } = await axiosInstance.get<ApiResponse<{ id: 'hello' }>>(
32+
const { data } = await axiosInstance.get<ApiResponse<UserFavoriteStations>>(
3333
'/members/bookmarks/stations',
3434
);
3535

3636
return data;
3737
};
3838

39-
// export const createUserFavoriteStations = () => {}
39+
export const prefetchUserFavoriteStations = async () => {
40+
const accessToken = getAccessTokenInLocalStorage();
41+
42+
const { data } = await axios.get<ApiResponse<UserFavoriteStations>>(
43+
`${BASE_URL.SERVER}${API_PREFIX}/members/bookmarks/stations`,
44+
{
45+
headers: {
46+
Authorization: `Bearer ${accessToken}`,
47+
},
48+
},
49+
);
50+
51+
return data;
52+
};
53+
54+
export const createUserFavoriteStations = async (stations: any) => {
55+
const response = await axiosInstance.post<ApiResponse<UserFavoriteStations>>(
56+
'/members/bookmarks/stations',
57+
{ stations },
58+
);
59+
60+
return response.data;
61+
};

0 commit comments

Comments
 (0)