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) && ( +
+ {prePaidTickets.length > 0 && ( + <> +

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

+ + + )} + {ticketsWithDiscounts.length > 0 && ( + <> +

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

+ + + )} +
+ )} {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..ee609b3 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; + p::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; 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."