From 5ade39edd3c68e9b59221d215bd1e70158025785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Castillo?= Date: Wed, 13 Nov 2024 09:42:21 -0300 Subject: [PATCH 01/11] replace ticket type ddl on event form MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Castillo --- src/actions/event-actions.js | 12 ++++++++++-- src/components/forms/event-form.js | 17 ++++++++--------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/actions/event-actions.js b/src/actions/event-actions.js index e182ce233..07e88c9d7 100644 --- a/src/actions/event-actions.js +++ b/src/actions/event-actions.js @@ -481,6 +481,12 @@ export const normalizeEvent = (entity, eventTypeConfig, summit) => { } } + if (entity.allowed_ticket_types?.length > 0) { + normalizedEntity.allowed_ticket_types = entity.allowed_ticket_types.map( + (tt) => (tt.hasOwnProperty("id") ? tt.id : tt) + ); + } + if (summit) normalizePresentationAllowedQuestionFields(normalizedEntity, summit); @@ -953,7 +959,8 @@ export const getEvent = (eventId) => async (dispatch, getState) => { const params = { access_token: accessToken, expand: - "creator,speakers,moderator,sponsors,groups,type,type.allowed_media_upload_types,type.allowed_media_upload_types.type, slides, links, videos, media_uploads, tags, media_uploads.media_upload_type, media_uploads.media_upload_type.type,extra_questions,selection_plan,selection_plan.extra_questions, selection_plan.extra_questions.values,selection_plan.track_chair_rating_types,selection_plan.track_chair_rating_types.score_types,created_by,track_chair_scores_avg.ranking_type,actions" + "creator,speakers,moderator,sponsors,groups,type,type.allowed_media_upload_types,type.allowed_media_upload_types.type, slides, links, videos, media_uploads, tags, media_uploads.media_upload_type, media_uploads.media_upload_type.type,extra_questions,selection_plan,selection_plan.extra_questions, selection_plan.extra_questions.values,selection_plan.track_chair_rating_types,selection_plan.track_chair_rating_types.score_types,created_by,track_chair_scores_avg.ranking_type,actions,allowed_ticket_types", + fields: "allowed_ticket_types.id,allowed_ticket_types.name" }; dispatch(startLoading()); @@ -1053,7 +1060,8 @@ export const saveEvent = (entity, publish) => async (dispatch, getState) => { const params = { access_token: accessToken, expand: - "creator,speakers,moderator,sponsors,groups,type,type.allowed_media_upload_types,type.allowed_media_upload_types.type, slides, links, videos, media_uploads, tags, media_uploads.media_upload_type, media_uploads.media_upload_type.type,extra_questions,selection_plan,selection_plan.track_chair_rating_types,selection_plan.track_chair_rating_types.score_types,selection_plan.extra_questions,selection_plan.extra_questions.values,created_by,track_chair_scores_avg.ranking_type,actions" + "creator,speakers,moderator,sponsors,groups,type,type.allowed_media_upload_types,type.allowed_media_upload_types.type, slides, links, videos, media_uploads, tags, media_uploads.media_upload_type, media_uploads.media_upload_type.type,extra_questions,selection_plan,selection_plan.track_chair_rating_types,selection_plan.track_chair_rating_types.score_types,selection_plan.extra_questions,selection_plan.extra_questions.values,created_by,track_chair_scores_avg.ranking_type,actions,allowed_ticket_types", + fields: "allowed_ticket_types.id,allowed_ticket_types.name" }; if (entity.id) { diff --git a/src/components/forms/event-form.js b/src/components/forms/event-form.js index 3518dfe74..3b2dd5a1f 100644 --- a/src/components/forms/event-form.js +++ b/src/components/forms/event-form.js @@ -32,6 +32,7 @@ import { Table, MemberInput, FreeTextSearch, + TicketTypesInput, SortableTable } from "openstack-uicore-foundation/lib/components"; import { Pagination } from "react-bootstrap"; @@ -986,11 +987,6 @@ class EventForm extends React.Component { { label: "Submission", value: "Submission" } ]; - const ticket_types_ddl = currentSummit.ticket_types.map((t) => ({ - value: t.id, - label: t.name - })); - return (
@@ -1509,7 +1505,7 @@ class EventForm extends React.Component { this.handleRemoveFile("attachment")} + handleRemove={() => this.handleRemoveFile("attachment")} className="dropzone col-md-6" multiple={this.props.multi} accept="image/*" @@ -1523,7 +1519,7 @@ class EventForm extends React.Component { this.handleRemoveFile("image")} + handleRemove={() => this.handleRemoveFile("image")} className="dropzone col-md-6" multiple={false} accept="image/*" @@ -1975,14 +1971,17 @@ class EventForm extends React.Component {
-
From d3fe41c86f910683dc1dd25336c83e2d8675f234 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Castillo?= Date: Wed, 13 Nov 2024 09:55:33 -0300 Subject: [PATCH 02/11] replace ddl on ticket list page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Castillo --- src/actions/ticket-actions.js | 2 +- src/pages/tickets/ticket-list-page.js | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/actions/ticket-actions.js b/src/actions/ticket-actions.js index 7c81487d6..a837b7dff 100644 --- a/src/actions/ticket-actions.js +++ b/src/actions/ticket-actions.js @@ -196,7 +196,7 @@ const parseFilters = (filters, term = null) => { filters.ticketTypesFilter.reduce( (accumulator, tt) => `${accumulator}${accumulator !== "" ? "," : ""}ticket_type_id==${ - tt.value + tt.id }`, "" ) diff --git a/src/pages/tickets/ticket-list-page.js b/src/pages/tickets/ticket-list-page.js index 68692339c..09e94f716 100644 --- a/src/pages/tickets/ticket-list-page.js +++ b/src/pages/tickets/ticket-list-page.js @@ -21,7 +21,8 @@ import { Dropdown, PromocodeInput, TagInput, - CompanyInput + CompanyInput, + TicketTypesInput } from "openstack-uicore-foundation/lib/components"; import { Modal, Pagination } from "react-bootstrap"; import { Breadcrumb } from "react-breadcrumbs"; @@ -614,10 +615,6 @@ class TicketListPage extends React.Component { if (!currentSummit.id) return
; - const ticketTypesOptions = [ - ...currentSummit.ticket_types.map((t) => ({ label: t.name, value: t.id })) - ]; - const alpha = Array.from(Array(LETTERS_IN_ALPHABET)).map( (e, i) => i + UPPERCASE_A_IN_ASCII ); @@ -1023,19 +1020,24 @@ class TicketListPage extends React.Component { )} {enabledFilters.includes("ticketTypesFilter") && (
-
-
+
- {currentSummit?.ticket_types.length > 0 && ( -
- - +
- )} + + +
{badge_features_ddl.length >= 0 && ( <>
diff --git a/src/components/forms/tax-type-form.js b/src/components/forms/tax-type-form.js index 71a6db7bf..f9be9a3d9 100644 --- a/src/components/forms/tax-type-form.js +++ b/src/components/forms/tax-type-form.js @@ -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 T from "i18n-react/dist/i18n-react"; @@ -18,7 +18,9 @@ import { Input, SimpleLinkList } from "openstack-uicore-foundation/lib/components"; +import { queryTicketTypes } from "openstack-uicore-foundation/lib/utils/query-actions"; import { isEmpty, scrollToError, shallowEqual } from "../../utils/methods"; +import { MILLISECONDS_TO_SECONDS } from "../../utils/constants"; class TaxTypeForm extends React.Component { constructor(props) { @@ -36,7 +38,7 @@ class TaxTypeForm extends React.Component { this.handleSubmit = this.handleSubmit.bind(this); } - componentDidUpdate(prevProps, prevState, snapshot) { + componentDidUpdate(prevProps) { const state = {}; scrollToError(this.props.errors); @@ -55,8 +57,8 @@ class TaxTypeForm extends React.Component { } handleChange(ev) { - let entity = { ...this.state.entity }; - let errors = { ...this.state.errors }; + const newEntity = { ...this.state.entity }; + const newErrors = { ...this.state.errors }; let { value, id } = ev.target; if (ev.target.type === "checkbox") { @@ -64,23 +66,23 @@ class TaxTypeForm extends React.Component { } if (ev.target.type === "datetime") { - value = value.valueOf() / 1000; + value = value.valueOf() / MILLISECONDS_TO_SECONDS; } - errors[id] = ""; - entity[id] = value; - this.setState({ entity: entity, errors: errors }); + newErrors[id] = ""; + newEntity[id] = value; + this.setState({ entity: newEntity, errors: newErrors }); } handleSubmit(ev) { - let entity = { ...this.state.entity }; + const entity = { ...this.state.entity }; ev.preventDefault(); - this.props.onSubmit(this.state.entity); + this.props.onSubmit(entity); } hasErrors(field) { - let { errors } = this.state; + const { errors } = this.state; if (field in errors) { return errors[field]; } @@ -113,7 +115,7 @@ class TaxTypeForm extends React.Component { const { entity } = this.state; const { currentSummit } = this.props; - let ticketColumns = [ + const ticketColumns = [ { columnKey: "name", value: T.translate("edit_tax_type.name") }, { columnKey: "description", @@ -121,13 +123,14 @@ class TaxTypeForm extends React.Component { } ]; - let ticketOptions = { + const ticketOptions = { title: T.translate("edit_tax_type.ticket_types"), valueKey: "name", labelKey: "name", defaultOptions: true, actions: { - search: this.queryTickets, + search: (ev, callback) => + queryTicketTypes(currentSummit.id, { name: ev }, callback, "v2"), delete: { onClick: this.handleTicketUnLink }, add: { onClick: this.handleTicketLink } } diff --git a/src/pages/attendees/summit-attendees-list-page.js b/src/pages/attendees/summit-attendees-list-page.js index a9f86ba31..4da2306c2 100644 --- a/src/pages/attendees/summit-attendees-list-page.js +++ b/src/pages/attendees/summit-attendees-list-page.js @@ -128,6 +128,7 @@ class SummitAttendeeListPage extends React.Component { this.handleApplyEventFilters = this.handleApplyEventFilters.bind(this); this.handleTermChange = this.handleTermChange.bind(this); this.handleOrAndFilter = this.handleOrAndFilter.bind(this); + this.handleParseFilters = this.handleParseFilters.bind(this); this.state = { showModal: false, modalTitle: "", @@ -148,7 +149,7 @@ class SummitAttendeeListPage extends React.Component { term, order, orderDir, - attendeeFilters, + this.handleParseFilters(attendeeFilters), selectedColumns ); } @@ -253,7 +254,7 @@ class SummitAttendeeListPage extends React.Component { DEFAULT_PER_PAGE, order, orderDir, - filters, + this.handleParseFilters(filters), extraColumns ); } @@ -294,7 +295,7 @@ class SummitAttendeeListPage extends React.Component { perPage, order, orderDir, - attendeeFilters, + this.handleParseFilters(attendeeFilters), selectedColumns ); } @@ -309,7 +310,7 @@ class SummitAttendeeListPage extends React.Component { perPage, key, dir, - attendeeFilters, + this.handleParseFilters(attendeeFilters), selectedColumns ); } @@ -323,7 +324,7 @@ class SummitAttendeeListPage extends React.Component { perPage, order, orderDir, - attendeeFilters, + this.handleParseFilters(attendeeFilters), selectedColumns ); } @@ -362,7 +363,7 @@ class SummitAttendeeListPage extends React.Component { perPage, order, orderDir, - attendeeFilters, + this.handleParseFilters(attendeeFilters), selectedColumns ); } @@ -460,10 +461,13 @@ class SummitAttendeeListPage extends React.Component { : `${ev.target.operator}${ev.target.value}`; } } - this.setState({ - ...this.state, - attendeeFilters: { ...this.state.attendeeFilters, [id]: value } - }); + this.setState( + { + ...this.state, + attendeeFilters: { ...this.state.attendeeFilters, [id]: value } + }, + () => console.log("CHECK...", this.state.attendeeFilters) + ); } handleOrAndFilter(ev) { @@ -477,6 +481,16 @@ class SummitAttendeeListPage extends React.Component { this.props.changeAttendeeListSearchTerm(term); } + handleParseFilters(filters) { + const parsedFilters = { ...filters }; + if (parsedFilters.ticketTypeFilter.length > 0) { + parsedFilters.ticketTypeFilter = filters.ticketTypeFilter.map( + (tt) => tt.id + ); + } + return parsedFilters; + } + render() { const { currentSummit, diff --git a/src/pages/tickets/registration-invitations-list-page.js b/src/pages/tickets/registration-invitations-list-page.js index daff8ea31..dd495fdda 100644 --- a/src/pages/tickets/registration-invitations-list-page.js +++ b/src/pages/tickets/registration-invitations-list-page.js @@ -560,10 +560,6 @@ class RegistrationInvitationsListPage extends React.Component { if (!currentSummit.id) return
; - // const ticketTypesFilterDDL = currentSummit.ticket_types.map((t) => { - // return { label: t.name, value: t.id }; - // }); - const flowEventsDDL = [ { label: "-- SELECT EMAIL EVENT --", value: "" }, { diff --git a/src/pages/tickets/ticket-list-page.js b/src/pages/tickets/ticket-list-page.js index 09e94f716..868d7af7e 100644 --- a/src/pages/tickets/ticket-list-page.js +++ b/src/pages/tickets/ticket-list-page.js @@ -1029,7 +1029,7 @@ class TicketListPage extends React.Component { onChange={(ev) => this.handleFilterChange( "ticketTypesFilter", - ev.target.value + ev.target.value.map((tt) => ({ ...tt, value: tt.id })) ) } isMulti From 7728ce6c007e852f16a737c449c53a5a1867b676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Castillo?= Date: Thu, 21 Nov 2024 10:08:56 -0300 Subject: [PATCH 08/11] adjust registration invitation action and page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Castillo --- src/actions/registration-invitation-actions.js | 2 +- src/pages/tickets/registration-invitations-list-page.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/actions/registration-invitation-actions.js b/src/actions/registration-invitation-actions.js index f58f1aa64..4d45fc7d5 100644 --- a/src/actions/registration-invitation-actions.js +++ b/src/actions/registration-invitation-actions.js @@ -427,7 +427,7 @@ const parseFilters = (filters, term = null) => { if (filters.allowedTicketTypesIds?.length > 0) { const ticketTypesId = filters.allowedTicketTypesIds.map((tt) => - tt.hasOwnProperty("id") ? tt.id : tt + tt?.id ? tt.id : tt ); filter.push(`ticket_types_id==${ticketTypesId.join("||")}`); } diff --git a/src/pages/tickets/registration-invitations-list-page.js b/src/pages/tickets/registration-invitations-list-page.js index dd495fdda..3d05e485f 100644 --- a/src/pages/tickets/registration-invitations-list-page.js +++ b/src/pages/tickets/registration-invitations-list-page.js @@ -273,7 +273,10 @@ class RegistrationInvitationsListPage extends React.Component { const { term, page, order, orderDir, perPage, status, isSent, tagFilter } = this.props; const { value } = ev.target; - const ticketTypeFilter = [...value]; + const ticketTypeFilter = [...value].map((tt) => ({ + id: tt.id, + name: tt.name + })); const { invitationFilter: { orAndFilter } } = this.state; From 7ae3823856999c2060d185ccc2663ab00f75bd2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Castillo?= Date: Wed, 18 Dec 2024 11:39:37 -0300 Subject: [PATCH 09/11] validation for parseFilter function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Castillo --- src/pages/attendees/summit-attendees-list-page.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/attendees/summit-attendees-list-page.js b/src/pages/attendees/summit-attendees-list-page.js index 4da2306c2..a5378ba93 100644 --- a/src/pages/attendees/summit-attendees-list-page.js +++ b/src/pages/attendees/summit-attendees-list-page.js @@ -483,7 +483,7 @@ class SummitAttendeeListPage extends React.Component { handleParseFilters(filters) { const parsedFilters = { ...filters }; - if (parsedFilters.ticketTypeFilter.length > 0) { + if (parsedFilters.ticketTypeFilter?.length > 0) { parsedFilters.ticketTypeFilter = filters.ticketTypeFilter.map( (tt) => tt.id ); From 1ace4cc3580c3e7d3b9f111b90ec91f79bf006a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Castillo?= Date: Wed, 18 Dec 2024 14:22:11 -0300 Subject: [PATCH 10/11] Add missing expands, and props MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Castillo --- src/actions/event-actions.js | 2 +- src/actions/summit-actions.js | 1 + .../forms/extra-question-form/index.js | 6 +- .../edit-sponsor-extra-question-page.js | 1 + ...edit-selection-plan-extra-question-page.js | 3 +- .../selection-plan-extra-question-reducer.js | 142 ++++++++---------- 6 files changed, 67 insertions(+), 88 deletions(-) diff --git a/src/actions/event-actions.js b/src/actions/event-actions.js index 07e88c9d7..58b78f9c6 100644 --- a/src/actions/event-actions.js +++ b/src/actions/event-actions.js @@ -959,7 +959,7 @@ export const getEvent = (eventId) => async (dispatch, getState) => { const params = { access_token: accessToken, expand: - "creator,speakers,moderator,sponsors,groups,type,type.allowed_media_upload_types,type.allowed_media_upload_types.type, slides, links, videos, media_uploads, tags, media_uploads.media_upload_type, media_uploads.media_upload_type.type,extra_questions,selection_plan,selection_plan.extra_questions, selection_plan.extra_questions.values,selection_plan.track_chair_rating_types,selection_plan.track_chair_rating_types.score_types,created_by,track_chair_scores_avg.ranking_type,actions,allowed_ticket_types", + "creator,speakers,moderator,sponsors,groups,type,type.allowed_media_upload_types,type.allowed_media_upload_types.type, slides, links, videos, media_uploads, tags, media_uploads.media_upload_type, media_uploads.media_upload_type.type,extra_questions,selection_plan,selection_plan.extra_questions, selection_plan.extra_questions.values,selection_plan.track_chair_rating_types,selection_plan.track_chair_rating_types.score_types,created_by,track_chair_scores_avg.ranking_type,actions,allowed_ticket_types,allowed_badge_features_types", fields: "allowed_ticket_types.id,allowed_ticket_types.name" }; diff --git a/src/actions/summit-actions.js b/src/actions/summit-actions.js index f60fb0fa7..129fefde4 100644 --- a/src/actions/summit-actions.js +++ b/src/actions/summit-actions.js @@ -72,6 +72,7 @@ export const getSummitById = (summitId) => async (dispatch) => { "selection_plans," + "ticket_types," + "badge_types," + + "badge_features," + "badge_features_types," + "badge_access_level_types," + "badge_view_types," + diff --git a/src/components/forms/extra-question-form/index.js b/src/components/forms/extra-question-form/index.js index a87ab116b..6491dd923 100644 --- a/src/components/forms/extra-question-form/index.js +++ b/src/components/forms/extra-question-form/index.js @@ -448,11 +448,11 @@ class ExtraQuestionForm extends React.Component {
diff --git a/src/pages/sponsors/edit-sponsor-extra-question-page.js b/src/pages/sponsors/edit-sponsor-extra-question-page.js index 7baea8d34..07f9579ea 100644 --- a/src/pages/sponsors/edit-sponsor-extra-question-page.js +++ b/src/pages/sponsors/edit-sponsor-extra-question-page.js @@ -87,6 +87,7 @@ function EditSponsorExtraQuestionPage({
{currentSummit && ( {currentSummit && ( { const { type, payload } = action; switch (type) { case LOGOUT_USER: - { - // we need this in case the token expired while editing the form - if (payload.hasOwnProperty("persistStore")) { - return state; - } else { - return { ...state, entity: { ...DEFAULT_ENTITY }, errors: {} }; - } + // we need this in case the token expired while editing the form + if (payload.hasOwnProperty("persistStore")) { + return state; } - break; + return { ...state, entity: { ...DEFAULT_ENTITY }, errors: {} }; case SET_CURRENT_SUMMIT: case RESET_SELECTION_PLAN_EXTRA_QUESTION_FORM: - { - return { ...state, entity: { ...DEFAULT_ENTITY }, errors: {} }; - } - break; - case RECEIVE_SELECTION_PLAN_EXTRA_QUESTION_META: - { - let allClasses = payload.response; + return { ...state, entity: { ...DEFAULT_ENTITY }, errors: {} }; + case RECEIVE_SELECTION_PLAN_EXTRA_QUESTION_META: { + const allClasses = payload.response; - return { ...state, allClasses: allClasses }; - } - break; + return { ...state, allClasses }; + } case UPDATE_SELECTION_PLAN_EXTRA_QUESTION: - { - return { ...state, entity: { ...payload }, errors: {} }; - } - break; + return { ...state, entity: { ...payload }, errors: {} }; case SELECTION_PLAN_EXTRA_QUESTION_ADDED: - case RECEIVE_SELECTION_PLAN_EXTRA_QUESTION: - { - let entity = { ...payload.response }; + case RECEIVE_SELECTION_PLAN_EXTRA_QUESTION: { + const entity = { ...payload.response }; - for (var key in entity) { - if (entity.hasOwnProperty(key)) { - entity[key] = entity[key] == null ? "" : entity[key]; - } + for (const key in entity) { + if (entity.hasOwnProperty(key)) { + entity[key] = entity[key] == null ? "" : entity[key]; } - - return { ...state, entity: { ...DEFAULT_ENTITY, ...entity } }; } - break; + + return { ...state, entity: { ...DEFAULT_ENTITY, ...entity } }; + } case SELECTION_PLAN_EXTRA_QUESTION_UPDATED: - { - return state; + return state; + case SELECTION_PLAN_EXTRA_QUESTION_VALUE_ADDED: { + const entity = { ...payload.response }; + let values = [...state.entity.values]; + if (entity.is_default) { + // reset all other values + values = values.map((v) => ({ ...v, is_default: false })); } - break; - case SELECTION_PLAN_EXTRA_QUESTION_VALUE_ADDED: - { - let entity = { ...payload.response }; - let values = [...state.entity.values]; - if (entity.is_default) { - // reset all other values - values = values.map((v) => ({ ...v, is_default: false })); - } - return { - ...state, - entity: { ...state.entity, values: [...values, entity] } - }; + return { + ...state, + entity: { ...state.entity, values: [...values, entity] } + }; + } + case SELECTION_PLAN_EXTRA_QUESTION_VALUE_UPDATED: { + const entity = { ...payload.response }; + let values_tmp = state.entity.values.filter((v) => v.id !== entity.id); + if (entity.is_default) { + // reset all other values + values_tmp = values_tmp.map((v) => ({ ...v, is_default: false })); } - break; - case SELECTION_PLAN_EXTRA_QUESTION_VALUE_UPDATED: - { - let entity = { ...payload.response }; - let values_tmp = state.entity.values.filter((v) => v.id !== entity.id); - if (entity.is_default) { - // reset all other values - values_tmp = values_tmp.map((v) => ({ ...v, is_default: false })); - } - let values = [...values_tmp, entity]; + const values = [...values_tmp, entity]; - values.sort((a, b) => - a.order > b.order ? 1 : a.order < b.order ? -1 : 0 - ); + values.sort((a, b) => + a.order > b.order ? 1 : a.order < b.order ? -1 : 0 + ); - return { ...state, entity: { ...state.entity, values: values } }; - } - break; - case SELECTION_PLAN_EXTRA_QUESTION_VALUE_DELETED: - { - let { valueId } = payload; - return { - ...state, - entity: { - ...state.entity, - values: state.entity.values.filter((v) => v.id !== valueId) - } - }; - } - break; + return { ...state, entity: { ...state.entity, values } }; + } + case SELECTION_PLAN_EXTRA_QUESTION_VALUE_DELETED: { + const { valueId } = payload; + return { + ...state, + entity: { + ...state.entity, + values: state.entity.values.filter((v) => v.id !== valueId) + } + }; + } case VALIDATE: - { - return { ...state, errors: payload.errors }; - } - break; + return { ...state, errors: payload.errors }; default: return state; } From b1256bf6237ca0a49432f8ee556be17f74468468 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Castillo?= Date: Wed, 18 Dec 2024 16:32:12 -0300 Subject: [PATCH 11/11] add missing ticket type ddl for purchase order, clean tax type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Castillo --- src/actions/order-actions.js | 4 +++ src/components/forms/purchase-order-form.js | 40 ++++++++++++--------- src/components/forms/tax-type-form.js | 12 ------- 3 files changed, 27 insertions(+), 29 deletions(-) diff --git a/src/actions/order-actions.js b/src/actions/order-actions.js index 517062244..db993a294 100644 --- a/src/actions/order-actions.js +++ b/src/actions/order-actions.js @@ -500,6 +500,10 @@ const normalizePurchaseOrder = (entity) => { delete normalizedEntity.owner_company_id; } + if (normalizedEntity.ticket_type_id != null) { + normalizedEntity.ticket_type_id = normalizedEntity.ticket_type_id.id; + } + delete normalizedEntity.extra_questions; return normalizedEntity; diff --git a/src/components/forms/purchase-order-form.js b/src/components/forms/purchase-order-form.js index 128f88f2a..e5be630bf 100644 --- a/src/components/forms/purchase-order-form.js +++ b/src/components/forms/purchase-order-form.js @@ -16,10 +16,10 @@ import T from "i18n-react/dist/i18n-react"; import "awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css"; import { Input, - Dropdown, Table, Panel, - PromocodeInput + PromocodeInput, + TicketTypesInput } from "openstack-uicore-foundation/lib/components"; import { Pagination } from "react-bootstrap"; import OwnerInput from "../inputs/owner-input"; @@ -39,7 +39,7 @@ class PurchaseOrderForm extends React.Component { entity: { ...props.entity }, errors: props.errors, showSection: "billing", - addTicketTypeId: 0, + addTicketTypeId: null, addTicketQty: 0, addPromoCode: null }; @@ -97,11 +97,16 @@ class PurchaseOrderForm extends React.Component { handleAddTickets = (ev) => { ev.preventDefault(); - const { addTicketTypeId, addTicketQty, addPromoCode, entity } = this.state; - if (!entity || !addTicketTypeId || !addTicketQty) return; + const { + addTicketTypeId: { id: ticketTypeId }, + addTicketQty, + addPromoCode, + entity + } = this.state; + if (!entity || !ticketTypeId || !addTicketQty) return; this.props - .addTickets(entity.id, addTicketTypeId, addTicketQty, addPromoCode) + .addTickets(entity.id, ticketTypeId, addTicketQty, addPromoCode) .then(() => this.setState({ addTicketTypeId: null, @@ -184,11 +189,6 @@ class PurchaseOrderForm extends React.Component { } }; - const ticket_type_ddl = currentSummit?.ticket_types?.map((tt) => ({ - label: tt.name, - value: tt.id - })); - const tax_columns = [ ...(entity?.approved_refunds_taxes?.map((tax) => ({ columnKey: `tax_${tax.id}_refunded_amount`, @@ -329,11 +329,14 @@ class PurchaseOrderForm extends React.Component {
-
@@ -510,16 +513,19 @@ class PurchaseOrderForm extends React.Component { {" "} {T.translate("edit_purchase_order.ticket_type")} - { this.setState({ ...this.state, - addTicketTypeId: parseInt(ev.target.value) + addTicketTypeId: ev.target.value }); }} + version="v2" + defaultOptions + optionsLimit={100} + isClearable />
diff --git a/src/components/forms/tax-type-form.js b/src/components/forms/tax-type-form.js index f9be9a3d9..a81b7955c 100644 --- a/src/components/forms/tax-type-form.js +++ b/src/components/forms/tax-type-form.js @@ -31,7 +31,6 @@ class TaxTypeForm extends React.Component { errors: props.errors }; - this.queryTickets = this.queryTickets.bind(this); this.handleTicketLink = this.handleTicketLink.bind(this); this.handleTicketUnLink = this.handleTicketUnLink.bind(this); this.handleChange = this.handleChange.bind(this); @@ -100,17 +99,6 @@ class TaxTypeForm extends React.Component { this.props.onTicketUnLink(entity.id, valueId); } - queryTickets(input, callback) { - const { currentSummit } = this.props; - let ticketTypes = []; - - ticketTypes = currentSummit.ticket_types.filter( - (f) => f.name.toLowerCase().indexOf(input.toLowerCase()) !== -1 - ); - - callback(ticketTypes); - } - render() { const { entity } = this.state; const { currentSummit } = this.props;