Skip to content
This repository was archived by the owner on Nov 27, 2025. It is now read-only.

Commit b9b4263

Browse files
author
Hyeokmin Kwon
committed
Replace session APIs
1 parent 15cef5f commit b9b4263

3 files changed

Lines changed: 2046 additions & 15 deletions

File tree

src/api/session.ts

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,30 @@
1-
import instance from "lib/axios";
21
import { APIPretalxSessions } from "models/api/session";
2+
import SESSIONS from "./sessions.json";
33

44
export const listSessions = async () => {
5-
const result = await instance.get("/2024/sessions/");
6-
switch (result.status) {
7-
case 200:
8-
return result.data as APIPretalxSessions;
9-
default:
10-
throw new Error("세션 목록을 불러오는데 실패했습니다,\n잠시 후 다시 시도해주세요.");
11-
}
5+
// const result = await instance.get("/2024/sessions/");
6+
// switch (result.status) {
7+
// case 200:
8+
// return result.data as APIPretalxSessions;
9+
// default:
10+
// throw new Error("세션 목록을 불러오는데 실패했습니다,\n잠시 후 다시 시도해주세요.");
11+
// }
12+
13+
return SESSIONS as APIPretalxSessions;
1214
};
1315

1416
export const retrieveSession = async (code: string) => {
15-
const result = await instance.get(`/2024/sessions/${code}/`);
16-
switch (result.status) {
17-
case 200:
18-
return result.data as APIPretalxSessions[0];
19-
default:
20-
throw new Error("세션을 불러오는데 실패했습니다,\n잠시 후 다시 시도해주세요.");
21-
}
17+
// const result = await instance.get(`/2024/sessions/${code}/`);
18+
// switch (result.status) {
19+
// case 200:
20+
// return result.data as APIPretalxSessions[0];
21+
// default:
22+
// throw new Error("세션을 불러오는데 실패했습니다,\n잠시 후 다시 시도해주세요.");
23+
// }
24+
25+
const filtered = (SESSIONS as APIPretalxSessions).filter((session) => session.code === code);
26+
if (filtered.length !== 1)
27+
throw new Error("세션을 불러오는데 실패했습니다,\n잠시 후 다시 시도해주세요.");
28+
29+
return filtered[0];
2230
};

0 commit comments

Comments
 (0)