Skip to content

Commit

Permalink
replace ticket type on registration invitation list page
Browse files Browse the repository at this point in the history
Signed-off-by: Tomás Castillo <[email protected]>
  • Loading branch information
tomrndom committed Nov 13, 2024
1 parent c024602 commit c34ca28
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 50 deletions.
47 changes: 26 additions & 21 deletions src/actions/registration-invitation-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
* */

import T from "i18n-react/dist/i18n-react";
import {
Expand All @@ -29,6 +29,8 @@ import {
import history from "../history";
import { checkOrFilter, getAccessTokenSafely } from "../utils/methods";
import { getSentEmailsByTemplatesAndEmail } from "./email-actions";
import { DEFAULT_PER_PAGE } from "../utils/constants";

export const REQUEST_INVITATIONS = "REQUEST_INVITATIONS";
export const RECEIVE_INVITATIONS = "RECEIVE_INVITATIONS";
export const INVITATIONS_IMPORTED = "INVITATIONS_IMPORTED";
Expand All @@ -51,13 +53,13 @@ export const REGISTRATION_INVITATION_ALL_DELETED =
export const SET_CURRENT_FLOW_EVENT = "SET_CURRENT_FLOW_EVENT";
export const SET_SELECTED_ALL = "SET_SELECTED_ALL";

/************************** INVITATIONS ******************************************/
/* ************************* INVITATIONS ***************************************** */

export const getInvitations =
(
term = null,
page = 1,
perPage = 10,
perPage = DEFAULT_PER_PAGE,
order = "id",
orderDir = 1,
filters = {}
Expand All @@ -71,7 +73,7 @@ export const getInvitations =
dispatch(startLoading());

const params = {
page: page,
page,
per_page: perPage,
access_token: accessToken,
expand: "allowed_ticket_types,tags"
Expand All @@ -86,7 +88,7 @@ export const getInvitations =
// order
if (order != null && orderDir != null) {
const orderDirSign = orderDir === 1 ? "+" : "-";
params["order"] = `${orderDirSign}${order}`;
params.order = `${orderDirSign}${order}`;
}

return getRequest(
Expand Down Expand Up @@ -138,7 +140,7 @@ export const exportInvitationsCSV =
const { currentSummitState } = getState();
const accessToken = await getAccessTokenSafely();
const { currentSummit } = currentSummitState;
const filename = currentSummit.name + "-invitations.csv";
const filename = `${currentSummit.name}-invitations.csv`;
const filter = parseFilters(filters, term);

const params = {
Expand All @@ -152,7 +154,7 @@ export const exportInvitationsCSV =
// order
if (order != null && orderDir != null) {
const orderDirSign = orderDir === 1 ? "+" : "-";
params["order"] = `${orderDirSign}${order}`;
params.order = `${orderDirSign}${order}`;
}

dispatch(
Expand All @@ -164,15 +166,15 @@ export const exportInvitationsCSV =
);
};

export const selectInvitation = (invitationId) => (dispatch, getState) => {
export const selectInvitation = (invitationId) => (dispatch) => {
dispatch(createAction(SELECT_INVITATION)(invitationId));
};

export const unSelectInvitation = (invitationId) => (dispatch, getState) => {
export const unSelectInvitation = (invitationId) => (dispatch) => {
dispatch(createAction(UNSELECT_INVITATION)(invitationId));
};

export const clearAllSelectedInvitations = () => (dispatch, getState) => {
export const clearAllSelectedInvitations = () => (dispatch) => {
dispatch(createAction(CLEAR_ALL_SELECTED_INVITATIONS)());
};

Expand Down Expand Up @@ -242,15 +244,15 @@ export const deleteAllRegistrationInvitation =
});
};

export const resetRegistrationInvitationForm = () => (dispatch, getState) => {
export const resetRegistrationInvitationForm = () => (dispatch) => {
dispatch(createAction(RESET_REGISTRATION_INVITATION_FORM)({}));
};

export const setCurrentFlowEvent = (value) => (dispatch, getState) => {
export const setCurrentFlowEvent = (value) => (dispatch) => {
dispatch(createAction(SET_CURRENT_FLOW_EVENT)(value));
};

export const setSelectedAll = (value) => (dispatch, getState) => {
export const setSelectedAll = (value) => (dispatch) => {
dispatch(createAction(SET_SELECTED_ALL)(value));
};

Expand Down Expand Up @@ -338,10 +340,10 @@ const normalizeEntity = (entity) => {
(tt) => tt.id
);
normalizedEntity.tags = entity.tags.map((t) => t.tag);
delete normalizedEntity["created"];
delete normalizedEntity["last_edited"];
delete normalizedEntity["is_sent"];
delete normalizedEntity["accepted_date"];
delete normalizedEntity.created;
delete normalizedEntity.last_edited;
delete normalizedEntity.is_sent;
delete normalizedEntity.accepted_date;
return normalizedEntity;
};

Expand Down Expand Up @@ -384,11 +386,11 @@ export const sendEmails =
};

if (testRecipient) {
payload["test_email_recipient"] = testRecipient;
payload.test_email_recipient = testRecipient;
}

if (excerptRecipient) {
payload["outcome_email_recipient"] = excerptRecipient;
payload.outcome_email_recipient = excerptRecipient;
}

dispatch(startLoading());
Expand Down Expand Up @@ -424,11 +426,14 @@ const parseFilters = (filters, term = null) => {
}

if (filters.allowedTicketTypesIds?.length > 0) {
filter.push("ticket_types_id==" + filters.allowedTicketTypesIds.join("||"));
const ticketTypesId = filters.allowedTicketTypesIds.map((tt) =>
tt.hasOwnProperty("id") ? tt.id : tt
);
filter.push(`ticket_types_id==${ticketTypesId.join("||")}`);
}

if (filters.tagFilter?.length > 0) {
filter.push("tags_id==" + filters.tagFilter.map((e) => e.id).join("||"));
filter.push(`tags_id==${filters.tagFilter.map((e) => e.id).join("||")}`);
}

if (term) {
Expand Down
60 changes: 31 additions & 29 deletions src/pages/tickets/registration-invitations-list-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
* */

import React from "react";
import { connect } from "react-redux";
Expand All @@ -22,8 +22,10 @@ import {
UploadInput,
Dropdown,
TagInput,
Input
Input,
TicketTypesInput
} from "openstack-uicore-foundation/lib/components";
import { SegmentedControl } from "segmented-control";
import { getSummitById } from "../../actions/summit-actions";
import {
exportInvitationsCSV,
Expand All @@ -46,11 +48,10 @@ import {
} from "../../utils/constants";

import "../../styles/registration-invitation-list-page.less";
import { SegmentedControl } from "segmented-control";
import OrAndFilter from "../../components/filters/or-and-filter";
import { validateEmail } from "../../utils/methods";
import InvitationStatusDropdown from "../../components/inputs/invitation-status-dropdown";
import SendEmailModal from "../../components/send-email-modal/index.jsx";
import SendEmailModal from "../../components/send-email-modal/index";

class RegistrationInvitationsListPage extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -145,7 +146,7 @@ class RegistrationInvitationsListPage extends React.Component {
}

handleChangeFlowEvent(ev) {
const { value, id } = ev.target;
const { value } = ev.target;
this.props.setCurrentFlowEvent(value);
}

Expand All @@ -159,7 +160,7 @@ class RegistrationInvitationsListPage extends React.Component {
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: T.translate("general.yes_delete")
}).then(function (result) {
}).then((result) => {
if (result.value) {
deleteAllRegistrationInvitation();
}
Expand All @@ -168,20 +169,18 @@ class RegistrationInvitationsListPage extends React.Component {

handleDelete(invitation_id) {
const { deleteRegistrationInvitation, invitations } = this.props;
let invitation = invitations.find((i) => i.id === invitation_id);
const invitation = invitations.find((i) => i.id === invitation_id);

Swal.fire({
title: T.translate("general.are_you_sure"),
text:
T.translate("registration_invitation_list.remove_warning") +
" (" +
invitation.email +
") .",
text: `${T.translate("registration_invitation_list.remove_warning")} (${
invitation.email
}) .`,
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: T.translate("general.yes_delete")
}).then(function (result) {
}).then((result) => {
if (result.value) {
deleteRegistrationInvitation(invitation_id);
}
Expand Down Expand Up @@ -262,18 +261,18 @@ class RegistrationInvitationsListPage extends React.Component {
}

handleSelectedAll(ev) {
let selectedAllCb = ev.target.checked;
const selectedAllCb = ev.target.checked;
this.props.setSelectedAll(selectedAllCb);
if (!selectedAllCb) {
//clear all selected
// clear all selected
this.props.clearAllSelectedInvitations();
}
}

handleTicketTypeSelected(ev) {
const { term, page, order, orderDir, perPage, status, isSent, tagFilter } =
this.props;
let { value } = ev.target;
const { value } = ev.target;
const ticketTypeFilter = [...value];
const {
invitationFilter: { orAndFilter }
Expand All @@ -287,7 +286,7 @@ class RegistrationInvitationsListPage extends React.Component {
});
}

handleSort(index, key, dir, func) {
handleSort(index, key, dir) {
const {
term,
page,
Expand Down Expand Up @@ -548,7 +547,7 @@ class RegistrationInvitationsListPage extends React.Component {
const table_options = {
sortCol: order,
sortDir: orderDir,
selectedAll: selectedAll,
selectedAll,
actions: {
edit: {
onClick: this.handleEdit,
Expand All @@ -561,11 +560,11 @@ class RegistrationInvitationsListPage extends React.Component {

if (!currentSummit.id) return <div />;

const ticketTypesFilterDDL = currentSummit.ticket_types.map((t) => {
return { label: t.name, value: t.id };
});
// const ticketTypesFilterDDL = currentSummit.ticket_types.map((t) => {
// return { label: t.name, value: t.id };
// });

let flowEventsDDL = [
const flowEventsDDL = [
{ label: "-- SELECT EMAIL EVENT --", value: "" },
{
label: "SUMMIT_REGISTRATION_INVITE_REGISTRATION",
Expand Down Expand Up @@ -628,7 +627,7 @@ class RegistrationInvitationsListPage extends React.Component {
<OrAndFilter
style={{ marginTop: 15 }}
value={invitationFilter.orAndFilter}
entity={"invitations"}
entity="invitations"
onChange={(filter) => this.handleOrAndFilter(filter)}
/>
<div className="row">
Expand All @@ -645,21 +644,24 @@ class RegistrationInvitationsListPage extends React.Component {
/>
</div>
<div className="col-md-6">
<Dropdown
<TicketTypesInput
id="allowed_ticket_types_filter"
value={allowedTicketTypesIds}
placeholder={T.translate(
"registration_invitation_list.placeholders.allowed_ticket_types_filter"
)}
onChange={this.handleTicketTypeSelected}
options={ticketTypesFilterDDL}
isMulti={true}
summitId={currentSummit.id}
version="v2"
optionsLimit={100}
defaultOptions
isMulti
/>
</div>
</div>
<div className="row">
<div className="col-md-6">
<div className={"row"}>
<div className="row">
<div className="col-md-6">
<SegmentedControl
name="isSent"
Expand Down Expand Up @@ -705,7 +707,7 @@ class RegistrationInvitationsListPage extends React.Component {
options={flowEventsDDL}
/>
</div>
<div className={"col-md-4"}>
<div className="col-md-4">
<Input
id="testRecipient"
value={testRecipient}
Expand All @@ -721,7 +723,7 @@ class RegistrationInvitationsListPage extends React.Component {
className="form-control"
/>
</div>
<div className={"col-md-2"}>
<div className="col-md-2">
<button
className="btn btn-default right-space"
onClick={this.handleSendClick}
Expand Down

0 comments on commit c34ca28

Please sign in to comment.