2022-02-02 18:51:18 +00:00
|
|
|
import { TApplicationActions } from '../definitions';
|
2020-03-30 19:50:27 +00:00
|
|
|
import { CREATE_DISCUSSION } from '../actions/actionsTypes';
|
|
|
|
|
2022-02-02 18:51:18 +00:00
|
|
|
export interface ICreateDiscussion {
|
|
|
|
isFetching: boolean;
|
|
|
|
failure: boolean;
|
|
|
|
result: Record<string, any>;
|
|
|
|
error: Record<string, any>;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const initialState: ICreateDiscussion = {
|
2020-03-30 19:50:27 +00:00
|
|
|
isFetching: false,
|
|
|
|
failure: false,
|
|
|
|
result: {},
|
|
|
|
error: {}
|
|
|
|
};
|
|
|
|
|
2022-02-02 18:51:18 +00:00
|
|
|
export default function (state = initialState, action: TApplicationActions): ICreateDiscussion {
|
2020-03-30 19:50:27 +00:00
|
|
|
switch (action.type) {
|
|
|
|
case CREATE_DISCUSSION.REQUEST:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
isFetching: true,
|
|
|
|
failure: false,
|
|
|
|
error: {}
|
|
|
|
};
|
|
|
|
case CREATE_DISCUSSION.SUCCESS:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
isFetching: false,
|
|
|
|
failure: false,
|
|
|
|
result: action.data
|
|
|
|
};
|
|
|
|
case CREATE_DISCUSSION.FAILURE:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
isFetching: false,
|
|
|
|
failure: true,
|
|
|
|
error: action.err
|
|
|
|
};
|
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|