51 lines
1.1 KiB
TypeScript
51 lines
1.1 KiB
TypeScript
import axiosInstance from './axiosInstance'
|
|
import { Leader } from './leaders'
|
|
import { Student } from './students'
|
|
|
|
type OrderType = 'asc' | 'desc'
|
|
|
|
interface GroupResponse {
|
|
max_pages: number
|
|
groups: Group[]
|
|
}
|
|
|
|
export interface Group {
|
|
id: number
|
|
name: string
|
|
project_supervisor: Leader
|
|
points_for_first_term: number
|
|
points_for_second_term: number
|
|
}
|
|
|
|
export interface GroupPost {
|
|
name: string
|
|
project_supervisor_id: number
|
|
students: number[]
|
|
}
|
|
|
|
export const getGroups = (
|
|
params: Partial<{
|
|
name: string
|
|
page: number
|
|
per_page: number
|
|
}> = {},
|
|
) =>
|
|
axiosInstance.get<GroupResponse>(
|
|
'http://127.0.0.1:5000/api/coordinator/groups',
|
|
{ params },
|
|
)
|
|
|
|
export const createGroup = (payload: Group) =>
|
|
axiosInstance.post('http://127.0.0.1:5000/api/coordinator/groups/', payload)
|
|
|
|
export const uploadGroups = (payload: FormData) =>
|
|
axiosInstance.post(
|
|
'http://127.0.0.1:5000/api/coordinator/groups/upload/',
|
|
payload,
|
|
)
|
|
|
|
export const deleteGroup = (payload: Number) =>
|
|
axiosInstance.delete(
|
|
'http://127.0.0.1:5000/api/coordinator/groups/'+payload.toString()+'/',
|
|
)
|