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.
42 lines
1.1 KiB
42 lines
1.1 KiB
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,
|
|
};
|
|
} |