update curl api
This commit is contained in:
@@ -2,7 +2,8 @@ import api from "./api";
|
||||
import { Activite, Athlete, Coach, Session, User } from "./classes";
|
||||
//import { useKeycloak } from '@react-keycloak/web'
|
||||
|
||||
//const { keycloak } = useKeycloak()
|
||||
import { useKeycloak } from '@react-keycloak/web'
|
||||
import { useAuthHeader } from "./hook/useAuthHeader";
|
||||
/*
|
||||
const useAuthHeader = () => {
|
||||
return keycloak?.token
|
||||
@@ -72,7 +73,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(`/sessions/${session.id}/unsubscribe`, { userId: user.id });
|
||||
await api.post(`/session/${session.id}/unsubscribe`, { userId: user.id });
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.error("Error unsubscribing from session:", error);
|
||||
@@ -93,9 +94,9 @@ export async function updateAllUserAPI(){
|
||||
// POST /////////////////////////////////////////////////////////
|
||||
|
||||
// COACH ADMIN
|
||||
export async function createSessionAPI(newSession: Session): Promise<Session> {
|
||||
export async function createSessionAPI(sessionDTO: any): Promise<Session> {
|
||||
try {
|
||||
const response = await api.post<Session>("/sessions", newSession);
|
||||
const response = await api.post<Session>("/session/create", sessionDTO);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error("Error creating session:", error);
|
||||
@@ -105,7 +106,7 @@ export async function createSessionAPI(newSession: Session): Promise<Session> {
|
||||
|
||||
export async function postActivityAPI(session: Session, activity: Activite){
|
||||
try {
|
||||
const response = await api.post<Activite>(`/sessions/${session.id}/activities`, activity);
|
||||
const response = await api.post<Activite>(`/session/${session.id}/activities`, activity);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error("Error creating activity:", error);
|
||||
@@ -131,7 +132,7 @@ export async function setSessionCreneauAPI(session: Session, date:Date){
|
||||
|
||||
export async function getSessionsAPI(): Promise<Session[]> {
|
||||
try {
|
||||
const response = await api.get<Session[]>("/sessions");
|
||||
const response = await api.get<Session[]>("/session");
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error("Error fetching sessions:", error);
|
||||
|
||||
Reference in New Issue
Block a user