Skip to content

Commit dc9941b

Browse files
committed
feat: complaint page (App) (#320)
1 parent ae20099 commit dc9941b

File tree

54 files changed

+1351
-139
lines changed

Some content is hidden

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

54 files changed

+1351
-139
lines changed
Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,49 @@
1-
export {};
1+
import { appendFilesToFormData, createJsonBlob, extractFormData } from '@ahhachul/utils';
2+
3+
import axiosInstance from '@/apis/fetcher';
4+
import type { ApiResponse, CommentList, PaginatedList, WithPostId } from '@/types';
5+
import type {
6+
ComplaintForm,
7+
ComplaintListParams,
8+
ComplaintPost,
9+
ComplaintPostDetail,
10+
} from '@/types/complaint';
11+
12+
export const fetchComplaintList = async (req: ComplaintListParams) => {
13+
const { data } = await axiosInstance.get<ApiResponse<PaginatedList<ComplaintPost>>>(
14+
'/complaint-posts',
15+
{
16+
params: {
17+
...req,
18+
pageSize: 10,
19+
},
20+
},
21+
);
22+
return data;
23+
};
24+
25+
export const createComplaint = async (req: ComplaintForm) => {
26+
const formData = new FormData();
27+
const formDataWithoutImages = extractFormData(req, 'images');
28+
const jsonBlob = createJsonBlob(formDataWithoutImages);
29+
30+
formData.append('content', jsonBlob);
31+
32+
if (req.images?.length) {
33+
appendFilesToFormData(formData, req.images);
34+
}
35+
36+
const { data } = await axiosInstance.post<ApiResponse<WithPostId>>('/complaint-posts', formData, {
37+
headers: {
38+
'Content-Type': 'multipart/form-data',
39+
},
40+
});
41+
42+
return data;
43+
};
44+
45+
export const fetchComplaintDetail = (id: number) =>
46+
axiosInstance.get<ApiResponse<ComplaintPostDetail>>(`/complaint-posts/${id}`);
47+
48+
export const fetchComplaintCommentList = (id: number) =>
49+
axiosInstance.get<ApiResponse<CommentList>>(`/complaint-posts/${id}/comments`);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ export * from './user';
33
export * from './token';
44
export * from './lostFound';
55
export * from './community';
6+
export * from './complaint';
Lines changed: 4 additions & 0 deletions
Loading
Lines changed: 4 additions & 0 deletions
Loading
Lines changed: 11 additions & 0 deletions
Loading
Lines changed: 5 additions & 0 deletions
Loading
Lines changed: 6 additions & 0 deletions
Loading
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export { default as ArrowMiniIcon } from './ic_arrow.svg?react';
2+
export { default as EmergencyIcon } from './ic_emergency.svg?react';
3+
export { default as HitIcon } from './ic_hit.svg?react';
4+
export { default as MetroIcon } from './ic_metro.svg?react';
5+
export { default as TreeIcon } from './ic_tree.svg?react';
Lines changed: 6 additions & 0 deletions
Loading

services/ahhachul.com/src/assets/icons/system/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export { default as DotIcon } from './ic_dot.svg?react';
22
export { default as MicIcon } from './ic_mic.svg?react';
33
export { default as BellIcon } from './ic_bell.svg?react';
4+
export { default as ListIcon } from './ic_list.svg?react';
45
export { default as TalkIcon } from './ic_talk.svg?react';
56
export { default as InfoIcon } from './ic_info.svg?react';
67
export { default as LogoIcon } from './ic_logo.svg?react';

0 commit comments

Comments
 (0)