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;
|
||||
}
|
||||
};
|
||||
10
mtucijobsweb/api/axiosInstance.ts
Normal file
10
mtucijobsweb/api/axiosInstance.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import axios from 'axios';
|
||||
|
||||
export const $mtuciApi = axios.create({
|
||||
baseURL: process.env.NEXT_PUBLIC_APP_BASE_URL, // NEXT_PUBLIC_ для переменных окружения, доступных на клиенте
|
||||
headers: {
|
||||
Accept: '*/*',
|
||||
'X-API-KEY':
|
||||
'SbRHOVoK97GKCx3Lqx6hKXLbZZJEd0GTGbeglXdpK9PhSB9kpr4eWCsuIIwnD6F2mgpTDlVHFCRbeFmuSfqBVsb12lNwF3P1tmdxiktl7zH9sDS2YK7Pyj2DecCWAZ3n',
|
||||
},
|
||||
});
|
||||
15
mtucijobsweb/api/bot.ts
Normal file
15
mtucijobsweb/api/bot.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { Bot } from '@/types/types';
|
||||
import axios from 'axios';
|
||||
|
||||
export const sendDataBot = async (dataBot: Bot) => {
|
||||
try {
|
||||
const response = await axios.post(
|
||||
`${process.env.NEXT_PUBLIC_BOT_URL}/api/resume/`,
|
||||
dataBot
|
||||
);
|
||||
return response;
|
||||
} catch (error) {
|
||||
console.error('Error post student:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user