Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down
47 changes: 40 additions & 7 deletions src/components/ticket-type/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -218,6 +227,30 @@ const TicketTypeComponent = ({
showMultipleTicketTexts={showMultipleTicketTexts}
removePromoCode={handleRemovePromoCode}
onPromoCodeChange={handlePromoCodeChange} />
{(prePaidTickets.length > 0 || ticketsWithDiscounts.length > 0) && (
<div className={`${styles.appliedDiscount} alert alert-success`}>
{prePaidTickets.length > 0 && (
<>
<p>{T.translate("ticket_type.unlocked_tickets", { promoCode })}</p>
<ul>
{prePaidTickets.map((tt) => (
<li key={`pre-${tt.name}`}>{tt.name}</li>
))}
</ul>
</>
)}
{ticketsWithDiscounts.length > 0 && (
<>
<p>{T.translate("ticket_type.discount_tickets", { promoCode })}</p>
<ul>
{ticketsWithDiscounts.map((tt) => (
<li key={`disc-${tt.name}`}>{tt.name}</li>
))}
</ul>
</>
)}
</div>
)}
{promoCodeError &&
Object.values(promoCodeError).map((er, index) => (<div key={`error-${index}`} className={`${styles.promocodeError} alert alert-danger`}>{er}</div>))
}
Expand Down
17 changes: 15 additions & 2 deletions src/components/ticket-type/index.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
}

.summary {
text-align: right;
text-align: right;
}

.promoCode {
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down