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..0a787b2 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, @@ -45,6 +45,9 @@ const TicketTypeComponent = ({ const [ticket, setTicket] = useState(null); const [quantity, setQuantity] = useState(1); + const [ticketsWithDiscounts, setTicketsWithDiscounts] = useState([]); + const [prePaidTickets, setPrePaidTickets] = useState([]); + const minQuantity = 1; const maxQuantity = getTicketMaxQuantity(ticket); @@ -75,13 +78,19 @@ 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 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); + setTicketsWithDiscounts(ticketTypesWithDiscount); + setPrePaidTickets(unlockedTickets); + } + if (!promoCode) { + changeForm({ promoCode: '' }); + setTicketsWithDiscounts([]); + setPrePaidTickets([]); } - if (!promoCode) changeForm({ promoCode: '' }) }, [promoCode, originalTicketTypes]) const isPrePaidReservation = useMemo( @@ -218,6 +227,30 @@ const TicketTypeComponent = ({ showMultipleTicketTexts={showMultipleTicketTexts} removePromoCode={handleRemovePromoCode} onPromoCodeChange={handlePromoCodeChange} /> + {(prePaidTickets.length > 0 || ticketsWithDiscounts.length > 0) && ( +
{T.translate("ticket_type.unlocked_tickets", { promoCode })}
+{T.translate("ticket_type.discount_tickets", { promoCode })}
+