208 lines
4.8 KiB
TypeScript
208 lines
4.8 KiB
TypeScript
import axiosInstance from './axiosInstance'
|
|
import { Leader } from './leaders'
|
|
import { Student } from './students'
|
|
|
|
interface TermOfDefences {
|
|
id: number
|
|
start_date: string
|
|
end_date: string
|
|
title: string
|
|
members_of_committee: {
|
|
first_name: string
|
|
last_name: string
|
|
}[]
|
|
group: { name: string; students: Student[] }
|
|
}
|
|
|
|
export const getTermsOfDefences = (scheduleId: number) => {
|
|
return axiosInstance.get<{
|
|
term_of_defences: TermOfDefences[]
|
|
}>(`coordinator/enrollments/${scheduleId}/term-of-defences/`)
|
|
}
|
|
export const getTermsOfDefencesWithGroups = (scheduleId: number) => {
|
|
return axiosInstance.get<{
|
|
term_of_defences: TermOfDefences[]
|
|
}>(
|
|
`coordinator/enrollments/${scheduleId}/assigned-group-to-term-of-defences/`,
|
|
)
|
|
}
|
|
|
|
export const getStudentsTermsOfDefences = (
|
|
scheduleId: number,
|
|
studentIndex: number,
|
|
) => {
|
|
return axiosInstance.get<{
|
|
term_of_defences: TermOfDefences[]
|
|
}>(
|
|
`students/examination-schedule/${scheduleId}/enrollments?student_index=${studentIndex}`,
|
|
)
|
|
}
|
|
|
|
export const getSupervisorTermsOfDefences = (scheduleId: number) => {
|
|
return axiosInstance.get<{
|
|
term_of_defences: TermOfDefences[]
|
|
}>(`project_supervisor/${scheduleId}/term-of-defences?id=1`) //fix hardcode id
|
|
}
|
|
|
|
export const getAvailabilityForSupervisor = (scheduleId: number) => {
|
|
return axiosInstance.get<{
|
|
free_times: { id: number; start_date: string; end_date: string }[]
|
|
}>(`project_supervisor/${scheduleId}/temporary-availabilities?id=1`) //fix hardcode id
|
|
}
|
|
|
|
export const getAvailabilityForCoordinator = (scheduleId: number) => {
|
|
return axiosInstance.get<{
|
|
temporary_availabilities: {
|
|
id: number
|
|
start_date: string
|
|
end_date: string
|
|
project_supervisor: Leader
|
|
}[]
|
|
}>(`coordinator/enrollments/${scheduleId}/temporary-availabilities`)
|
|
}
|
|
|
|
export const getSchedules = (year_group_id: number) => {
|
|
return axiosInstance.get<{
|
|
examination_schedules: {
|
|
id: number
|
|
start_date: string
|
|
end_date: string
|
|
title: string
|
|
mode: boolean
|
|
}[]
|
|
}>(`coordinator/examination_schedule/${year_group_id}?per_page=10000`)
|
|
}
|
|
|
|
export const createEvent = ({
|
|
start_date,
|
|
end_date,
|
|
scheduleId,
|
|
project_supervisors,
|
|
}: {
|
|
start_date: string
|
|
end_date: string
|
|
scheduleId: number
|
|
project_supervisors: number[]
|
|
}) => {
|
|
return axiosInstance.post(
|
|
`coordinator/enrollments/${scheduleId}/add-term-of-defences/`,
|
|
{
|
|
start_date,
|
|
end_date,
|
|
project_supervisors,
|
|
},
|
|
)
|
|
}
|
|
|
|
export const createSchedule = (
|
|
year_group_id: number,
|
|
payload: { title: string; start_date: string; end_date: string },
|
|
) => {
|
|
return axiosInstance.post(
|
|
`coordinator/examination_schedule/${year_group_id}/`,
|
|
payload,
|
|
)
|
|
}
|
|
|
|
export const setEventDate = ({
|
|
id,
|
|
start_date,
|
|
end_date,
|
|
}: {
|
|
id: number
|
|
start_date: string
|
|
end_date: string
|
|
}) => {
|
|
return axiosInstance.put(`coordinator/examination_schedule/${id}/date`, {
|
|
start_date,
|
|
end_date,
|
|
})
|
|
}
|
|
|
|
export const assignGroup = ({
|
|
scheduleId,
|
|
enrollmentId,
|
|
studentIndex,
|
|
}: {
|
|
scheduleId: number
|
|
enrollmentId: number
|
|
studentIndex: number
|
|
}) => {
|
|
return axiosInstance.post(
|
|
`students/${scheduleId}/enrollments/${enrollmentId}/`,
|
|
{
|
|
student_index: studentIndex,
|
|
},
|
|
)
|
|
}
|
|
|
|
export const assignSupervisor = ({
|
|
scheduleId,
|
|
enrollmentId,
|
|
supervisorId,
|
|
}: {
|
|
scheduleId: number
|
|
enrollmentId: number
|
|
supervisorId: number
|
|
}) => {
|
|
return axiosInstance.post(
|
|
`project_supervisor/${scheduleId}/enrollments/${enrollmentId}/`,
|
|
{
|
|
project_supervisor_id: supervisorId,
|
|
},
|
|
)
|
|
}
|
|
|
|
export const downloadSchedule = (scheduleId: number) =>
|
|
axiosInstance.post(
|
|
`coordinator/examination_schedule/${scheduleId}/download/`,
|
|
{
|
|
responseType: 'blob',
|
|
},
|
|
)
|
|
|
|
export const addAvailability = ({
|
|
start_date,
|
|
end_date,
|
|
scheduleId,
|
|
project_supervisor_id,
|
|
}: {
|
|
start_date: string
|
|
end_date: string
|
|
scheduleId: number
|
|
project_supervisor_id: number
|
|
}) => {
|
|
return axiosInstance.post(`project_supervisor/${scheduleId}/enrollments/`, {
|
|
start_date,
|
|
end_date,
|
|
project_supervisor_id,
|
|
})
|
|
}
|
|
|
|
export const setDateOfExaminationSchedule = (
|
|
scheduleId: number,
|
|
payload: {
|
|
start_date_for_enrollment_students: string
|
|
end_date_for_enrollment_students: string
|
|
},
|
|
) => {
|
|
return axiosInstance.put(
|
|
`coordinator/examination_schedule/${scheduleId}/date`,
|
|
payload,
|
|
)
|
|
}
|
|
|
|
export const generateTermsOfDefence = (scheduleId: number) => {
|
|
return axiosInstance.post(`coordinator/enrollments/${scheduleId}/generate`)
|
|
}
|
|
|
|
export const geWorkloadStatistics = (scheduleId: number) => {
|
|
return axiosInstance.get<{
|
|
workloads: {
|
|
assigned_to_committee: number
|
|
full_name: string
|
|
groups_assigned_to_his_committee: number
|
|
}[]
|
|
}>(`coordinator/examination_schedule/${scheduleId}/workloads/`)
|
|
}
|