From 4754741fabfcc1a294f175ee4a635d01d71b9e1f Mon Sep 17 00:00:00 2001 From: mohamed Date: Wed, 22 Mar 2023 16:15:39 +0100 Subject: [PATCH] =?UTF-8?q?r=C3=A9paration=20constants=20redux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- R-Dash/redux/Constants.ts | 56 ++--------------------------- R-Dash/redux/actions/sessions.ts | 4 +-- R-Dash/redux/actions/teams.ts | 4 +-- R-Dash/redux/actions/users.ts | 4 +-- R-Dash/redux/reducers/appReducer.ts | 12 +++---- 5 files changed, 15 insertions(+), 65 deletions(-) diff --git a/R-Dash/redux/Constants.ts b/R-Dash/redux/Constants.ts index 7d5b0d7..e063f3e 100644 --- a/R-Dash/redux/Constants.ts +++ b/R-Dash/redux/Constants.ts @@ -1,53 +1,3 @@ -import { Geocalisation } from "../core/Geocalisation"; -import { Lap } from "../core/Lap"; -import { Member } from "../core/Member"; -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 -] \ No newline at end of file +export const FETCH_USERS = 'FETCH_USERS'; +export const FETCH_TEAMS = 'FETCH_TEAMS'; +export const FETCH_SESSIONS = 'FETCH_SESSIONS'; \ No newline at end of file diff --git a/R-Dash/redux/actions/sessions.ts b/R-Dash/redux/actions/sessions.ts index 4d51e2f..627162a 100644 --- a/R-Dash/redux/actions/sessions.ts +++ b/R-Dash/redux/actions/sessions.ts @@ -2,11 +2,11 @@ import { Geocalisation } from "../../core/Geocalisation"; import { Lap } from "../../core/Lap"; import { Point } from "../../core/Point"; import { Session } from "../../core/Session"; -import { Fetch_Sessions } from "../Constants"; +import { FETCH_SESSIONS } from "../Constants"; export const setSessionsList = (sessionsList: Session[]) => { return { - type: Fetch_Sessions, + type: FETCH_SESSIONS, payload: sessionsList, }; } diff --git a/R-Dash/redux/actions/teams.ts b/R-Dash/redux/actions/teams.ts index 407dc68..8da7204 100644 --- a/R-Dash/redux/actions/teams.ts +++ b/R-Dash/redux/actions/teams.ts @@ -1,9 +1,9 @@ import { Team } from "../../core/Team"; -import { Fetch_Teams } from "../Constants"; +import { FETCH_TEAMS } from "../Constants"; export const setTeamsList = (teamsList: Team[]) => { return { - type: Fetch_Teams, + type: FETCH_TEAMS, payload: teamsList, }; } diff --git a/R-Dash/redux/actions/users.ts b/R-Dash/redux/actions/users.ts index b9eeb27..dc0a7ec 100644 --- a/R-Dash/redux/actions/users.ts +++ b/R-Dash/redux/actions/users.ts @@ -3,12 +3,12 @@ import { Owner } from "../../core/Owner"; import { Team } from "../../core/Team"; import { User } from "../../core/User"; import { WaitingMember } from "../../core/WaitingMember"; -import { Fetch_Users } from "../Constants"; +import { FETCH_USERS } from "../Constants"; import { DtoUserEcurie } from "../dto/dtoUserEcurie"; export const setUsersList = (usersList: User[]) => { return { - type: Fetch_Users, + type: FETCH_USERS, payload: usersList, }; } diff --git a/R-Dash/redux/reducers/appReducer.ts b/R-Dash/redux/reducers/appReducer.ts index 30fb29a..362b746 100644 --- a/R-Dash/redux/reducers/appReducer.ts +++ b/R-Dash/redux/reducers/appReducer.ts @@ -6,12 +6,12 @@ const initialState = { const appReducer = (state = initialState, action: { type: any; payload: any; }) => { switch (action.type) { - case 'Fetch_Teams': - return { ...state, teams: [...state.teams, action.payload] }; - case 'Fetch_Users': - return { ...state, users: [...state.users, action.payload] }; - case 'Fetch_Sessions': - return { ...state, sessions: [...state.sessions, action.payload] }; + case 'FETCH_TEAMS': + return { ...state, teams: action.payload }; + case 'FETCH_USERS': + return { ...state, users: action.payload }; + case 'FETCH_SESSIONS': + return { ...state, sessions: action.payload }; default: return state; }