From 2ec8f13848988b28118314c42cd079f565a18a92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Castillo?= Date: Thu, 25 Sep 2025 18:31:51 -0300 Subject: [PATCH 1/2] fix: display message for unlocked ticket types on promo code apply MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Castillo --- src/actions.js | 4 ++- src/components/ticket-type/index.js | 30 +++++++++++++++----- src/components/ticket-type/index.module.scss | 17 +++++++++-- 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/src/actions.js b/src/actions.js index 6d436d0..0a8a7c2 100644 --- a/src/actions.js +++ b/src/actions.js @@ -114,7 +114,9 @@ const getTicketTypes = (summitId) => async (dispatch, getState, { apiBaseUrl, ge const { registrationLiteState: {promoCode : currentPromoCode} } = getState(); let params = { - expand: 'badge_type,badge_type.access_levels,badge_type.badge_features', + fields: "cost,cost_with_applied_discount,currency,currency_symbol,id,max_quantity_per_order,name,quantity_2_sell,quantity_sold,sales_end_date,sales_start_date,sub_type,badge_type,badge_type.access_levels,badge_type,badge_type.access_levels.name", + expand: 'badge_type,badge_type.access_levels', + relations: "none,badge_type.none", access_token: accessToken }; diff --git a/src/components/ticket-type/index.js b/src/components/ticket-type/index.js index c08d373..2f8bb34 100644 --- a/src/components/ticket-type/index.js +++ b/src/components/ticket-type/index.js @@ -24,7 +24,7 @@ import { getTicketMaxQuantity } from '../../helpers'; import { avoidTooltipOverflow, getTicketCost, getTicketTaxes, isPrePaidOrder } from '../../utils/utils'; import PromoCodeInput from '../promocode-input'; -import { VIEW_ITEM } from '../../utils/constants'; +import { TICKET_TYPE_SUBTYPE_PREPAID } from '../../utils/constants'; const TicketTypeComponent = ({ allowedTicketTypes, @@ -44,6 +44,7 @@ const TicketTypeComponent = ({ }) => { const [ticket, setTicket] = useState(null); const [quantity, setQuantity] = useState(1); + const [updatedTicketTypes, setUpdatedTicketTypes] = useState([]); const minQuantity = 1; const maxQuantity = getTicketMaxQuantity(ticket); @@ -75,13 +76,18 @@ const TicketTypeComponent = ({ // try to find the updated ticket from the original ticket types collection from api // and update the current ticket that exist on component state // bc a discount could be applied to the current selected ticket type - if (!ticket) return; - const updatedCurrentTicket = originalTicketTypes.find(t => t?.id === ticket.id); - if (updatedCurrentTicket) { - changeForm({ ticketType: updatedCurrentTicket }) - setTicket(updatedCurrentTicket); + const ticketsWithDiscounts = originalTicketTypes.filter(tt => tt.cost_with_applied_discount); + const prePaidTickets = originalTicketTypes.filter(tt => tt.sub_type === TICKET_TYPE_SUBTYPE_PREPAID); + const affectedTickets = [...ticketsWithDiscounts, ...prePaidTickets]; + if (affectedTickets.length > 0) { + changeForm({ ticketType: null }) + setTicket(null); + setUpdatedTicketTypes(affectedTickets) + } + if (!promoCode) { + changeForm({ promoCode: '' }); + setUpdatedTicketTypes([]) } - if (!promoCode) changeForm({ promoCode: '' }) }, [promoCode, originalTicketTypes]) const isPrePaidReservation = useMemo( @@ -218,6 +224,16 @@ const TicketTypeComponent = ({ showMultipleTicketTexts={showMultipleTicketTexts} removePromoCode={handleRemovePromoCode} onPromoCodeChange={handlePromoCodeChange} /> + {updatedTicketTypes.length > 0 && + (
+ Promo Code {promoCode} has unlocked the following tickets types +
    + {updatedTicketTypes.map((tt) => ( +
  • {tt.name}
  • + ))} +
+
) + } {promoCodeError && Object.values(promoCodeError).map((er, index) => (
{er}
)) } diff --git a/src/components/ticket-type/index.module.scss b/src/components/ticket-type/index.module.scss index 541404b..fe77338 100644 --- a/src/components/ticket-type/index.module.scss +++ b/src/components/ticket-type/index.module.scss @@ -6,7 +6,7 @@ } .summary { - text-align: right; + text-align: right; } .promoCode { @@ -37,7 +37,20 @@ } } -.taxes { +.appliedDiscount { + margin-top: 10px; + &::before { + font-family: FontAwesome; + content: '\f058'; + margin-right: 5px; + } + li { + list-style: disc; + margin: 5px 0px 0px 20px; + } +} + +.taxes { display: inline-flex; abbr { overflow: hidden; From 2787143642925be50455d323f01ab44a93de8bc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Castillo?= Date: Mon, 29 Sep 2025 13:04:16 -0300 Subject: [PATCH 2/2] adjust message for discount, move text to i18n file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Castillo --- src/components/ticket-type/index.js | 51 +++++++++++++------- src/components/ticket-type/index.module.scss | 2 +- src/i18n/en.json | 4 +- 3 files changed, 38 insertions(+), 19 deletions(-) diff --git a/src/components/ticket-type/index.js b/src/components/ticket-type/index.js index 2f8bb34..0a787b2 100644 --- a/src/components/ticket-type/index.js +++ b/src/components/ticket-type/index.js @@ -44,7 +44,9 @@ const TicketTypeComponent = ({ }) => { const [ticket, setTicket] = useState(null); const [quantity, setQuantity] = useState(1); - const [updatedTicketTypes, setUpdatedTicketTypes] = useState([]); + + const [ticketsWithDiscounts, setTicketsWithDiscounts] = useState([]); + const [prePaidTickets, setPrePaidTickets] = useState([]); const minQuantity = 1; const maxQuantity = getTicketMaxQuantity(ticket); @@ -76,17 +78,18 @@ const TicketTypeComponent = ({ // try to find the updated ticket from the original ticket types collection from api // and update the current ticket that exist on component state // bc a discount could be applied to the current selected ticket type - const ticketsWithDiscounts = originalTicketTypes.filter(tt => tt.cost_with_applied_discount); - const prePaidTickets = originalTicketTypes.filter(tt => tt.sub_type === TICKET_TYPE_SUBTYPE_PREPAID); - const affectedTickets = [...ticketsWithDiscounts, ...prePaidTickets]; - if (affectedTickets.length > 0) { + const ticketTypesWithDiscount = originalTicketTypes.filter(tt => tt.cost_with_applied_discount); + const unlockedTickets = originalTicketTypes.filter(tt => tt.sub_type === TICKET_TYPE_SUBTYPE_PREPAID); + if (ticketTypesWithDiscount.length > 0 || unlockedTickets.length > 0) { changeForm({ ticketType: null }) setTicket(null); - setUpdatedTicketTypes(affectedTickets) + setTicketsWithDiscounts(ticketTypesWithDiscount); + setPrePaidTickets(unlockedTickets); } if (!promoCode) { changeForm({ promoCode: '' }); - setUpdatedTicketTypes([]) + setTicketsWithDiscounts([]); + setPrePaidTickets([]); } }, [promoCode, originalTicketTypes]) @@ -224,16 +227,30 @@ const TicketTypeComponent = ({ showMultipleTicketTexts={showMultipleTicketTexts} removePromoCode={handleRemovePromoCode} onPromoCodeChange={handlePromoCodeChange} /> - {updatedTicketTypes.length > 0 && - (
- Promo Code {promoCode} has unlocked the following tickets types -
    - {updatedTicketTypes.map((tt) => ( -
  • {tt.name}
  • - ))} -
-
) - } + {(prePaidTickets.length > 0 || ticketsWithDiscounts.length > 0) && ( +
+ {prePaidTickets.length > 0 && ( + <> +

{T.translate("ticket_type.unlocked_tickets", { promoCode })}

+
    + {prePaidTickets.map((tt) => ( +
  • {tt.name}
  • + ))} +
+ + )} + {ticketsWithDiscounts.length > 0 && ( + <> +

{T.translate("ticket_type.discount_tickets", { promoCode })}

+
    + {ticketsWithDiscounts.map((tt) => ( +
  • {tt.name}
  • + ))} +
+ + )} +
+ )} {promoCodeError && Object.values(promoCodeError).map((er, index) => (
{er}
)) } diff --git a/src/components/ticket-type/index.module.scss b/src/components/ticket-type/index.module.scss index fe77338..ee609b3 100644 --- a/src/components/ticket-type/index.module.scss +++ b/src/components/ticket-type/index.module.scss @@ -39,7 +39,7 @@ .appliedDiscount { margin-top: 10px; - &::before { + p::before { font-family: FontAwesome; content: '\f058'; margin-right: 5px; diff --git a/src/i18n/en.json b/src/i18n/en.json index 83b12e7..37d8382 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -11,7 +11,9 @@ "event_will_start_text": "The event will start on {date} at {time} {time_zone_label}" }, "ticket_type": { - "ticket_quantity_tooltip": "Only one ticket type can be selected per order. To purchase multiple ticket types, please place a separate registration order for each ticket type." + "ticket_quantity_tooltip": "Only one ticket type can be selected per order. To purchase multiple ticket types, please place a separate registration order for each ticket type.", + "unlocked_tickets": "Promo Code {promoCode} has unlocked the following tickets types", + "discount_tickets": "Promo Code {promoCode} has applied discount to the following tickets types" }, "promo_code": { "promo_code_tooltip": "Only one promo code can be used per order; the code will be applied to all tickets in this order. If you'd like to use multiple promo codes, please place a separate registration order for each promo code."