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.
31 lines
840 B
31 lines
840 B
import {CustomJoke} from "../../model/CustomJoke";
|
|
import {SampleJoke} from "../../model/SampleJoke";
|
|
import {Action, ActionType} from "../actions/SampleAction";
|
|
import {Category} from "../../model/Category";
|
|
|
|
interface State {
|
|
jokes: SampleJoke[];
|
|
favoriteJokes: SampleJoke[];
|
|
joke : SampleJoke;
|
|
}
|
|
|
|
const initialState = {
|
|
jokes: [],
|
|
favoriteJokes: [],
|
|
joke: new SampleJoke(1, "", "", "", ""),
|
|
}
|
|
|
|
const sampleReducer = (state: State = initialState, action: Action) => {
|
|
switch (action.type) {
|
|
case ActionType.FETCH_JOKES:
|
|
// @ts-ignore
|
|
return {...state, jokes: action.payload};
|
|
case ActionType.FETCH_JOKES_BY_ID:
|
|
// @ts-ignore
|
|
return {...state, joke: action.payload}
|
|
default:
|
|
return state;
|
|
}
|
|
}
|
|
|
|
export default sampleReducer; |