import { SELECT_GAME, SELECT_DATE, SELECT_SLOT, BOOK_SLOT, SAVE_DETAILS } from '../Action/action'; import BasketBall from './basket_ball.jpeg'; import VolleyBall from './volleyBall.jpeg'; import FootBall from './footBall.jpeg'; const bookSlot1 = [ { id: 1, startTime: "09.00 A.M", endTime: "10.00 A.M", slotStatus: "btn btn-success" }, { id: 2, startTime: "10.00 A.M", endTime: "11.00 A.M", slotStatus: "btn btn-success" }, { id: 3, startTime: "11.00 A.M", endTime: "12.00 P.M", slotStatus: "btn btn-success" }, { id: 4, startTime: "12.00 P.M", endTime: "01.00 P.M", slotStatus: "btn btn-success" }, { id: 5, startTime: "01.00 P.M", endTime: "02.00 P.M", slotStatus: "btn btn-success" }, { id: 6, startTime: "02.00 P.M", endTime: "03.00 P.M", slotStatus: "btn btn-success" }, { id: 7, startTime: "03.00 P.M", endTime: "04.00 P.M", slotStatus: "btn btn-success" }, { id: 8, startTime: "04.00 P.M", endTime: "05.00 P.M", slotStatus: "btn btn-success" }, { id: 9, startTime: "05.00 P.M", endTime: "06.00 P.M", slotStatus: "btn btn-success" } ]; const initialState = { Games: [ { id: 0, src: BasketBall, name: "BasketBall", slots: bookSlot1 }, { id: 1, src: VolleyBall, name: "VolleyBall", slots: bookSlot1 }, { id: 2, src: FootBall, name: "FootBall", slots: bookSlot1 } ], selectedGame: [], selectedDate: new Date(new Date().setDate(new Date().getDate() + 1)), slotBooked: undefined, details: [], bookingCheck: [], }; const reducer = (state = initialState, action) => { switch (action.type) { case SELECT_GAME: return { ...state, selectedGame: [action.payload] }; case SELECT_DATE: return { ...state, selectedDate: action.payload }; case SELECT_SLOT: return { ...state, slotBooked: action.payload }; case BOOK_SLOT: return { ...state, bookingCheck: [...state.bookingCheck, action.payload] }; case SAVE_DETAILS: return { ...state, details: [...state.details, action.payload] }; default: return state; } }; export default reducer;