system-pri/frontend/src/api/students.ts

43 lines
920 B
TypeScript
Raw Normal View History

2022-05-30 21:38:45 +02:00
import axiosInstance from './axiosInstance'
2022-05-22 21:28:25 +02:00
type OrderType = 'asc' | 'desc'
2022-05-22 21:28:25 +02:00
interface StudentResponse {
2022-05-30 21:38:45 +02:00
max_pages: number
2022-06-04 21:03:40 +02:00
students: Student[]
}
export interface Student {
first_name: string
last_name: string
index: number
2022-06-12 18:31:01 +02:00
pesel: string
2022-06-04 21:03:40 +02:00
mode: boolean
group?: any
2022-05-22 21:28:25 +02:00
}
export const getStudents = (
params: Partial<{
fullname: string
order_by_first_name: OrderType
order_by_last_name: OrderType
page: number
per_page: number
2022-06-11 15:06:17 +02:00
mode: boolean
}> = {},
) =>
2022-05-30 21:38:45 +02:00
axiosInstance.get<StudentResponse>(
'http://127.0.0.1:5000/api/coordinator/students',
{ params },
2022-05-30 21:38:45 +02:00
)
2022-06-04 21:03:40 +02:00
export const createStudent = (payload: Student) =>
axiosInstance.post('http://127.0.0.1:5000/api/coordinator/students/', payload)
export const uploadStudents = (payload: FormData, mode: Boolean) =>
2022-05-30 21:38:45 +02:00
axiosInstance.post(
'http://127.0.0.1:5000/api/coordinator/students/upload/',
payload,
mode,
2022-05-30 21:38:45 +02:00
)