import {CustomJoke} from "../../model/CustomJoke"; import {SampleJoke} from "../../model/SampleJoke"; export enum ActionType { FETCH_CUSTOM_JOKES = 'FETCH_CUSTOM_JOKES', POST_CUSTOM_JOKE = "POST_CUSTOM_JOKE", FETCH_JOKES_BY_ID = "FETCH_JOKES_BY_ID" } type actionPostFetch = { type: ActionType.POST_CUSTOM_JOKE; payload: CustomJoke; } type actionGetFetch = { type: ActionType.FETCH_CUSTOM_JOKES; payload: CustomJoke[]; } type actionGetByFetch = { type: ActionType.FETCH_JOKES_BY_ID; payload: CustomJoke; } export type Action = actionPostFetch | actionGetFetch | actionGetByFetch; export const setPostJoke = (customJoke: CustomJoke) => { return { type: ActionType.POST_CUSTOM_JOKE, payload: customJoke } } export const setCustomJokesList = (customJokesList: CustomJoke[]) => { return { type: ActionType.FETCH_CUSTOM_JOKES, payload: customJokesList }; } export const setCustomJokeById = (customJoke: CustomJoke) => { return { type: ActionType.FETCH_JOKES_BY_ID, payload: customJoke, }; }