Skip to content

Commit 1d9fc8d

Browse files
committed
2 parents 0a8e69a + 5ca4f51 commit 1d9fc8d

File tree

95 files changed

+1805
-760
lines changed

Some content is hidden

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

95 files changed

+1805
-760
lines changed

src/App.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import useViewport from './hooks/useViewport';
44
import Layout from './layouts/Layout';
55
import MobileLayout from './layouts/MobileLayout';
66
import AdminPage from './pages/Admin';
7+
import FilteredLetterManage from './pages/Admin/FilteredLetter';
8+
import FilteringManage from './pages/Admin/Filtering';
79
import ReportManage from './pages/Admin/Report';
810
import Home from './pages/Home';
911
import Landing from './pages/Landing';
@@ -14,6 +16,7 @@ import LetterBoxDetailPage from './pages/LetterBoxDetail';
1416
import LetterDetailPage from './pages/LetterDetail';
1517
import LoginPage from './pages/Login';
1618
import MyPage from './pages/MyPage';
19+
import NotFoundPage from './pages/NotFound';
1720
import NotificationsPage from './pages/Notifications';
1821
import OnboardingPage from './pages/Onboarding';
1922
import RandomLettersPage from './pages/RandomLetters';
@@ -51,9 +54,13 @@ const App = () => {
5154
<Route path="board" element={<LetterBoardPage />} />
5255
<Route path="notifications" element={<NotificationsPage />} />
5356
</Route>
57+
<Route path="*" element={<NotFoundPage />}></Route>
5458
</Route>
59+
5560
<Route path="admin" element={<AdminPage />}>
5661
<Route path="report" element={<ReportManage />} />
62+
<Route path="badwords" element={<FilteringManage />} />
63+
<Route path="filtered-letter" element={<FilteredLetterManage />} />
5764
</Route>
5865
</Routes>
5966
);

src/apis/admin.ts

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import client from './client';
2+
3+
const getReports = async (
4+
setReports: React.Dispatch<React.SetStateAction<Report[]>>,
5+
queryString: string = '',
6+
callBack?: () => void,
7+
) => {
8+
try {
9+
const res = await client.get(`/api/reports${queryString}`);
10+
setReports(res.data.data);
11+
if (callBack) callBack();
12+
console.log(res.data.data);
13+
} catch (error) {
14+
console.error(error);
15+
}
16+
};
17+
18+
const patchReport = async (reportId: number, reportRequest: ReportRequest) => {
19+
try {
20+
console.log(`/api/reports/${reportId}`, reportRequest);
21+
const res = await client.patch(`/api/reports/${reportId}`, reportRequest);
22+
console.log(res);
23+
} catch (error) {
24+
console.error(error);
25+
}
26+
};
27+
28+
// badwords
29+
const getBadWords = async (setBadWords: React.Dispatch<React.SetStateAction<BadWords[]>>) => {
30+
try {
31+
const res = await client.get('/api/bad-words');
32+
setBadWords(res.data.data);
33+
console.log(res);
34+
} catch (error) {
35+
console.error(error);
36+
}
37+
};
38+
39+
const postBadWords = async (badWordsRequest: BadWords, callBack?: () => void) => {
40+
try {
41+
const res = await client.post('/api/bad-words', badWordsRequest);
42+
if (callBack) callBack();
43+
console.log(res);
44+
} catch (error) {
45+
console.error(error);
46+
}
47+
};
48+
49+
// 내 상상대로 만든 필터링 단어 취소 버튼
50+
const patchBadWords = async (
51+
badWordId: number,
52+
badWordsRequest: BadWords,
53+
callBack?: () => void,
54+
) => {
55+
try {
56+
const res = await client.patch(`/api/bad-words/${badWordId}/status`, badWordsRequest);
57+
if (callBack) callBack();
58+
console.log(res);
59+
} catch (error) {
60+
console.error(error);
61+
}
62+
};
63+
64+
export { getReports, patchReport, getBadWords, postBadWords, patchBadWords };

src/apis/client.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
import axios from 'axios';
22

3-
export const client = axios.create({
3+
const client = axios.create({
44
baseURL: import.meta.env.VITE_API_URL,
55
});
6+
7+
// client.interceptors.request.use(
8+
// (config) => {
9+
// const token = localStorage.getItem('authToken');
10+
// if (token) {
11+
// config.headers['Authorization'] = `Bearer ${token}`;
12+
// }
13+
// return config;
14+
// },
15+
// (error) => {
16+
// //TODO: 에러처리
17+
// return Promise.reject(error);
18+
// },
19+
// );
20+
21+
export default client;

src/apis/incomingLetters.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import client from './client';
2+
3+
export const fetchIncomingLettersApi = async (token: string) => {
4+
try {
5+
const { data } = await client.get('/api/letters?status=delivery', {
6+
headers: {
7+
Authorization: `Bearer ${token}`,
8+
},
9+
});
10+
console.log('불러온 데이터', data);
11+
return data;
12+
} catch (error) {
13+
console.error('❌오고 있는 편지 목록을 불러오던 중 에러 발생', error);
14+
throw error;
15+
}
16+
};

src/apis/letterDetail.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { client } from './client';
1+
import client from './client';
22

33
const getLetter = async (
44
letterId: string,

src/apis/mailBox.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import client from './client';
2+
3+
export const getMailbox = async () => {
4+
try {
5+
const response = await client.get('/api/mailbox');
6+
if (!response) throw new Error('error while fetching mailbox data');
7+
return response.data;
8+
} catch (error) {
9+
console.error(error);
10+
}
11+
};
12+
13+
export const getMailboxDetail = async (id: number) => {
14+
try {
15+
const response = await client.get(`/api/mailbox/${id}`);
16+
if (!response) throw new Error('error while fetching mailbox detail data');
17+
return response.data;
18+
} catch (error) {
19+
console.error(error);
20+
}
21+
};
22+
23+
export const postMailboxDisconnect = async (id: number) => {
24+
try {
25+
const response = await client.post(`/api/mailbox/${id}/disconnect`);
26+
if (!response) throw new Error('error while disconnecting mailbox');
27+
return response;
28+
} catch (error) {
29+
console.error(error);
30+
}
31+
};

src/apis/myPage.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import client from './client';
2+
3+
export const fetchMyPageInfo = async () => {
4+
try {
5+
const response = await client.get('/api/members/me');
6+
if (!response) throw new Error('❌데이터를 불러오던 중 오류가 발생했습니다');
7+
return response.data;
8+
} catch (error) {
9+
console.error(error);
10+
}
11+
};

src/apis/rolling.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import client from './client';
2+
3+
export const getCurrentRollingPaper = async (): Promise<RollingPaperInformation> => {
4+
const {
5+
data: { data },
6+
} = await client.get('/api/event-posts');
7+
return data;
8+
};
9+
10+
export const getRollingPaperDetail = async (
11+
rollingPaperId: string | number,
12+
): Promise<RollingPaper> => {
13+
const {
14+
data: { data },
15+
} = await client.get(`/api/event-posts/${rollingPaperId}`);
16+
return data;
17+
};
18+
19+
export const postRollingPaperComment = async (rollingPaperId: string | number, content: string) => {
20+
const {
21+
data: { data },
22+
} = await client.post(`/api/event-posts/${rollingPaperId}/comments`, {
23+
content,
24+
});
25+
return data;
26+
};
27+
28+
export const deleteRollingPaperComment = async (commentId: string | number) => {
29+
try {
30+
const {
31+
data: { data },
32+
} = await client.delete(`/api/event-posts/comments/${commentId}`);
33+
return data;
34+
} catch (error) {
35+
console.error(error);
36+
throw error;
37+
}
38+
};

src/apis/share.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import client from './client';
2+
3+
export const postShareProposals = async (
4+
letterIds: number[],
5+
requesterId: number,
6+
recipientId: number,
7+
message: string,
8+
) => {
9+
try {
10+
const response = await client.post('/api/share-proposals', {
11+
letterIds: letterIds,
12+
requesterId: requesterId,
13+
recipientId: recipientId,
14+
message: message,
15+
});
16+
if (!response) throw new Error('error while fetching mailbox data');
17+
return response;
18+
} catch (error) {
19+
console.error(error);
20+
}
21+
};

src/apis/write.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { client } from './client';
1+
import client from './client';
22

33
const postLetter = async (data: LetterRequest, callBack?: () => void) => {
44
try {

0 commit comments

Comments
 (0)