You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
613 B
28 lines
613 B
// redux/reducers/moveReducer.ts
|
|
import { FETCH_MOVES } from '../constants';
|
|
import { Move } from "../../entities/Move";
|
|
import { AnyAction } from "redux";
|
|
|
|
export type MoveState = {
|
|
moves: Move[];
|
|
};
|
|
|
|
type MoveAction = AnyAction & {
|
|
type: typeof FETCH_MOVES;
|
|
payload?: Move[];
|
|
};
|
|
|
|
const initialState: MoveState = {
|
|
moves: [],
|
|
}
|
|
|
|
export default function moveReducer(state = initialState, action: MoveAction): MoveState {
|
|
switch (action.type) {
|
|
case FETCH_MOVES:
|
|
return { ...state, moves: action.payload || [] };
|
|
default:
|
|
return state;
|
|
}
|
|
}
|
|
|