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

42 lines
895 B
TypeScript

import axiosInstance from './axiosInstance'
type OrderType = 'asc' | 'desc'
interface StudentResponse {
max_pages: number
students: Student[]
}
export interface Student {
first_name: string
last_name: string
index: number
pesel: string
mode: boolean
group?: any
}
export const getStudents = (
params: Partial<{
fullname: string
order_by_first_name: OrderType
order_by_last_name: OrderType
page: number
per_page: number
mode: boolean
}> = {},
) =>
axiosInstance.get<StudentResponse>(
'http://127.0.0.1:5000/api/coordinator/students',
{ params },
)
export const createStudent = (payload: Student) =>
axiosInstance.post('http://127.0.0.1:5000/api/coordinator/students/', payload)
export const uploadStudents = (payload: FormData) =>
axiosInstance.post(
'http://127.0.0.1:5000/api/coordinator/students/upload/',
payload,
)