Skip to content

Commit 9b9c1d5

Browse files
LucaTvlNiconiKimg
andcommitted
Implentation of the appeal logic
Co-authored-by: Nicolás Pedemonte <pedemontenicolas2004@gmail.com>
1 parent 254f2f6 commit 9b9c1d5

5 files changed

Lines changed: 81 additions & 17 deletions

File tree

public/professor_appeal_image.svg

Lines changed: 1 addition & 0 deletions
Loading

src/api/apiClient.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ export const TOKEN_STORAGE_KEY = 'jwt_token';
44

55
const apiClient = axios.create({
66
baseURL: import.meta.env.VITE_API_BASE_URL,
7-
8-
headers: {
9-
'Content-Type': 'application/json',
10-
},
117
});
128

139
apiClient.interceptors.request.use(
@@ -17,6 +13,11 @@ apiClient.interceptors.request.use(
1713
if (token) {
1814
config.headers.Authorization = `Bearer ${token}`;
1915
}
16+
17+
if (!(config.data instanceof FormData)) {
18+
config.headers['Content-Type'] = 'application/json';
19+
}
20+
2021
return config;
2122
},
2223
(error) => {

src/api/services/appeal.service.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import apiClient from '../apiClient';
2+
import type { Appeal } from '../../types/entities';
3+
4+
interface ApiResponse<T> {
5+
status: number;
6+
message: string;
7+
data: T;
8+
}
9+
10+
/**
11+
* @param formData
12+
* @returns
13+
*/
14+
const createAppeal = async (formData: FormData): Promise<Appeal> => {
15+
16+
const response = await apiClient.post<ApiResponse<Appeal>>('/appeals', formData);
17+
18+
return response.data.data;
19+
};
20+
21+
export const appealService = {
22+
createAppeal,
23+
};

0 commit comments

Comments
 (0)