Skip to content

Commit 4abfee8

Browse files
authored
Merge pull request #67 from solutionchallenge/feat/#46
add: 리포트 API 연동
2 parents 7eecaab + 68e36af commit 4abfee8

File tree

35 files changed

+765
-396
lines changed

35 files changed

+765
-396
lines changed

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"eslint-plugin-unused-imports": "^4.1.4",
3737
"globals": "^15.14.0",
3838
"postcss": "^8.5.3",
39-
"prettier": "^3.5.2",
39+
"prettier": "^3.5.3",
4040
"tailwindcss": "^3.4.17",
4141
"typescript": "~5.7.2",
4242
"typescript-eslint": "^8.22.0",

public/videos/video_1.mp4

5.65 MB
Binary file not shown.

public/videos/video_2.mp4

16 MB
Binary file not shown.

src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function App() {
4040
<Route path="report">
4141
<Route index path="*" element={<NotFoundPage />} />
4242
<Route path="main" element={<ReportMainPage />} />
43-
<Route path="detail/:id" element={<ReportDetailPage />} />
43+
<Route path="detail/:session_id" element={<ReportDetailPage />} />
4444
</Route>
4545
</Route>
4646
<Route element={<Layout bottomNavigation={false} />}>

src/api/fetch.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ const baseFetch = async (url: RequestInfo, init?: RequestInit) => {
2020
};
2121

2222
const http = {
23-
get: async <T = any>(url: string) => {
24-
return baseFetch(url, {
23+
get: async <T = any>(url: string, params?: Record<string, string>) => {
24+
const queryString = params ? `?${new URLSearchParams(params).toString()}` : '';
25+
return baseFetch(`${url}${queryString}`, {
2526
method: "GET",
2627
}) as Promise<{ response: T }>;
2728
},

src/api/report/chats.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import { http } from "../fetch";
2+
import { EmotionTypes } from "../onboarding/addition";
3+
4+
export interface SummaryResponse {
5+
emotions:{
6+
emotion: EmotionTypes,
7+
rate: 0
8+
}[],
9+
keywords: string[],
10+
recommendations: string[],
11+
text: string,
12+
title: string,
13+
main_topic:{
14+
begin_message_id:string,
15+
end_message_id:string
16+
}
17+
}
18+
19+
export interface ChatResponse {
20+
chat_duration: string,
21+
id: string,
22+
is_archived: boolean,
23+
is_finished: boolean,
24+
session_id: string,
25+
started_date: string,
26+
summary:SummaryResponse,
27+
}[]
28+
29+
type History = {
30+
content: string,
31+
id: string,
32+
metadata: number[],
33+
role: string,
34+
when: string
35+
}
36+
37+
export interface ChatDetailResponse extends ChatResponse {
38+
histories: History[],
39+
summary:SummaryResponse,
40+
}
41+
42+
43+
export const getChats = async (params:{
44+
datetime_gte:string,
45+
datetime_lte:string,
46+
dominant_emotions:string,
47+
matching_content:string,
48+
}): Promise<{chats:ChatResponse[]}> => {
49+
const { response } = await http.get<{chats:ChatResponse[]}>(
50+
`/chats`, params
51+
);
52+
return response;
53+
};
54+
55+
export const getChatDetail = async (sessionId: string): Promise<ChatDetailResponse> => {
56+
const { response } = await http.get<ChatDetailResponse>(
57+
`/chats/${sessionId}`
58+
);
59+
return response;
60+
};
61+

src/api/report/report.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { http } from "../fetch";
2+
import { EmotionTypes } from "../onboarding/addition";
3+
import { ChatResponse } from "./chats";
4+
5+
export interface ReportResponse {
6+
"average_chat_duration": string,
7+
"average_negative_score": number,
8+
"average_neutral_score": number,
9+
"average_positive_score": number,
10+
"datetime_gte": string,
11+
"datetime_lte": string,
12+
"emotion_counts": [
13+
{
14+
"count": number,
15+
"emotion": EmotionTypes
16+
}
17+
],
18+
"stress_level_descriptor": {
19+
"description": string,
20+
"threshold": number,
21+
"title": string
22+
},
23+
"total_chat_count": number
24+
}
25+
26+
export const getChatReport = async (params:{
27+
datetime_gte:string,
28+
datetime_lte:string,
29+
}): Promise<ReportResponse> => {
30+
const { response } = await http.get<ReportResponse>(
31+
`/chat-reports`, params
32+
);
33+
return response;
34+
};
35+
36+
export const getChatById = async (params:{
37+
message_id:string
38+
}): Promise<{chats:ChatResponse[]}> => {
39+
const { response } = await http.get<{chats:ChatResponse[]}>(
40+
`/chats`, params
41+
);
42+
return response;
43+
};

src/assets/images/icon_arrow.svg

Lines changed: 3 additions & 0 deletions
Loading

src/assets/images/icon_play.svg

Lines changed: 12 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)