ajout d'activité
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import api from "./api";
|
||||
import { Activite, Athlete, Coach, Session, User } from "./classes";
|
||||
import { Activite, Admin, Athlete, Coach, Session, User } from "./classes";
|
||||
|
||||
//debug:
|
||||
export function delay(ms: number): Promise<void> {
|
||||
@@ -53,7 +53,7 @@ export async function updateActivitiesOfSessionAPI(session:Session){
|
||||
|
||||
export async function subscribeSessionAPI(user:User, session:Session):Promise<boolean>{
|
||||
try {
|
||||
await api.post(`/sessions/${session.id}/subscribe`, { userId: user.id });
|
||||
await api.post(`/sessions/${session.id}/subscribe`);
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.error("Error subscribing to session:", error);
|
||||
@@ -63,7 +63,7 @@ export async function subscribeSessionAPI(user:User, session:Session):Promise<bo
|
||||
|
||||
export async function unsubscribeSessionAPI(user:User, session:Session):Promise<boolean>{
|
||||
try {
|
||||
await api.post(`/session/${session.id}/unsubscribe`, { userId: user.id });
|
||||
await api.post(`/session/${session.id}/unsubscribe`);
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.error("Error unsubscribing from session:", error);
|
||||
@@ -104,8 +104,26 @@ export async function postActivityAPI(session: Session, activity: Activite){
|
||||
}
|
||||
}
|
||||
|
||||
export async function postUser(user: User):Promise<boolean>{
|
||||
return true;
|
||||
export async function postAthlete(athlete: Athlete):Promise<Athlete>{
|
||||
try {
|
||||
const response = await api.post<Athlete>("/athlete/create/",athlete);
|
||||
console.log(response);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error("Error fetching coachs:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
export async function postAdmin(athlete: Admin):Promise<Admin>{
|
||||
try {
|
||||
const response = await api.post<Admin>("/admin/create/",athlete);
|
||||
console.log(response);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error("Error fetching coachs:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// SET /////////////////////////////////////////////////////////
|
||||
@@ -142,6 +160,7 @@ export async function getUsersAPI(): Promise<User[]> {
|
||||
export async function getCoachsAPI(): Promise<Coach[]> {
|
||||
try {
|
||||
const response = await api.get<Coach[]>("/coach/all");
|
||||
console.log(response);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error("Error fetching coachs:", error);
|
||||
|
||||
Reference in New Issue
Block a user