|
|
|
@ -2,6 +2,7 @@ import { Geocalisation } from "../../core/Geocalisation";
|
|
|
|
|
import { Lap } from "../../core/Lap";
|
|
|
|
|
import { Point } from "../../core/Point";
|
|
|
|
|
import { Session } from "../../core/Session";
|
|
|
|
|
import { User } from "../../core/User";
|
|
|
|
|
import { FETCH_SESSIONS } from "../Constants";
|
|
|
|
|
|
|
|
|
|
export const setSessionsList = (sessionsList: Session[]) => {
|
|
|
|
@ -11,10 +12,25 @@ export const setSessionsList = (sessionsList: Session[]) => {
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const getSessionsList = () => {
|
|
|
|
|
export const addXlsFile = async (file: File) => {
|
|
|
|
|
try {
|
|
|
|
|
const formData = new FormData();
|
|
|
|
|
formData.append('file', file);
|
|
|
|
|
const response = await fetch('https://codefirst.iut.uca.fr/containers/enzojolys-r-dash_container/upload', {
|
|
|
|
|
method: 'POST',
|
|
|
|
|
body: formData
|
|
|
|
|
});
|
|
|
|
|
const data = await response.json();
|
|
|
|
|
return data;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.log('Error---------', error);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const getSessionsList = (user: User) => {
|
|
|
|
|
return async dispatch => {
|
|
|
|
|
try {
|
|
|
|
|
const sessionsPromise = await fetch('https://codefirst.iut.uca.fr/containers/enzojolys-r-dash_container/Sessions');
|
|
|
|
|
const sessionsPromise = await fetch('https://codefirst.iut.uca.fr/containers/enzojolys-r-dash_container/Sessions/'+user.getUsername);
|
|
|
|
|
const sessionsListJson = await sessionsPromise.json();
|
|
|
|
|
const sessionsList: Session[] = sessionsListJson.map(elt => {
|
|
|
|
|
const laps: Lap[] = elt.laps.map(lap => {
|
|
|
|
|