Add base_url env
This commit is contained in:
parent
b0e48d3703
commit
3125a696e4
1
frontend/.env.example
Normal file
1
frontend/.env.example
Normal file
@ -0,0 +1 @@
|
|||||||
|
REACT_APP_BASE_URL=http://localhost:5000/api/
|
2
frontend/.gitignore
vendored
2
frontend/.gitignore
vendored
@ -21,3 +21,5 @@
|
|||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
yarn-debug.log*
|
yarn-debug.log*
|
||||||
yarn-error.log*
|
yarn-error.log*
|
||||||
|
|
||||||
|
.env
|
@ -1,5 +1,7 @@
|
|||||||
import axios from "axios";
|
import axios from 'axios'
|
||||||
|
|
||||||
const axiosInstance = axios.create({});
|
const axiosInstance = axios.create({
|
||||||
|
baseURL: process.env.REACT_APP_BASE_URL,
|
||||||
|
})
|
||||||
|
|
||||||
export default axiosInstance;
|
export default axiosInstance
|
||||||
|
@ -18,9 +18,6 @@ export const getEnrollmentList = (
|
|||||||
email: string
|
email: string
|
||||||
mode: number
|
mode: number
|
||||||
}[]
|
}[]
|
||||||
}>(
|
}>(`students/registrations/${params.year_group_id}`, {
|
||||||
`http://127.0.0.1:5000/api/students/registrations/${params.year_group_id}`,
|
params,
|
||||||
{
|
})
|
||||||
params,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
@ -27,17 +27,14 @@ export const getGroups = (
|
|||||||
}>,
|
}>,
|
||||||
) =>
|
) =>
|
||||||
axiosInstance.get<{ max_pages: number; groups: Group[] }>(
|
axiosInstance.get<{ max_pages: number; groups: Group[] }>(
|
||||||
`http://127.0.0.1:5000/api/coordinator/groups/${params.year_group_id}`,
|
`coordinator/groups/${params.year_group_id}`,
|
||||||
{
|
{
|
||||||
params,
|
params,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
export const createGroup = (year_group_id: number, payload: CreateGroup) =>
|
export const createGroup = (year_group_id: number, payload: CreateGroup) =>
|
||||||
axiosInstance.post(
|
axiosInstance.post(`coordinator/groups/${year_group_id}`, payload)
|
||||||
`http://127.0.0.1:5000/api/coordinator/groups/${year_group_id}`,
|
|
||||||
payload,
|
|
||||||
)
|
|
||||||
|
|
||||||
export const deleteGroup = (id: number) =>
|
export const deleteGroup = (id: number) =>
|
||||||
axiosInstance.delete(`http://127.0.0.1:5000/api/coordinator/groups/${id}/`)
|
axiosInstance.delete(`coordinator/groups/${id}/`)
|
||||||
|
@ -28,17 +28,12 @@ export const getLeaders = (
|
|||||||
}> = {},
|
}> = {},
|
||||||
) =>
|
) =>
|
||||||
axiosInstance.get<LeaderResponse>(
|
axiosInstance.get<LeaderResponse>(
|
||||||
`http://127.0.0.1:5000/api/coordinator/project_supervisor/${params.year_group_id}`,
|
`coordinator/project_supervisor/${params.year_group_id}`,
|
||||||
{ params },
|
{ params },
|
||||||
)
|
)
|
||||||
|
|
||||||
export const createLeader = (payload: Leader) =>
|
export const createLeader = (payload: Leader) =>
|
||||||
axiosInstance.post(
|
axiosInstance.post('coordinator/project_supervisor/', payload)
|
||||||
'http://127.0.0.1:5000/api/coordinator/project_supervisor/',
|
|
||||||
payload,
|
|
||||||
)
|
|
||||||
|
|
||||||
export const deleteLeader = (id: number) =>
|
export const deleteLeader = (id: number) =>
|
||||||
axiosInstance.delete(
|
axiosInstance.delete(`coordinator/project_supervisor/${id}/`)
|
||||||
`http://127.0.0.1:5000/api/coordinator/project_supervisor/${id}/`,
|
|
||||||
)
|
|
||||||
|
@ -12,9 +12,7 @@ export const getTermsOfDefences = (scheduleId: number) => {
|
|||||||
}
|
}
|
||||||
group: { name: string }
|
group: { name: string }
|
||||||
}[]
|
}[]
|
||||||
}>(
|
}>(`coordinator/enrollments/${scheduleId}/term-of-defences/`)
|
||||||
`http://127.0.0.1:5000/api/coordinator/enrollments/${scheduleId}/term-of-defences/`,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getStudentsTermsOfDefences = (scheduleId: number) => {
|
export const getStudentsTermsOfDefences = (scheduleId: number) => {
|
||||||
@ -29,9 +27,7 @@ export const getStudentsTermsOfDefences = (scheduleId: number) => {
|
|||||||
}
|
}
|
||||||
group: { name: string }
|
group: { name: string }
|
||||||
}[]
|
}[]
|
||||||
}>(
|
}>(`students/examination-schedule/${scheduleId}/enrollments/`)
|
||||||
`http://127.0.0.1:5000/api/students/examination-schedule/${scheduleId}/enrollments/`,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
export const getSchedules = (year_group_id: number = 1) => {
|
export const getSchedules = (year_group_id: number = 1) => {
|
||||||
return axiosInstance.get<{
|
return axiosInstance.get<{
|
||||||
@ -42,9 +38,7 @@ export const getSchedules = (year_group_id: number = 1) => {
|
|||||||
title: string
|
title: string
|
||||||
mode: boolean
|
mode: boolean
|
||||||
}[]
|
}[]
|
||||||
}>(
|
}>(`coordinator/examination_schedule/${year_group_id}?per_page=10000`)
|
||||||
`http://127.0.0.1:5000/api/coordinator/examination_schedule/${year_group_id}?per_page=10000`,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createEvent = ({
|
export const createEvent = ({
|
||||||
@ -58,14 +52,11 @@ export const createEvent = ({
|
|||||||
scheduleId: number
|
scheduleId: number
|
||||||
project_supervisors: number[]
|
project_supervisors: number[]
|
||||||
}) => {
|
}) => {
|
||||||
return axiosInstance.post(
|
return axiosInstance.post(`coordinator/enrollments/${scheduleId}/add`, {
|
||||||
`http://127.0.0.1:5000/api/coordinator/enrollments/${scheduleId}/add`,
|
start_date,
|
||||||
{
|
end_date,
|
||||||
start_date,
|
project_supervisors,
|
||||||
end_date,
|
})
|
||||||
project_supervisors,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createSchedule = (
|
export const createSchedule = (
|
||||||
@ -73,7 +64,7 @@ export const createSchedule = (
|
|||||||
payload: { title: string; start_date: string; end_date: string },
|
payload: { title: string; start_date: string; end_date: string },
|
||||||
) => {
|
) => {
|
||||||
return axiosInstance.post(
|
return axiosInstance.post(
|
||||||
`http://127.0.0.1:5000/api/coordinator/examination_schedule/${year_group_id}/`,
|
`coordinator/examination_schedule/${year_group_id}/`,
|
||||||
payload,
|
payload,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -87,13 +78,10 @@ export const setEventDate = ({
|
|||||||
start_date: string
|
start_date: string
|
||||||
end_date: string
|
end_date: string
|
||||||
}) => {
|
}) => {
|
||||||
return axiosInstance.put(
|
return axiosInstance.put(`coordinator/examination_schedule/${id}/date`, {
|
||||||
`http://127.0.0.1:5000/api/coordinator/examination_schedule/${id}/date`,
|
start_date,
|
||||||
{
|
end_date,
|
||||||
start_date,
|
})
|
||||||
end_date,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const assignGroup = ({
|
export const assignGroup = ({
|
||||||
@ -106,7 +94,7 @@ export const assignGroup = ({
|
|||||||
studentIndex: number
|
studentIndex: number
|
||||||
}) => {
|
}) => {
|
||||||
return axiosInstance.post(
|
return axiosInstance.post(
|
||||||
`http://127.0.0.1:5000/api/students/${scheduleId}/enrollments/${enrollmentId}/`,
|
`students/${scheduleId}/enrollments/${enrollmentId}/`,
|
||||||
{
|
{
|
||||||
student_index: studentIndex,
|
student_index: studentIndex,
|
||||||
},
|
},
|
||||||
@ -123,7 +111,7 @@ export const assignSupervisor = ({
|
|||||||
supervisorId: number
|
supervisorId: number
|
||||||
}) => {
|
}) => {
|
||||||
return axiosInstance.post(
|
return axiosInstance.post(
|
||||||
`http://127.0.0.1:5000/api/project_supervisor/${scheduleId}/enrollments/${enrollmentId}/`,
|
`project_supervisor/${scheduleId}/enrollments/${enrollmentId}/`,
|
||||||
{
|
{
|
||||||
project_supervisor_id: supervisorId,
|
project_supervisor_id: supervisorId,
|
||||||
},
|
},
|
||||||
@ -132,7 +120,7 @@ export const assignSupervisor = ({
|
|||||||
|
|
||||||
export const downloadSchedule = (scheduleId: number) =>
|
export const downloadSchedule = (scheduleId: number) =>
|
||||||
axiosInstance.post(
|
axiosInstance.post(
|
||||||
`http://127.0.0.1:5000/api/coordinator/examination_schedule/${scheduleId}/download/`,
|
`coordinator/examination_schedule/${scheduleId}/download/`,
|
||||||
{
|
{
|
||||||
responseType: 'blob',
|
responseType: 'blob',
|
||||||
},
|
},
|
||||||
|
@ -28,30 +28,20 @@ export const getStudents = (
|
|||||||
}> = {},
|
}> = {},
|
||||||
) =>
|
) =>
|
||||||
axiosInstance.get<StudentResponse>(
|
axiosInstance.get<StudentResponse>(
|
||||||
`http://127.0.0.1:5000/api/coordinator/students/${params.year_group_id}`,
|
`coordinator/students/${params.year_group_id}`,
|
||||||
{ params },
|
{ params },
|
||||||
)
|
)
|
||||||
|
|
||||||
export const createStudent = (payload: Student) =>
|
export const createStudent = (payload: Student) =>
|
||||||
axiosInstance.post('http://127.0.0.1:5000/api/coordinator/students/', payload)
|
axiosInstance.post('coordinator/students/', payload)
|
||||||
|
|
||||||
export const uploadStudents = (payload: FormData) =>
|
export const uploadStudents = (payload: FormData) =>
|
||||||
axiosInstance.post(
|
axiosInstance.post('coordinator/students/upload/', payload)
|
||||||
'http://127.0.0.1:5000/api/coordinator/students/upload/',
|
|
||||||
payload,
|
|
||||||
)
|
|
||||||
|
|
||||||
export const deleteStudent = (index: number) =>
|
export const deleteStudent = (index: number) =>
|
||||||
axiosInstance.delete(
|
axiosInstance.delete(`coordinator/students/${index}/`)
|
||||||
`http://127.0.0.1:5000/api/coordinator/students/${index}/`,
|
|
||||||
)
|
|
||||||
|
|
||||||
export const downloadStudents = (mode: boolean) =>
|
export const downloadStudents = (mode: boolean) =>
|
||||||
axiosInstance.post(
|
axiosInstance.post(`coordinator/students/download/?mode=${Number(mode)}`, {
|
||||||
`http://127.0.0.1:5000/api/coordinator/students/download/?mode=${Number(
|
responseType: 'blob',
|
||||||
mode,
|
})
|
||||||
)}`,
|
|
||||||
{
|
|
||||||
responseType: 'blob',
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user