réparation constants redux

redux
mohamed 2 years ago
parent 782a5aa86c
commit 4754741fab

@ -1,53 +1,3 @@
import { Geocalisation } from "../core/Geocalisation"; export const FETCH_USERS = 'FETCH_USERS';
import { Lap } from "../core/Lap"; export const FETCH_TEAMS = 'FETCH_TEAMS';
import { Member } from "../core/Member"; export const FETCH_SESSIONS = 'FETCH_SESSIONS';
import { Owner } from "../core/Owner";
import { Point } from "../core/Point";
import { Session } from "../core/Session";
import { SessionType } from "../core/SessionType";
import { Team } from "../core/Team";
import { User } from "../core/User";
import { WaitingMember } from "../core/WaitingMember";
const owner1 = new Owner("eric", "PASSWORD123", "eric@gmail.com", []);
const owner2 = new Owner("castor", "PASSWORD123", "castor@gmail.com", []);
export const Fetch_Users: User[] = [
new Member("stickman", "PASSWORD123", "stickman@gmail.com", []),
new Member("crapaud", "PASSWORD123", "crapaud@gmail.com", []),
new WaitingMember("mcdo", "PASSWORD123", "mcdo@gmail.com", []),
new WaitingMember("bucheron", "PASSWORD123", "bucheron@gmail.com", []),
]
export const Fetch_Teams: Team[] = [
new Team("La team 1", owner1, Fetch_Users),
new Team("Bat INFO", owner2, Fetch_Users)
]
export const Fetch_Laps: Lap[] = [
]
const geo1 = new Geocalisation(40.7128, -74.0060);
const geo2 = new Geocalisation(51.5074, -0.1278);
const geo3 = new Geocalisation(35.6895, 139.6917);
const point1 = new Point(geo1, 120, 10, 3, 50, 90, 20, 10, 20, 100);
const point2 = new Point(geo2, 130, 15, 4, 60, 100, 30, 15, 25, 120);
const point3 = new Point(geo3, 140, 20, 5, 70, 110, 40, 20, 30, 140);
const lap1 = new Lap(1, [point1, point2], 250);
const lap2 = new Lap(2, [point2, point3], 300);
const lap3 = new Lap(3, [point3, point1], 350);
const session1 = new Session("First Session", [lap1, lap2], SessionType.PrivateTest);
const session2 = new Session("Second Session", [lap2, lap3], SessionType.Qualification);
const session3 = new Session("Third Session", [lap3, lap1], SessionType.Unknown);
export const Fetch_Sessions: Session[] = [
session1, session2, session3
]

@ -2,11 +2,11 @@ import { Geocalisation } from "../../core/Geocalisation";
import { Lap } from "../../core/Lap"; import { Lap } from "../../core/Lap";
import { Point } from "../../core/Point"; import { Point } from "../../core/Point";
import { Session } from "../../core/Session"; import { Session } from "../../core/Session";
import { Fetch_Sessions } from "../Constants"; import { FETCH_SESSIONS } from "../Constants";
export const setSessionsList = (sessionsList: Session[]) => { export const setSessionsList = (sessionsList: Session[]) => {
return { return {
type: Fetch_Sessions, type: FETCH_SESSIONS,
payload: sessionsList, payload: sessionsList,
}; };
} }

@ -1,9 +1,9 @@
import { Team } from "../../core/Team"; import { Team } from "../../core/Team";
import { Fetch_Teams } from "../Constants"; import { FETCH_TEAMS } from "../Constants";
export const setTeamsList = (teamsList: Team[]) => { export const setTeamsList = (teamsList: Team[]) => {
return { return {
type: Fetch_Teams, type: FETCH_TEAMS,
payload: teamsList, payload: teamsList,
}; };
} }

@ -3,12 +3,12 @@ import { Owner } from "../../core/Owner";
import { Team } from "../../core/Team"; import { Team } from "../../core/Team";
import { User } from "../../core/User"; import { User } from "../../core/User";
import { WaitingMember } from "../../core/WaitingMember"; import { WaitingMember } from "../../core/WaitingMember";
import { Fetch_Users } from "../Constants"; import { FETCH_USERS } from "../Constants";
import { DtoUserEcurie } from "../dto/dtoUserEcurie"; import { DtoUserEcurie } from "../dto/dtoUserEcurie";
export const setUsersList = (usersList: User[]) => { export const setUsersList = (usersList: User[]) => {
return { return {
type: Fetch_Users, type: FETCH_USERS,
payload: usersList, payload: usersList,
}; };
} }

@ -6,12 +6,12 @@ const initialState = {
const appReducer = (state = initialState, action: { type: any; payload: any; }) => { const appReducer = (state = initialState, action: { type: any; payload: any; }) => {
switch (action.type) { switch (action.type) {
case 'Fetch_Teams': case 'FETCH_TEAMS':
return { ...state, teams: [...state.teams, action.payload] }; return { ...state, teams: action.payload };
case 'Fetch_Users': case 'FETCH_USERS':
return { ...state, users: [...state.users, action.payload] }; return { ...state, users: action.payload };
case 'Fetch_Sessions': case 'FETCH_SESSIONS':
return { ...state, sessions: [...state.sessions, action.payload] }; return { ...state, sessions: action.payload };
default: default:
return state; return state;
} }

Loading…
Cancel
Save