Skip to content

Commit f768b58

Browse files
committed
Merge branch 'develop' of https://github.com/prgrms-web-devcourse-final-project/WEB2_3_9crops_FE into 82-feat-admin-rd
2 parents f363aaa + ae17500 commit f768b58

33 files changed

+661
-185
lines changed

eslint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export default tseslint.config(
3131
...reactHooks.configs.recommended.rules,
3232
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
3333
'@tanstack/query/exhaustive-deps': 'error',
34+
'@typescript-eslint/no-empty-object-type': off,
3435
'import/order': [
3536
'error',
3637
{

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"@tailwindcss/vite": "^4.0.6",
1919
"@tanstack/react-query": "^5.66.0",
2020
"axios": "^1.7.9",
21+
"event-source-polyfill": "^1.0.31",
2122
"gsap": "^3.12.7",
2223
"react": "^18.3.1",
2324
"react-dom": "^18.3.1",
@@ -31,6 +32,7 @@
3132
"devDependencies": {
3233
"@eslint/js": "^9.19.0",
3334
"@tanstack/eslint-plugin-query": "^5.66.1",
35+
"@types/event-source-polyfill": "^1.0.5",
3436
"@types/react": "^19.0.8",
3537
"@types/react-dom": "^19.0.3",
3638
"@vitejs/plugin-react-swc": "^3.5.0",

pnpm-lock.yaml

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/App.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Route, Routes } from 'react-router';
22

3+
import { useServerSentEvents } from './hooks/useServerSentEvents';
34
import useViewport from './hooks/useViewport';
45
import Layout from './layouts/Layout';
56
import MobileLayout from './layouts/MobileLayout';
@@ -8,6 +9,7 @@ import AdminPage from './pages/Admin';
89
import FilteredLetterManage from './pages/Admin/FilteredLetter';
910
import FilteringManage from './pages/Admin/Filtering';
1011
import ReportManage from './pages/Admin/Report';
12+
import AdminRollingPaper from './pages/Admin/RollingPaper';
1113
import AuthCallbackPage from './pages/Auth';
1214
import Home from './pages/Home';
1315
import Landing from './pages/Landing';
@@ -28,6 +30,7 @@ import WritePage from './pages/Write';
2830

2931
const App = () => {
3032
useViewport();
33+
useServerSentEvents();
3134

3235
return (
3336
<Routes>
@@ -69,6 +72,7 @@ const App = () => {
6972
<Route path="report" element={<ReportManage />} />
7073
<Route path="badwords" element={<FilteringManage />} />
7174
<Route path="filtered-letter" element={<FilteredLetterManage />} />
75+
<Route path="rolling-paper" element={<AdminRollingPaper />} />
7276
</Route>
7377
</Route>
7478
</Routes>

src/apis/client.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,8 @@ let retry = false;
4545

4646
client.interceptors.request.use(
4747
(config) => {
48-
console.log('response again', config);
49-
5048
const accessToken = useAuthStore.getState().accessToken;
51-
if (config.url !== '/auth/reissue' && accessToken) {
49+
if (config.url !== '/api/reissue' && accessToken) {
5250
config.headers.Authorization = `Bearer ${accessToken}`;
5351
}
5452
return config;

src/apis/draftLetters.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,30 @@ export interface DraftLetter {
1616
matched: boolean;
1717
}
1818

19-
export const getDraftLetters = async () // token: string
20-
: Promise<DraftLetter[]> => {
19+
export const getDraftLetters = async (): Promise<DraftLetter[]> => {
2120
try {
22-
const { data } = await client.get('/api/letters?status=draft', {
23-
// headers: {
24-
// Authorization: `Bearer ${token}`,
25-
// },
26-
});
21+
const { data } = await client.get('/api/letters?status=draft', {});
2722
console.log('임시저장된 편지 데이터', data);
2823
return data.data;
2924
} catch (error) {
30-
console.error(`❌임시저장된 편지를 불러오던 중 에러가 발생했습니다`, error);
25+
console.error('❌임시저장된 편지를 불러오던 중 에러가 발생했습니다', error);
3126
throw new Error('임시저장된 편지 불러오기 실패');
3227
}
3328
};
29+
30+
export const deleteDraftLetters = async (letterId: number) => {
31+
try {
32+
const { data } = await client.delete(`/api/letters/${letterId}/temporary-save`);
33+
34+
if (data.data?.letterId) {
35+
console.log('삭제된 임시저장 편지 ID:', data.data.letterId);
36+
} else {
37+
console.error('❌서버 응답에 letterId가 존재하지 않습니다.');
38+
}
39+
40+
return data.data.letterId;
41+
} catch (error) {
42+
console.error('❌임시저장된 편지를 삭제하던 중 에러가 발생했습니다:', error);
43+
throw error;
44+
}
45+
};

src/apis/myPage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const fetchMyPageInfo = async () => {
1212

1313
export const getMySharePostList = async () => {
1414
try {
15-
const response = await client.get('/api/share-proposals/inbox');
15+
const response = await client.get('/api/share-posts/me');
1616
if (!response) throw new Error('error while fetching my share post list');
1717
return response.data;
1818
} catch (error) {

src/apis/notification.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import client from './client';
2+
3+
const getTimeLines = async () => {
4+
try {
5+
const res = await client.get('/api/timelines');
6+
if (!res) throw new Error('타임라인을 받아오는 도중 오류가 발생했습니다.');
7+
console.log(res);
8+
return res;
9+
} catch (error) {
10+
console.error(error);
11+
}
12+
};
13+
14+
const patchReadNotification = async (timelineId: number) => {
15+
try {
16+
const res = await client.patch(`/api/notifications/${timelineId}/read`);
17+
if (!res) throw new Error('편지 개별 읽음 처리를 하는 도중 오류가 발생했습니다.');
18+
return res;
19+
} catch (error) {
20+
console.error(error);
21+
}
22+
};
23+
24+
const patchReadNotificationAll = async () => {
25+
try {
26+
const res = await client.patch(`/api/notifications/read`);
27+
if (!res) throw new Error('편지 개별 읽음 처리를 하는 도중 오류가 발생했습니다.');
28+
return res;
29+
} catch (error) {
30+
console.error(error);
31+
}
32+
};
33+
34+
export { getTimeLines, patchReadNotification, patchReadNotificationAll };

src/apis/rolling.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,50 @@ export const deleteRollingPaperComment = async (commentId: string | number) => {
3636
throw error;
3737
}
3838
};
39+
40+
export const postNewRollingPaper = async (title: string) => {
41+
try {
42+
const {
43+
data: { data },
44+
} = await client.post('/api/admin/event-posts', { title });
45+
return data;
46+
} catch (error) {
47+
console.error(error);
48+
throw error;
49+
}
50+
};
51+
52+
export const getRollingPaperList = async (): Promise<RollingPaperList> => {
53+
try {
54+
const {
55+
data: { data },
56+
} = await client.get('/api/admin/event-posts');
57+
return data;
58+
} catch (error) {
59+
console.error(error);
60+
throw error;
61+
}
62+
};
63+
64+
export const deleteRollingPaper = async (eventPostId: number | string) => {
65+
try {
66+
const { data } = await client.delete(`/api/admin/event-posts/${eventPostId}`);
67+
return data;
68+
} catch (error) {
69+
console.error(error);
70+
throw error;
71+
}
72+
};
73+
74+
export const patchRollingPaper = async (eventPostId: number | string) => {
75+
try {
76+
const {
77+
data: { data },
78+
} = await client.patch(`/api/admin/event-posts/${eventPostId}/status`);
79+
console.log(data);
80+
return data;
81+
} catch (error) {
82+
console.error(error);
83+
throw error;
84+
}
85+
};

src/apis/share.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export const getSharePostList = async (page: number = 1, size: number = 10) => {
5353
};
5454

5555
// 공유 게시글 상세 조회
56-
export const getSharePostDetail = async (sharePostId: number): Promise<SharePost> => {
56+
export const getSharePostDetail = async (sharePostId: string): Promise<SharePost> => {
5757
try {
5858
const response = await client.get(`/api/share-posts/${sharePostId}`);
5959
console.log(`🔥공유 게시글 상세 데이터`, response.data);
@@ -102,7 +102,7 @@ export const postShareProposalApproval = async (
102102
};
103103

104104
// 편지 좋아요 추가, 취소
105-
export const postSharePostLike = async (sharePostId: number) => {
105+
export const postSharePostLike = async (sharePostId: string) => {
106106
try {
107107
const response = await client.post(`/api/share-posts/${sharePostId}/likes`);
108108
if (!response) throw new Error('error while posting like');
@@ -114,7 +114,7 @@ export const postSharePostLike = async (sharePostId: number) => {
114114
};
115115

116116
// 편지 좋아요 갯수
117-
export const getSharePostLikeCount = async (sharePostId: number) => {
117+
export const getSharePostLikeCount = async (sharePostId: string) => {
118118
try {
119119
const response = await client.get(`/api/share-posts/${sharePostId}/likes`);
120120
if (!response) throw new Error('error while fetching likes');

0 commit comments

Comments
 (0)