mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 16:03:21 +00:00
feat: Gestion multi-profil multi-école
This commit is contained in:
@ -30,6 +30,7 @@ export const login = (data) => {
|
||||
redirect: false,
|
||||
email: data.email,
|
||||
password: data.password,
|
||||
role_type: data.role_type,
|
||||
})
|
||||
};
|
||||
|
||||
@ -194,7 +195,11 @@ export const getUser = async () => {
|
||||
return {
|
||||
id: session.user.user_id,
|
||||
email: session.user.email,
|
||||
role: session.user.droit
|
||||
roles: session.user.roles.map(role => ({
|
||||
role_type: role.role_type,
|
||||
establishment_id: role.establishment__id,
|
||||
establishment_name: role.establishment__name
|
||||
}))
|
||||
};
|
||||
|
||||
} catch (error) {
|
||||
|
||||
@ -7,8 +7,7 @@ import {
|
||||
BE_SCHOOL_DISCOUNTS_URL,
|
||||
BE_SCHOOL_PAYMENT_PLANS_URL,
|
||||
BE_SCHOOL_PAYMENT_MODES_URL,
|
||||
BE_SCHOOL_ESTABLISHMENT_URL,
|
||||
ESTABLISHMENT_ID
|
||||
BE_SCHOOL_ESTABLISHMENT_URL
|
||||
} from '@/utils/Url';
|
||||
|
||||
const requestResponseHandler = async (response) => {
|
||||
@ -24,18 +23,18 @@ const requestResponseHandler = async (response) => {
|
||||
}
|
||||
|
||||
|
||||
export const fetchSpecialities = () => {
|
||||
return fetch(`${BE_SCHOOL_SPECIALITIES_URL}`)
|
||||
export const fetchSpecialities = (establishment) => {
|
||||
return fetch(`${BE_SCHOOL_SPECIALITIES_URL}?establishment_id=${establishment}`)
|
||||
.then(requestResponseHandler)
|
||||
};
|
||||
|
||||
export const fetchTeachers = () => {
|
||||
return fetch(`${BE_SCHOOL_TEACHERS_URL}`)
|
||||
export const fetchTeachers = (establishment) => {
|
||||
return fetch(`${BE_SCHOOL_TEACHERS_URL}?establishment_id=${establishment}`)
|
||||
.then(requestResponseHandler)
|
||||
};
|
||||
|
||||
export const fetchClasses = () => {
|
||||
return fetch(`${BE_SCHOOL_SCHOOLCLASSES_URL}`)
|
||||
export const fetchClasses = (establishment) => {
|
||||
return fetch(`${BE_SCHOOL_SCHOOLCLASSES_URL}?establishment_id=${establishment}`)
|
||||
.then(requestResponseHandler)
|
||||
};
|
||||
|
||||
@ -44,48 +43,48 @@ export const fetchSchedules = () => {
|
||||
.then(requestResponseHandler)
|
||||
};
|
||||
|
||||
export const fetchRegistrationDiscounts = () => {
|
||||
return fetch(`${BE_SCHOOL_DISCOUNTS_URL}?filter=registration`)
|
||||
export const fetchRegistrationDiscounts = (establishment) => {
|
||||
return fetch(`${BE_SCHOOL_DISCOUNTS_URL}?filter=registration&establishment_id=${establishment}`)
|
||||
.then(requestResponseHandler)
|
||||
};
|
||||
|
||||
export const fetchTuitionDiscounts = () => {
|
||||
return fetch(`${BE_SCHOOL_DISCOUNTS_URL}?filter=tuition`)
|
||||
export const fetchTuitionDiscounts = (establishment) => {
|
||||
return fetch(`${BE_SCHOOL_DISCOUNTS_URL}?filter=tuition&establishment_id=${establishment}`)
|
||||
.then(requestResponseHandler)
|
||||
};
|
||||
|
||||
export const fetchRegistrationFees = () => {
|
||||
return fetch(`${BE_SCHOOL_FEES_URL}?filter=registration`)
|
||||
export const fetchRegistrationFees = (establishment) => {
|
||||
return fetch(`${BE_SCHOOL_FEES_URL}?filter=registration&establishment_id=${establishment}`)
|
||||
.then(requestResponseHandler)
|
||||
};
|
||||
|
||||
export const fetchTuitionFees = () => {
|
||||
return fetch(`${BE_SCHOOL_FEES_URL}?filter=tuition`)
|
||||
export const fetchTuitionFees = (establishment) => {
|
||||
return fetch(`${BE_SCHOOL_FEES_URL}?filter=tuition&establishment_id=${establishment}`)
|
||||
.then(requestResponseHandler)
|
||||
};
|
||||
|
||||
export const fetchRegistrationPaymentPlans = () => {
|
||||
return fetch(`${BE_SCHOOL_PAYMENT_PLANS_URL}?filter=registration`)
|
||||
export const fetchRegistrationPaymentPlans = (establishment) => {
|
||||
return fetch(`${BE_SCHOOL_PAYMENT_PLANS_URL}?filter=registration&establishment_id=${establishment}`)
|
||||
.then(requestResponseHandler)
|
||||
}
|
||||
|
||||
export const fetchTuitionPaymentPlans = () => {
|
||||
return fetch(`${BE_SCHOOL_PAYMENT_PLANS_URL}?filter=tuition`)
|
||||
export const fetchTuitionPaymentPlans = (establishment) => {
|
||||
return fetch(`${BE_SCHOOL_PAYMENT_PLANS_URL}?filter=tuition&establishment_id=${establishment}`)
|
||||
.then(requestResponseHandler)
|
||||
}
|
||||
|
||||
export const fetchRegistrationPaymentModes = () => {
|
||||
return fetch(`${BE_SCHOOL_PAYMENT_MODES_URL}?filter=registration`)
|
||||
export const fetchRegistrationPaymentModes = (establishment) => {
|
||||
return fetch(`${BE_SCHOOL_PAYMENT_MODES_URL}?filter=registration&establishment_id=${establishment}`)
|
||||
.then(requestResponseHandler)
|
||||
}
|
||||
|
||||
export const fetchTuitionPaymentModes = () => {
|
||||
return fetch(`${BE_SCHOOL_PAYMENT_MODES_URL}?filter=tuition`)
|
||||
export const fetchTuitionPaymentModes = (establishment) => {
|
||||
return fetch(`${BE_SCHOOL_PAYMENT_MODES_URL}?filter=tuition&establishment_id=${establishment}`)
|
||||
.then(requestResponseHandler)
|
||||
}
|
||||
|
||||
export const fetchEstablishment = () => {
|
||||
return fetch(`${BE_SCHOOL_ESTABLISHMENT_URL}/${ESTABLISHMENT_ID}`)
|
||||
export const fetchEstablishment = (establishment) => {
|
||||
return fetch(`${BE_SCHOOL_ESTABLISHMENT_URL}/${establishment}`)
|
||||
.then(requestResponseHandler)
|
||||
}
|
||||
|
||||
|
||||
@ -100,7 +100,7 @@ export const archiveRegisterForm = (id) => {
|
||||
}
|
||||
|
||||
export const fetchStudents = (id=null, establishment) => {
|
||||
const url = (id)?`${BE_SUBSCRIPTION_STUDENTS_URL}/${id}`:`${BE_SUBSCRIPTION_STUDENTS_URL}?establishment_id=${establishment}`;
|
||||
const url = (id)?`${BE_SUBSCRIPTION_STUDENTS_URL}/${id}?establishment_id=${establishment}`:`${BE_SUBSCRIPTION_STUDENTS_URL}?establishment_id=${establishment}`;
|
||||
const request = new Request(
|
||||
url,
|
||||
{
|
||||
@ -114,9 +114,9 @@ export const fetchStudents = (id=null, establishment) => {
|
||||
|
||||
};
|
||||
|
||||
export const fetchChildren = (id) =>{
|
||||
export const fetchChildren = (id, establishment) =>{
|
||||
const request = new Request(
|
||||
`${BE_SUBSCRIPTION_CHILDRENS_URL}/${id}`,
|
||||
`${BE_SUBSCRIPTION_CHILDRENS_URL}/${id}?establishment_id=${establishment}`,
|
||||
{
|
||||
method:'GET',
|
||||
headers: {
|
||||
|
||||
Reference in New Issue
Block a user