copied the code from the working repo
This commit is contained in:
77
mtucijobsweb/api/api.ts
Normal file
77
mtucijobsweb/api/api.ts
Normal file
@@ -0,0 +1,77 @@
|
||||
import { FormValues, JobsSearch, Request, Student } from '@/types/types';
|
||||
import { $mtuciApi } from './axiosInstance';
|
||||
|
||||
export const sendStudent = async (postData: Request) => {
|
||||
try {
|
||||
const response = await $mtuciApi.post(`/students/`, postData);
|
||||
return response;
|
||||
} catch (error) {
|
||||
console.error('Error post student:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export const editStudent = async (
|
||||
postData: Omit<Student, 'StudentID'>,
|
||||
id: number
|
||||
) => {
|
||||
try {
|
||||
const response = await $mtuciApi.put(`/students/${id}`, postData);
|
||||
return response;
|
||||
} catch (error) {
|
||||
console.error('Error post student:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export const fetchStudent = async (id: number) => {
|
||||
try {
|
||||
const response = await $mtuciApi.get(`/students/${id}`);
|
||||
return response;
|
||||
} catch (error) {
|
||||
console.error('Error fetching student:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
export const deleteStudent = async (id: number) => {
|
||||
try {
|
||||
const response = await $mtuciApi.delete(`/students/${id}`);
|
||||
return response;
|
||||
} catch (error) {
|
||||
console.error('Error fetching student:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export const fetchHardSkills = async (id: number) => {
|
||||
try {
|
||||
const response = await $mtuciApi.get(`/students/hardskills/${id}`);
|
||||
return response;
|
||||
} catch (error) {
|
||||
console.error('Error fetching student:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export const searchJobs = async (params: JobsSearch) => {
|
||||
try {
|
||||
const response = await $mtuciApi.get('/students/jobs-search/', { params });
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Error search jobs', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export const fetchHardSkillsAll = async (): Promise<
|
||||
{ Hard_skillID: number; Title: string }[]
|
||||
> => {
|
||||
try {
|
||||
const response = await $mtuciApi.get(`/services/hardskills/`);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Error fetching hard skills:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user