Skip to content

Commit 43e37bc

Browse files
committed
Fix Incorrect API Calling Functions
1 parent 1cd8dd0 commit 43e37bc

File tree

4 files changed

+7
-9
lines changed

4 files changed

+7
-9
lines changed

frontend/src/data/repositories/HistoryRemoteDataSource.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export class HistoryRemoteDataSource extends BaseApi {
1010
}
1111

1212
async getAllUserHistories(): Promise<HistoryEntry[]> {
13-
return await this.get<HistoryEntry[]>("/");
13+
return await this.protectedGet<HistoryEntry[]>("/");
1414
}
1515

1616
async createOrUpdateUserHistory(questionId: string, roomId: string, attemptStartedAt: string, attemptCompletedAt: string, collaboratorId: string, attemptCode: string): Promise<void> {
@@ -21,12 +21,12 @@ export class HistoryRemoteDataSource extends BaseApi {
2121
console.log("Delete")
2222
selectedHistoryIds.forEach(async (id) => {
2323
console.log(id);
24-
await this.delete<void>(`/user/${id}`);
24+
await this.protectedDelete<void>(`/user/${id}`);
2525
});
2626
}
2727

2828
async deleteAllUserHistories(): Promise<void> {
29-
await this.delete<void>("/all");
29+
await this.protectedDelete<void>("/all");
3030
}
3131
}
3232

frontend/src/domain/usecases/HistoryUseCases.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ export class HistoryUseCases {
66
constructor(private historyRepository: IHistoryRepository) {}
77

88
/**
9-
* Retrieves all categories.
10-
* @returns Promise resolving to an array of Category objects.
9+
* Retrieves all history entries of the logged in user.
10+
* @returns Promise resolving to an array of HistoryEntry objects.
1111
*/
12-
async getAllCategories(): Promise<HistoryEntry[]> {
12+
async getAllUserHistories(): Promise<HistoryEntry[]> {
1313
const allHistories = this.historyRepository.getAllUserHistories();
1414
return allHistories;
1515
}

frontend/src/infrastructure/Api/BaseApi.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@ export class BaseApi {
1717
}
1818

1919
private createAxiosInstance(baseUrl: string): AxiosInstance {
20-
const token = AuthClientStore.getAccessToken();
2120
return axios.create({
2221
baseURL: API_URL + baseUrl,
2322
timeout: 10000,
2423
headers: {
2524
"Content-Type": "application/json",
26-
'Authorization': `Bearer ${token}`,
2725
},
2826
withCredentials: true
2927
});

frontend/src/presentation/components/RecentAttemptsTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const RecentAttemptsTable: React.FC = () => {
2020
const fetchRecentAttempts = async () => {
2121
setLoading(true);
2222
try {
23-
const data = await historyUseCases.getAllCategories();
23+
const data = await historyUseCases.getAllUserHistories();
2424
setRecentAttemptsData(data);
2525
} catch (error) {
2626
if (error instanceof Error) {

0 commit comments

Comments
 (0)