68 lines
2.2 KiB
JavaScript
68 lines
2.2 KiB
JavaScript
import axios from 'src/utils/axios';
|
|
|
|
// Students (mentor's clients)
|
|
export async function getStudents(params) {
|
|
const res = await axios.get('/manage/clients/', { params });
|
|
const {data} = res;
|
|
if (Array.isArray(data)) return { results: data, count: data.length };
|
|
return { results: data?.results ?? [], count: data?.count ?? 0 };
|
|
}
|
|
|
|
// Invite student by email or universal_code
|
|
export async function addStudentInvitation(payload) {
|
|
const res = await axios.post('/manage/clients/add_client/', payload);
|
|
return res.data;
|
|
}
|
|
|
|
// Generate invitation link for mentor
|
|
export async function generateInvitationLink() {
|
|
const res = await axios.post('/manage/clients/generate-invitation-link/');
|
|
return res.data;
|
|
}
|
|
|
|
// Pending mentorship requests for mentor
|
|
export async function getMentorshipRequestsPending() {
|
|
const res = await axios.get('/mentorship-requests/pending/');
|
|
return res.data;
|
|
}
|
|
|
|
export async function acceptMentorshipRequest(id) {
|
|
const res = await axios.post(`/mentorship-requests/${id}/accept/`);
|
|
return res.data;
|
|
}
|
|
|
|
export async function rejectMentorshipRequest(id) {
|
|
const res = await axios.post(`/mentorship-requests/${id}/reject/`);
|
|
return res.data;
|
|
}
|
|
|
|
// Client: send mentorship request to mentor by code
|
|
export async function sendMentorshipRequest(mentorCode) {
|
|
const res = await axios.post('/mentorship-requests/send/', {
|
|
mentor_code: mentorCode.trim().toUpperCase(),
|
|
});
|
|
return res.data;
|
|
}
|
|
|
|
// Client: my mentors
|
|
export async function getMyMentors() {
|
|
const res = await axios.get('/mentorship-requests/my-mentors/');
|
|
return res.data;
|
|
}
|
|
|
|
// Client: incoming invitations from mentors
|
|
export async function getMyInvitations() {
|
|
const res = await axios.get('/invitation/my-invitations/');
|
|
return res.data;
|
|
}
|
|
|
|
export async function confirmInvitationAsStudent(invitationId) {
|
|
const res = await axios.post('/invitation/confirm-as-student/', { invitation_id: invitationId });
|
|
return res.data;
|
|
}
|
|
|
|
export async function rejectInvitationAsStudent(invitationId) {
|
|
const res = await axios.post('/invitation/reject-as-student/', { invitation_id: invitationId });
|
|
return res.data;
|
|
}
|