Merge branch 'main' of https://gitlab2.istic.univ-rennes1.fr/tuvu/hackathon
This commit is contained in:
@@ -64,9 +64,21 @@ export async function loginOrRegister(keycloak:Keycloak): Promise<User|null>{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateActivitiesOfSessionAPI(session:Session){
|
export async function updateActivitiesOfSessionAPI(session:Session,activities:Activite[]){
|
||||||
try {
|
try {
|
||||||
const response = await api.get<Activite[]>(`/sessions/${session.id}/activities`);
|
const session_id = session.id
|
||||||
|
for (const activity of activities) {
|
||||||
|
const response = await activiteService.update(activity.id!, {
|
||||||
|
name: activity.nom,
|
||||||
|
duree: activity.duree,
|
||||||
|
date: activity.data,
|
||||||
|
theme: activity.theme,
|
||||||
|
sessionId: session_id,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// To refresh the activities in the session object
|
||||||
|
const response = await sessionService.getActivities(session_id!);
|
||||||
session.activites = response.data;
|
session.activites = response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching activities for session:", error);
|
console.error("Error fetching activities for session:", error);
|
||||||
@@ -76,7 +88,9 @@ export async function updateActivitiesOfSessionAPI(session:Session){
|
|||||||
|
|
||||||
export async function subscribeSessionAPI(user:User, session:Session):Promise<boolean>{
|
export async function subscribeSessionAPI(user:User, session:Session):Promise<boolean>{
|
||||||
try {
|
try {
|
||||||
await api.post(`/sessions/${session.id}/subscribe`);
|
const session_id =session.id
|
||||||
|
const user_id = user.id
|
||||||
|
const response = await sessionService.subscribe(session_id!, user_id!);
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error subscribing to session:", error);
|
console.error("Error subscribing to session:", error);
|
||||||
@@ -86,7 +100,9 @@ export async function subscribeSessionAPI(user:User, session:Session):Promise<bo
|
|||||||
|
|
||||||
export async function unsubscribeSessionAPI(user:User, session:Session):Promise<boolean>{
|
export async function unsubscribeSessionAPI(user:User, session:Session):Promise<boolean>{
|
||||||
try {
|
try {
|
||||||
await api.post(`/session/${session.id}/unsubscribe`);
|
const session_id =session.id
|
||||||
|
const user_id = user.id
|
||||||
|
const response = await sessionService.unsubscribe(session_id!, user_id!);
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error unsubscribing from session:", error);
|
console.error("Error unsubscribing from session:", error);
|
||||||
@@ -209,6 +225,16 @@ export async function getSessionsOfUserAPI(user:Coach|Athlete){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getAllSessionsAPI():Promise<Session[]>{
|
||||||
|
try {
|
||||||
|
const response = await sessionService.getAll();
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching sessions:", error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//COACH
|
//COACH
|
||||||
export async function getAllCoach(): Promise<Coach[]> {
|
export async function getAllCoach(): Promise<Coach[]> {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user