Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 46 additions & 20 deletions src/actions/event-type-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ import {
startLoading,
showMessage,
showSuccessMessage,
authErrorHandler
authErrorHandler,
escapeFilterValue
} from "openstack-uicore-foundation/lib/utils/actions";
import history from "../history";
import { getAccessTokenSafely } from "../utils/methods";
import { DEFAULT_PER_PAGE, DEFAULT_CURRENT_PAGE } from "../utils/constants";

export const REQUEST_EVENT_TYPES = "REQUEST_EVENT_TYPES";
export const RECEIVE_EVENT_TYPES = "RECEIVE_EVENT_TYPES";
Expand All @@ -36,28 +38,52 @@ export const EVENT_TYPE_ADDED = "EVENT_TYPE_ADDED";
export const EVENT_TYPE_DELETED = "EVENT_TYPE_DELETED";
export const EVENT_TYPES_SEEDED = "EVENT_TYPES_SEEDED";

export const getEventTypes = () => async (dispatch, getState) => {
const { currentSummitState } = getState();
const accessToken = await getAccessTokenSafely();
const { currentSummit } = currentSummitState;
export const getEventTypes =
(
term = null,
page = DEFAULT_CURRENT_PAGE,
perPage = DEFAULT_PER_PAGE,
order = "id",
orderDir = 1
) =>
async (dispatch, getState) => {
const { currentSummitState } = getState();
const accessToken = await getAccessTokenSafely();
const { currentSummit } = currentSummitState;
const filter = [];

dispatch(startLoading());

const params = {
access_token: accessToken,
page,
per_page: perPage
};

dispatch(startLoading());
if (term) {
const escapedTerm = escapeFilterValue(term);
filter.push(`name=@${escapedTerm}`);
}

const params = {
access_token: accessToken,
per_page: 100,
page: 1
};
if (filter.length > 0) {
params["filter[]"] = filter;
}

return getRequest(
createAction(REQUEST_EVENT_TYPES),
createAction(RECEIVE_EVENT_TYPES),
`${window.API_BASE_URL}/api/v1/summits/${currentSummit.id}/event-types`,
authErrorHandler
)(params)(dispatch).then(() => {
dispatch(stopLoading());
});
};
if (order != null && orderDir != null) {
const orderDirSign = orderDir === 1 ? "" : "-";
params.order = `${orderDirSign}${order}`;
}

return getRequest(
createAction(REQUEST_EVENT_TYPES),
createAction(RECEIVE_EVENT_TYPES),
`${window.API_BASE_URL}/api/v1/summits/${currentSummit.id}/event-types`,
authErrorHandler,
{ order, orderDir, term, perPage }
)(params)(dispatch).then(() => {
dispatch(stopLoading());
});
};

export const getEventType = (eventTypeId) => async (dispatch, getState) => {
const { currentSummitState } = getState();
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,7 @@
"name": "Name",
"class": "Class",
"seed_event_types": "Seed Types",
"remove_warning": "Are you sure you want to delete activity type "
"remove_warning": "Please verify you want to delete activity type "
},
"edit_event_type": {
"event_type": "Activity Type",
Expand Down
Loading
Loading