mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-28 23:43:22 +00:00
56 lines
1.4 KiB
JavaScript
56 lines
1.4 KiB
JavaScript
import {
|
|
BE_SCHOOL_SPECIALITIES_URL,
|
|
BE_SCHOOL_TEACHERS_URL,
|
|
BE_SCHOOL_SCHOOLCLASSES_URL,
|
|
BE_SCHOOL_PLANNINGS_URL,
|
|
BE_SCHOOL_FEES_URL,
|
|
BE_SCHOOL_DISCOUNTS_URL
|
|
} from '@/utils/Url';
|
|
|
|
const requestResponseHandler = async (response) => {
|
|
|
|
const body = await response.json();
|
|
if (response.ok) {
|
|
return body;
|
|
}
|
|
// Throw an error with the JSON body containing the form errors
|
|
const error = new Error('Form submission error');
|
|
error.details = body;
|
|
throw error;
|
|
}
|
|
|
|
|
|
export const fetchSpecialities = () => {
|
|
return fetch(`${BE_SCHOOL_SPECIALITIES_URL}`)
|
|
.then(requestResponseHandler)
|
|
};
|
|
|
|
export const fetchTeachers = () => {
|
|
return fetch(`${BE_SCHOOL_TEACHERS_URL}`)
|
|
.then(requestResponseHandler)
|
|
};
|
|
|
|
export const fetchClasses = () => {
|
|
return fetch(`${BE_SCHOOL_SCHOOLCLASSES_URL}`)
|
|
.then(requestResponseHandler)
|
|
};
|
|
|
|
export const fetchSchedules = () => {
|
|
return fetch(`${BE_SCHOOL_PLANNINGS_URL}`)
|
|
.then(requestResponseHandler)
|
|
};
|
|
|
|
export const fetchDiscounts = () => {
|
|
return fetch(`${BE_SCHOOL_DISCOUNTS_URL}`)
|
|
.then(requestResponseHandler)
|
|
};
|
|
|
|
export const fetchRegistrationFees = () => {
|
|
return fetch(`${BE_SCHOOL_FEES_URL}/registration`)
|
|
.then(requestResponseHandler)
|
|
};
|
|
|
|
export const fetchTuitionFees = () => {
|
|
return fetch(`${BE_SCHOOL_FEES_URL}/tuition`)
|
|
.then(requestResponseHandler)
|
|
}; |