tf-checkout-react 1.7.30 → 2.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +141 -1033
- package/dist/checkout.css +17 -0
- package/dist/index.d.mts +3930 -0
- package/dist/index.d.ts +3930 -30
- package/dist/index.esm.js +9123 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +9277 -6
- package/dist/index.js.map +1 -0
- package/dist/styles/addons.css +75 -0
- package/dist/styles/auth.css +294 -0
- package/dist/styles/billing.css +98 -0
- package/dist/styles/confirmation.css +51 -0
- package/dist/styles/foundation.css +146 -0
- package/dist/styles/payment.css +179 -0
- package/dist/styles/primitives.css +356 -0
- package/dist/styles/seat-map.css +46 -0
- package/dist/styles/tickets.css +285 -0
- package/dist/styles/verification-confirmation.css +258 -0
- package/package.json +93 -78
- package/src/.d.ts +1 -1
- package/src/CardInput.tsx +374 -0
- package/src/EmbeddedCheckout.tsx +400 -0
- package/src/ResumedCheckout.tsx +132 -0
- package/src/auth/AuthModal.tsx +231 -0
- package/src/auth/ForgotPasswordForm.tsx +93 -0
- package/src/auth/LoginForm.tsx +104 -0
- package/src/auth/PasswordInput.tsx +33 -0
- package/src/auth/RegisterForm.tsx +333 -0
- package/src/auth/ResetPasswordForm.tsx +112 -0
- package/src/auth/index.ts +5 -0
- package/src/checkout.css +17 -0
- package/src/configure.ts +29 -0
- package/src/confirmer.ts +439 -0
- package/src/index.ts +41 -30
- package/src/instance.ts +21 -0
- package/src/sections/AddOns.tsx +241 -0
- package/src/sections/BillingInfo.tsx +743 -0
- package/src/sections/Confirmation.tsx +146 -0
- package/src/sections/IDVerification.tsx +76 -0
- package/src/sections/OrderConfirmation.tsx +277 -0
- package/src/sections/OrderIDVerification.tsx +117 -0
- package/src/sections/OrderSummary.tsx +84 -0
- package/src/sections/Payment.tsx +541 -0
- package/src/sections/SeatMap.tsx +512 -0
- package/src/sections/Tickets.tsx +573 -0
- package/src/sections/billing/BillingAddressFields.tsx +138 -0
- package/src/sections/billing/BuyerField.tsx +75 -0
- package/src/sections/billing/TicketHoldersCard.tsx +119 -0
- package/src/sections/billing/types.ts +10 -0
- package/src/sections/index.ts +15 -0
- package/src/sections/seatMap.utils.ts +105 -0
- package/src/styles/addons.css +75 -0
- package/src/styles/auth.css +294 -0
- package/src/styles/billing.css +98 -0
- package/src/styles/confirmation.css +51 -0
- package/src/styles/foundation.css +146 -0
- package/src/styles/payment.css +179 -0
- package/src/styles/primitives.css +356 -0
- package/src/styles/seat-map.css +46 -0
- package/src/styles/tickets.css +285 -0
- package/src/styles/verification-confirmation.css +258 -0
- package/src/typings.d.ts +2 -2
- package/src/ui/Button.tsx +38 -0
- package/src/ui/Card.tsx +54 -0
- package/src/ui/CheckoutProvider.tsx +172 -0
- package/src/ui/CustomFields.tsx +195 -0
- package/src/ui/Field.tsx +114 -0
- package/src/ui/I18nProvider.tsx +36 -0
- package/src/ui/InstallmentPicker.tsx +69 -0
- package/src/ui/Loader.tsx +12 -0
- package/src/ui/PaymentMethods.tsx +133 -0
- package/src/ui/PriceLine.tsx +24 -0
- package/src/ui/QuantitySelect.tsx +50 -0
- package/src/ui/Stepper.tsx +36 -0
- package/src/ui/Timer.tsx +34 -0
- package/src/ui/TimerBanner.tsx +55 -0
- package/src/ui/cx.ts +3 -0
- package/src/ui/index.ts +54 -0
- package/src/ui/theme.ts +83 -0
- package/src/useCheckout.ts +35 -0
- package/src/xendit.ts +438 -0
- package/dist/adapters/customFields.d.ts +0 -12
- package/dist/adapters/index.d.ts +0 -1
- package/dist/api/auth.d.ts +0 -27
- package/dist/api/cart.d.ts +0 -2
- package/dist/api/checkout.d.ts +0 -3
- package/dist/api/common.d.ts +0 -11
- package/dist/api/guestTicketDelegation.d.ts +0 -47
- package/dist/api/index.d.ts +0 -82
- package/dist/api/interceptors.d.ts +0 -1
- package/dist/api/orders.d.ts +0 -2
- package/dist/api/payment.d.ts +0 -5
- package/dist/api/preRegistrationComplete.d.ts +0 -3
- package/dist/api/publicRequest.d.ts +0 -9
- package/dist/api/resale.d.ts +0 -5
- package/dist/components/account-settings/index.d.ts +0 -3
- package/dist/components/addonsContainer/AddonComponent.d.ts +0 -18
- package/dist/components/addonsContainer/SimpleAddonsContainer.d.ts +0 -20
- package/dist/components/addonsContainer/adapters/index.d.ts +0 -12
- package/dist/components/addonsContainer/index.d.ts +0 -22
- package/dist/components/addonsContainer/normalizers/index.d.ts +0 -1
- package/dist/components/addonsContainer/useAddons.d.ts +0 -23
- package/dist/components/addonsContainer/utils/index.d.ts +0 -16
- package/dist/components/billing-info-container/hooks/index.d.ts +0 -3
- package/dist/components/billing-info-container/hooks/usePaymentContext.d.ts +0 -5
- package/dist/components/billing-info-container/hooks/usePaymentRedirect.d.ts +0 -14
- package/dist/components/billing-info-container/hooks/useStripePayment.d.ts +0 -18
- package/dist/components/billing-info-container/index.d.ts +0 -69
- package/dist/components/billing-info-container/utils.d.ts +0 -59
- package/dist/components/common/Checkbox.d.ts +0 -11
- package/dist/components/common/CheckboxField/index.d.ts +0 -9
- package/dist/components/common/CopyField.d.ts +0 -12
- package/dist/components/common/CopyMessageModal.d.ts +0 -7
- package/dist/components/common/CustomField.d.ts +0 -26
- package/dist/components/common/DatePickerField.d.ts +0 -20
- package/dist/components/common/FieldSection/index.d.ts +0 -19
- package/dist/components/common/FieldSection/utils/index.d.ts +0 -8
- package/dist/components/common/FormikPhoneNumberField.d.ts +0 -11
- package/dist/components/common/Loader.d.ts +0 -2
- package/dist/components/common/ModalComponent/index.d.ts +0 -16
- package/dist/components/common/NativeSelectFeild/index.d.ts +0 -21
- package/dist/components/common/PhoneNumberField.d.ts +0 -14
- package/dist/components/common/PoweredBy.d.ts +0 -2
- package/dist/components/common/RadioField.d.ts +0 -11
- package/dist/components/common/RadioGroupField/index.d.ts +0 -17
- package/dist/components/common/RedirectModal.d.ts +0 -7
- package/dist/components/common/SelectField/index.d.ts +0 -19
- package/dist/components/common/SnackbarAlert.d.ts +0 -13
- package/dist/components/common/index.d.ts +0 -11
- package/dist/components/common/socials.d.ts +0 -10
- package/dist/components/confirmModal/index.d.ts +0 -10
- package/dist/components/confirmationContainer/config.d.ts +0 -1
- package/dist/components/confirmationContainer/index.d.ts +0 -46
- package/dist/components/confirmationContainer/social-buttons.d.ts +0 -16
- package/dist/components/countdown/index.d.ts +0 -14
- package/dist/components/delegationsContainer/IssueComponent.d.ts +0 -10
- package/dist/components/delegationsContainer/IssueTicketForm.d.ts +0 -9
- package/dist/components/delegationsContainer/TicketsAssignedTable.d.ts +0 -11
- package/dist/components/delegationsContainer/TicketsAvailableTable.d.ts +0 -11
- package/dist/components/delegationsContainer/index.d.ts +0 -10
- package/dist/components/forgotPasswordModal/index.d.ts +0 -12
- package/dist/components/idVerificationContainer/VerificationPendingModal.d.ts +0 -10
- package/dist/components/idVerificationContainer/constants.d.ts +0 -21
- package/dist/components/idVerificationContainer/index.d.ts +0 -16
- package/dist/components/index.d.ts +0 -12
- package/dist/components/loginForm/index.d.ts +0 -31
- package/dist/components/loginModal/SignUpForm.d.ts +0 -10
- package/dist/components/loginModal/constants.d.ts +0 -39
- package/dist/components/loginModal/index.d.ts +0 -22
- package/dist/components/myTicketsContainer/index.d.ts +0 -16
- package/dist/components/myTicketsContainer/row.d.ts +0 -3
- package/dist/components/myTicketsContainer/tableConfig.d.ts +0 -5
- package/dist/components/orderDetailsContainer/CustomFieldsForm.d.ts +0 -12
- package/dist/components/orderDetailsContainer/TicketHolderCustomFields.d.ts +0 -10
- package/dist/components/orderDetailsContainer/index.d.ts +0 -66
- package/dist/components/orderDetailsContainer/ticketsTable.d.ts +0 -46
- package/dist/components/orderDetailsContainer/utils/index.d.ts +0 -6
- package/dist/components/paymentContainer/OrderDetails.d.ts +0 -9
- package/dist/components/paymentContainer/PaymentPlanSection.d.ts +0 -10
- package/dist/components/paymentContainer/handlePayment.d.ts +0 -15
- package/dist/components/paymentContainer/index.d.ts +0 -39
- package/dist/components/preRegistration/FieldsSection.d.ts +0 -19
- package/dist/components/preRegistration/Influancers.d.ts +0 -2
- package/dist/components/preRegistration/PreRegistrationComplete.d.ts +0 -13
- package/dist/components/preRegistration/PreRegistrationInformations.d.ts +0 -2
- package/dist/components/preRegistration/Prewards.d.ts +0 -2
- package/dist/components/preRegistration/ShareOptions.d.ts +0 -2
- package/dist/components/preRegistration/constants.d.ts +0 -2
- package/dist/components/preRegistration/index.d.ts +0 -23
- package/dist/components/preRegistration/utils.d.ts +0 -12
- package/dist/components/registerForm/adapters/index.d.ts +0 -4
- package/dist/components/registerForm/constants.d.ts +0 -1
- package/dist/components/registerForm/index.d.ts +0 -16
- package/dist/components/registerModal/index.d.ts +0 -12
- package/dist/components/resetPasswordContainer/index.d.ts +0 -10
- package/dist/components/rsvpContainer/index.d.ts +0 -7
- package/dist/components/seatMapContainer/SeatMapComponent.d.ts +0 -8
- package/dist/components/seatMapContainer/TicketsSection.d.ts +0 -9
- package/dist/components/seatMapContainer/addToCart.d.ts +0 -14
- package/dist/components/seatMapContainer/index.d.ts +0 -2
- package/dist/components/seatMapContainer/utils.d.ts +0 -6
- package/dist/components/signupModal/index.d.ts +0 -12
- package/dist/components/ticketResale/index.d.ts +0 -12
- package/dist/components/ticketResaleModal/index.d.ts +0 -19
- package/dist/components/ticketsContainer/AccessCodeSection.d.ts +0 -7
- package/dist/components/ticketsContainer/InfoIcon.d.ts +0 -5
- package/dist/components/ticketsContainer/PromoCodeSection.d.ts +0 -15
- package/dist/components/ticketsContainer/ReferralLogic.d.ts +0 -5
- package/dist/components/ticketsContainer/TicketRow.d.ts +0 -13
- package/dist/components/ticketsContainer/TicketsSection.d.ts +0 -20
- package/dist/components/ticketsContainer/TimeSlotTicketRow.d.ts +0 -19
- package/dist/components/ticketsContainer/TimeSlotsSection.d.ts +0 -25
- package/dist/components/ticketsContainer/index.d.ts +0 -93
- package/dist/components/ticketsContainer/utils.d.ts +0 -13
- package/dist/components/timerWidget/index.d.ts +0 -16
- package/dist/components/waitingList/index.d.ts +0 -9
- package/dist/constants/index.d.ts +0 -7
- package/dist/env.d.ts +0 -16
- package/dist/hoc/CustomFields/index.d.ts +0 -3
- package/dist/hoc/index.d.ts +0 -1
- package/dist/hooks/index.d.ts +0 -1
- package/dist/hooks/useCookieListener.d.ts +0 -1
- package/dist/hooks/useEventListener.d.ts +0 -1
- package/dist/hooks/useLocalStorageListener.d.ts +0 -1
- package/dist/hooks/useOnline.d.ts +0 -1
- package/dist/hooks/usePixel.d.ts +0 -6
- package/dist/images/Polygon.png +0 -0
- package/dist/images/cross.svg +0 -44
- package/dist/images/done.svg +0 -3
- package/dist/images/edit.svg +0 -10
- package/dist/images/email.svg +0 -1
- package/dist/images/instagram.svg +0 -5
- package/dist/images/logo-ttf.png +0 -0
- package/dist/images/spotify.svg +0 -6
- package/dist/images/user.svg +0 -1
- package/dist/images/xmark.svg +0 -92
- package/dist/normalizers/index.d.ts +0 -4
- package/dist/tf-checkout-react.cjs.development.js +0 -16149
- package/dist/tf-checkout-react.cjs.development.js.map +0 -1
- package/dist/tf-checkout-react.cjs.production.min.js +0 -2
- package/dist/tf-checkout-react.cjs.production.min.js.map +0 -1
- package/dist/tf-checkout-react.esm.js +0 -16116
- package/dist/tf-checkout-react.esm.js.map +0 -1
- package/dist/tf-checkout-styles.css +0 -1
- package/dist/types/add_on.d.ts +0 -8
- package/dist/types/billing-info-data.d.ts +0 -27
- package/dist/types/checkoutPageConfigs.d.ts +0 -13
- package/dist/types/index.d.ts +0 -6
- package/dist/types/order-data.d.ts +0 -15
- package/dist/types/payment-field.d.ts +0 -6
- package/dist/types/payment-plan-configuration.d.ts +0 -18
- package/dist/types/referral-promotion.d.ts +0 -6
- package/dist/types/verification.d.ts +0 -12
- package/dist/utils/adaptStripeErrors.d.ts +0 -8
- package/dist/utils/auth.d.ts +0 -21
- package/dist/utils/cookies.d.ts +0 -3
- package/dist/utils/createCheckoutDataBodyWithDefaultHolder.d.ts +0 -23
- package/dist/utils/createMarkup.d.ts +0 -3
- package/dist/utils/customFields.d.ts +0 -35
- package/dist/utils/downloadPDF.d.ts +0 -1
- package/dist/utils/form.d.ts +0 -3
- package/dist/utils/formikErrorFocus.d.ts +0 -2
- package/dist/utils/getDomain.d.ts +0 -1
- package/dist/utils/getImage.d.ts +0 -1
- package/dist/utils/getQueryVariable.d.ts +0 -1
- package/dist/utils/htmlNodeFromString.d.ts +0 -1
- package/dist/utils/index.d.ts +0 -15
- package/dist/utils/isBrowser.d.ts +0 -1
- package/dist/utils/isValidNumber.d.ts +0 -1
- package/dist/utils/jsonUtils.d.ts +0 -1
- package/dist/utils/replaceVarInString.d.ts +0 -1
- package/dist/utils/setConfigs.d.ts +0 -11
- package/dist/utils/showZero.d.ts +0 -1
- package/dist/validators/index.d.ts +0 -8
- package/src/adapters/customFields.ts +0 -85
- package/src/adapters/index.ts +0 -1
- package/src/api/auth.ts +0 -88
- package/src/api/cart.ts +0 -28
- package/src/api/checkout.ts +0 -28
- package/src/api/common.ts +0 -190
- package/src/api/guestTicketDelegation.ts +0 -79
- package/src/api/index.ts +0 -346
- package/src/api/interceptors.ts +0 -77
- package/src/api/orders.ts +0 -30
- package/src/api/payment.ts +0 -77
- package/src/api/preRegistrationComplete.ts +0 -37
- package/src/api/publicRequest.ts +0 -47
- package/src/api/resale.ts +0 -28
- package/src/assets/images/Polygon.png +0 -0
- package/src/assets/images/cross.svg +0 -44
- package/src/assets/images/done.svg +0 -3
- package/src/assets/images/edit.svg +0 -10
- package/src/assets/images/email.svg +0 -1
- package/src/assets/images/instagram.svg +0 -5
- package/src/assets/images/logo-ttf.png +0 -0
- package/src/assets/images/spotify.svg +0 -6
- package/src/assets/images/user.svg +0 -1
- package/src/assets/images/xmark.svg +0 -92
- package/src/components/account-settings/index.tsx +0 -161
- package/src/components/account-settings/style.css +0 -200
- package/src/components/addonsContainer/AddonComponent.tsx +0 -204
- package/src/components/addonsContainer/SimpleAddonsContainer.tsx +0 -459
- package/src/components/addonsContainer/adapters/index.tsx +0 -62
- package/src/components/addonsContainer/index.tsx +0 -353
- package/src/components/addonsContainer/normalizers/index.ts +0 -5
- package/src/components/addonsContainer/useAddons.ts +0 -248
- package/src/components/addonsContainer/utils/index.tsx +0 -231
- package/src/components/billing-info-container/hooks/index.ts +0 -3
- package/src/components/billing-info-container/hooks/usePaymentContext.ts +0 -22
- package/src/components/billing-info-container/hooks/usePaymentRedirect.ts +0 -145
- package/src/components/billing-info-container/hooks/useStripePayment.ts +0 -119
- package/src/components/billing-info-container/index.tsx +0 -1695
- package/src/components/billing-info-container/style.css +0 -150
- package/src/components/billing-info-container/utils.tsx +0 -413
- package/src/components/common/Checkbox.tsx +0 -51
- package/src/components/common/CheckboxField/index.tsx +0 -41
- package/src/components/common/CopyField.tsx +0 -53
- package/src/components/common/CopyMessageModal.tsx +0 -34
- package/src/components/common/CustomField.tsx +0 -168
- package/src/components/common/DatePickerField.tsx +0 -126
- package/src/components/common/FieldSection/index.tsx +0 -141
- package/src/components/common/FieldSection/utils/index.tsx +0 -92
- package/src/components/common/FormikPhoneNumberField.tsx +0 -51
- package/src/components/common/Loader.tsx +0 -8
- package/src/components/common/ModalComponent/index.tsx +0 -68
- package/src/components/common/NativeSelectFeild/index.tsx +0 -86
- package/src/components/common/PhoneNumberField.tsx +0 -117
- package/src/components/common/PoweredBy.tsx +0 -15
- package/src/components/common/RadioField.tsx +0 -36
- package/src/components/common/RadioGroupField/index.tsx +0 -76
- package/src/components/common/RedirectModal.tsx +0 -43
- package/src/components/common/SelectField/index.tsx +0 -104
- package/src/components/common/SnackbarAlert.tsx +0 -52
- package/src/components/common/index.tsx +0 -11
- package/src/components/common/socials.tsx +0 -33
- package/src/components/confirmModal/index.tsx +0 -60
- package/src/components/confirmationContainer/config.ts +0 -79
- package/src/components/confirmationContainer/index.tsx +0 -349
- package/src/components/confirmationContainer/social-buttons.tsx +0 -149
- package/src/components/confirmationContainer/style.css +0 -206
- package/src/components/countdown/index.tsx +0 -100
- package/src/components/countdown/style.css +0 -10
- package/src/components/delegationsContainer/IssueComponent.tsx +0 -156
- package/src/components/delegationsContainer/IssueTicketForm.tsx +0 -109
- package/src/components/delegationsContainer/TicketsAssignedTable.tsx +0 -55
- package/src/components/delegationsContainer/TicketsAvailableTable.tsx +0 -54
- package/src/components/delegationsContainer/index.tsx +0 -83
- package/src/components/forgotPasswordModal/index.tsx +0 -138
- package/src/components/forgotPasswordModal/style.css +0 -47
- package/src/components/idVerificationContainer/VerificationPendingModal.tsx +0 -47
- package/src/components/idVerificationContainer/constants.ts +0 -27
- package/src/components/idVerificationContainer/index.tsx +0 -323
- package/src/components/index.ts +0 -12
- package/src/components/loginForm/index.tsx +0 -202
- package/src/components/loginModal/SignUpForm.tsx +0 -329
- package/src/components/loginModal/constants.ts +0 -46
- package/src/components/loginModal/index.tsx +0 -263
- package/src/components/loginModal/style.css +0 -116
- package/src/components/myTicketsContainer/index.tsx +0 -228
- package/src/components/myTicketsContainer/row.tsx +0 -46
- package/src/components/myTicketsContainer/style.css +0 -40
- package/src/components/myTicketsContainer/tableConfig.tsx +0 -80
- package/src/components/myTicketsContainer/types.d.ts +0 -41
- package/src/components/orderDetailsContainer/CustomFieldsForm.tsx +0 -75
- package/src/components/orderDetailsContainer/TicketHolderCustomFields.tsx +0 -100
- package/src/components/orderDetailsContainer/index.tsx +0 -586
- package/src/components/orderDetailsContainer/style.css +0 -77
- package/src/components/orderDetailsContainer/ticketsTable.tsx +0 -246
- package/src/components/orderDetailsContainer/utils/index.tsx +0 -55
- package/src/components/paymentContainer/OrderDetails.tsx +0 -277
- package/src/components/paymentContainer/PaymentPlanSection.tsx +0 -169
- package/src/components/paymentContainer/handlePayment.ts +0 -86
- package/src/components/paymentContainer/index.tsx +0 -643
- package/src/components/paymentContainer/style.css +0 -196
- package/src/components/preRegistration/FieldsSection.tsx +0 -150
- package/src/components/preRegistration/Influancers.tsx +0 -34
- package/src/components/preRegistration/PreRegistrationComplete.tsx +0 -186
- package/src/components/preRegistration/PreRegistrationInformations.tsx +0 -60
- package/src/components/preRegistration/Prewards.tsx +0 -41
- package/src/components/preRegistration/ShareOptions.tsx +0 -77
- package/src/components/preRegistration/constants.tsx +0 -169
- package/src/components/preRegistration/index.tsx +0 -330
- package/src/components/preRegistration/style.css +0 -3
- package/src/components/preRegistration/utils.ts +0 -163
- package/src/components/registerForm/adapters/index.tsx +0 -10
- package/src/components/registerForm/constants.tsx +0 -98
- package/src/components/registerForm/index.tsx +0 -188
- package/src/components/registerModal/index.tsx +0 -154
- package/src/components/registerModal/style.css +0 -18
- package/src/components/resetPasswordContainer/index.tsx +0 -102
- package/src/components/resetPasswordContainer/style.css +0 -36
- package/src/components/rsvpContainer/index.tsx +0 -126
- package/src/components/seatMapContainer/SeatMapComponent.tsx +0 -77
- package/src/components/seatMapContainer/TicketsSection.tsx +0 -286
- package/src/components/seatMapContainer/addToCart.ts +0 -66
- package/src/components/seatMapContainer/index.tsx +0 -443
- package/src/components/seatMapContainer/utils.ts +0 -133
- package/src/components/signupModal/index.tsx +0 -178
- package/src/components/signupModal/style.css +0 -58
- package/src/components/ticketResale/index.tsx +0 -86
- package/src/components/ticketResaleModal/index.tsx +0 -224
- package/src/components/ticketResaleModal/style.css +0 -28
- package/src/components/ticketsContainer/AccessCodeSection.tsx +0 -50
- package/src/components/ticketsContainer/InfoIcon.tsx +0 -35
- package/src/components/ticketsContainer/PromoCodeSection.tsx +0 -116
- package/src/components/ticketsContainer/ReferralLogic.tsx +0 -33
- package/src/components/ticketsContainer/TicketRow.tsx +0 -107
- package/src/components/ticketsContainer/TicketsSection.tsx +0 -350
- package/src/components/ticketsContainer/TimeSlotTicketRow.tsx +0 -243
- package/src/components/ticketsContainer/TimeSlotsSection.tsx +0 -194
- package/src/components/ticketsContainer/index.tsx +0 -986
- package/src/components/ticketsContainer/style.css +0 -178
- package/src/components/ticketsContainer/utils.ts +0 -35
- package/src/components/timerWidget/index.tsx +0 -97
- package/src/components/timerWidget/style.css +0 -35
- package/src/components/waitingList/index.tsx +0 -190
- package/src/components/waitingList/style.css +0 -27
- package/src/constants/index.ts +0 -3
- package/src/env.ts +0 -29
- package/src/hoc/CustomFields/index.tsx +0 -85
- package/src/hoc/index.ts +0 -1
- package/src/hooks/index.ts +0 -1
- package/src/hooks/useCookieListener.ts +0 -32
- package/src/hooks/useEventListener.ts +0 -32
- package/src/hooks/useLocalStorageListener.ts +0 -32
- package/src/hooks/useOnline.ts +0 -21
- package/src/hooks/usePixel.ts +0 -88
- package/src/normalizers/index.ts +0 -49
- package/src/types/add_on.ts +0 -8
- package/src/types/api/auth.d.ts +0 -63
- package/src/types/api/axiosResponse.d.ts +0 -6
- package/src/types/api/cart.d.ts +0 -73
- package/src/types/api/checkout.d.ts +0 -92
- package/src/types/api/common.d.ts +0 -153
- package/src/types/api/guestTicketDelegation.d.ts +0 -18
- package/src/types/api/orders.d.ts +0 -116
- package/src/types/api/payment.d.ts +0 -180
- package/src/types/api/preRegistration.d.ts +0 -11
- package/src/types/api/preRegistrationComplete.d.ts +0 -95
- package/src/types/api/ticketResale.d.ts +0 -13
- package/src/types/billing-info-data.ts +0 -37
- package/src/types/checkoutPageConfigs.ts +0 -13
- package/src/types/formFields.d.ts +0 -29
- package/src/types/index.ts +0 -6
- package/src/types/order-data.ts +0 -16
- package/src/types/payment-field.ts +0 -7
- package/src/types/payment-plan-configuration.ts +0 -19
- package/src/types/pre-registration-complete.d.ts +0 -47
- package/src/types/referral-promotion.ts +0 -7
- package/src/types/seatMap.d.ts +0 -159
- package/src/types/verification.ts +0 -12
- package/src/utils/adaptStripeErrors.ts +0 -26
- package/src/utils/auth.ts +0 -45
- package/src/utils/cookies.ts +0 -73
- package/src/utils/createCheckoutDataBodyWithDefaultHolder.ts +0 -81
- package/src/utils/createMarkup.ts +0 -1
- package/src/utils/customFields.ts +0 -80
- package/src/utils/downloadPDF.tsx +0 -42
- package/src/utils/form.ts +0 -34
- package/src/utils/formikErrorFocus.ts +0 -24
- package/src/utils/getDomain.ts +0 -21
- package/src/utils/getImage.ts +0 -14
- package/src/utils/getQueryVariable.ts +0 -13
- package/src/utils/htmlNodeFromString.ts +0 -6
- package/src/utils/index.ts +0 -15
- package/src/utils/isBrowser.ts +0 -2
- package/src/utils/isValidNumber.ts +0 -8
- package/src/utils/jsonUtils.ts +0 -8
- package/src/utils/replaceVarInString.ts +0 -9
- package/src/utils/setConfigs.ts +0 -24
- package/src/utils/showZero.tsx +0 -10
- package/src/validators/index.ts +0 -61
|
@@ -1,459 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
|
|
3
|
-
import { CircularProgress } from '@mui/material'
|
|
4
|
-
import { Form, Formik } from 'formik'
|
|
5
|
-
import _identity from 'lodash/identity'
|
|
6
|
-
import _map from 'lodash/map'
|
|
7
|
-
import React, { useEffect, useMemo, useState } from 'react'
|
|
8
|
-
import { Tooltip } from 'react-tooltip'
|
|
9
|
-
|
|
10
|
-
import { getAddons, getCart } from '../../api'
|
|
11
|
-
import { FEES_STYLES } from '../../constants'
|
|
12
|
-
import { currencyNormalizerCreator } from '../../normalizers'
|
|
13
|
-
import { CONFIGS, createMarkup } from '../../utils'
|
|
14
|
-
import InfoIcon from '../ticketsContainer/InfoIcon'
|
|
15
|
-
import { addonsWithGroupsAdapter, cartAdapter } from './adapters'
|
|
16
|
-
import AddonComponent from './AddonComponent'
|
|
17
|
-
import { getNormalizedPrice } from './normalizers'
|
|
18
|
-
import {
|
|
19
|
-
generateSelectOptions,
|
|
20
|
-
getAddonSelectOptions,
|
|
21
|
-
getSortedAddons,
|
|
22
|
-
getTicketRelatedAddons,
|
|
23
|
-
} from './utils'
|
|
24
|
-
|
|
25
|
-
export interface ISimpleAddonContainerProps {
|
|
26
|
-
classNamePrefix?: string;
|
|
27
|
-
onGetAddonsPageInfoSuccess?: (res: any) => void;
|
|
28
|
-
onGetAddonsPageInfoError?: (error: any) => void;
|
|
29
|
-
descriptionTrigger?: 'click' | 'hover' | 'always';
|
|
30
|
-
addOnDataWithCustomFields: any;
|
|
31
|
-
configs: any;
|
|
32
|
-
eventId: string;
|
|
33
|
-
useStepperQty?: boolean;
|
|
34
|
-
maxTotalQuantity?: number;
|
|
35
|
-
addonMaxQuantityGroups?: number;
|
|
36
|
-
onAddOnSelect?: (id: string, value: string, addon: any, fieldUpdates: any) => void;
|
|
37
|
-
handleConfirm?: (values: any) => void;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export interface ObjectLiteral {
|
|
41
|
-
[key: string]: any;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export const SimpleAddonsContainer = ({
|
|
45
|
-
classNamePrefix = 'add_on',
|
|
46
|
-
onGetAddonsPageInfoSuccess = _identity,
|
|
47
|
-
onGetAddonsPageInfoError = _identity,
|
|
48
|
-
descriptionTrigger = 'click',
|
|
49
|
-
addOnDataWithCustomFields,
|
|
50
|
-
configs,
|
|
51
|
-
eventId,
|
|
52
|
-
useStepperQty = false,
|
|
53
|
-
addonMaxQuantityGroups,
|
|
54
|
-
onAddOnSelect = _identity,
|
|
55
|
-
handleConfirm = _identity,
|
|
56
|
-
}: ISimpleAddonContainerProps) => {
|
|
57
|
-
const [addons, setAddons] = useState<any>(null)
|
|
58
|
-
const [addonsOptions, setAddonsOptions] = useState<any>({})
|
|
59
|
-
const [groupsWithSelectedVariants, setGroupsWithSelectedVariants] = useState<any>({})
|
|
60
|
-
const [groupsWithInitialVariantsValues, setGroupsWithInitialVariantsValues] =
|
|
61
|
-
useState<any>({})
|
|
62
|
-
const [crossGroupSelections, setCrossGroupSelections] = useState<ObjectLiteral>({})
|
|
63
|
-
const [loading, setLoading] = useState(true)
|
|
64
|
-
|
|
65
|
-
const [visibleDescription, setVisibleDescription] = useState<string | null>(null)
|
|
66
|
-
|
|
67
|
-
const handleDescriptionToggle = (ticketId: string) => {
|
|
68
|
-
setVisibleDescription(current => (current === ticketId ? null : ticketId))
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// build { [fieldName]: value } for one addon from current Formik values
|
|
72
|
-
const collectAddonFieldUpdates = (addon: any, allValues: Record<string, any>) => {
|
|
73
|
-
const out: Record<string, any> = {}
|
|
74
|
-
if (!addOnDataWithCustomFields?.fields?.length) return out
|
|
75
|
-
addOnDataWithCustomFields.fields.forEach((group: any) => {
|
|
76
|
-
group.groupItems.forEach((item: any) => {
|
|
77
|
-
const k = `${addon.id}-${group.id}-${item.name}`
|
|
78
|
-
if (k in allValues) out[item.name] = allValues[k]
|
|
79
|
-
})
|
|
80
|
-
})
|
|
81
|
-
return out
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// live-sync a single custom field change into localStorage.add_on_data_capture
|
|
85
|
-
const handleCustomFieldChange = (
|
|
86
|
-
addon: any,
|
|
87
|
-
_groupId: string | number,
|
|
88
|
-
fieldName: string,
|
|
89
|
-
value: any
|
|
90
|
-
) => {
|
|
91
|
-
const existing = JSON.parse(localStorage.getItem('add_on_data_capture') || '{}')
|
|
92
|
-
const addonId = String(addon.id)
|
|
93
|
-
const next = {
|
|
94
|
-
...existing,
|
|
95
|
-
[addonId]: { ...(existing[addonId] || {}), [fieldName]: value },
|
|
96
|
-
}
|
|
97
|
-
localStorage.setItem('add_on_data_capture', JSON.stringify(next))
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
useEffect(() => {
|
|
101
|
-
const getAddonsPageInfo = async () => {
|
|
102
|
-
try {
|
|
103
|
-
if (eventId) {
|
|
104
|
-
setLoading(true)
|
|
105
|
-
|
|
106
|
-
// Get choosed ticket info (id, count) from Cart request for addons options calculations
|
|
107
|
-
const cart = await getCart()
|
|
108
|
-
const { id: choosedTicketID, quantity } = cartAdapter(cart)
|
|
109
|
-
const choosedTicketCount = Number(quantity)
|
|
110
|
-
|
|
111
|
-
// Get and collect addons data
|
|
112
|
-
const addonsData = await getAddons(eventId)
|
|
113
|
-
const adaptedAddons = addonsWithGroupsAdapter(addonsData)
|
|
114
|
-
const ticketRelatedAddons = getTicketRelatedAddons(
|
|
115
|
-
adaptedAddons,
|
|
116
|
-
choosedTicketID
|
|
117
|
-
)
|
|
118
|
-
const sortedTicketAddons = getSortedAddons(ticketRelatedAddons)
|
|
119
|
-
|
|
120
|
-
setAddons(sortedTicketAddons)
|
|
121
|
-
|
|
122
|
-
// Collect addons and addon group options
|
|
123
|
-
const {
|
|
124
|
-
addonsWithOptions,
|
|
125
|
-
groupsWithSelectedVariantsInfo,
|
|
126
|
-
groupsWithVariants,
|
|
127
|
-
} = getAddonSelectOptions(adaptedAddons, choosedTicketCount)
|
|
128
|
-
|
|
129
|
-
setAddonsOptions(addonsWithOptions)
|
|
130
|
-
setGroupsWithSelectedVariants(groupsWithSelectedVariantsInfo)
|
|
131
|
-
setGroupsWithInitialVariantsValues(groupsWithVariants)
|
|
132
|
-
|
|
133
|
-
// Success callback props
|
|
134
|
-
onGetAddonsPageInfoSuccess(addonsData)
|
|
135
|
-
}
|
|
136
|
-
} catch (e) {
|
|
137
|
-
// Callback error props
|
|
138
|
-
onGetAddonsPageInfoError(e)
|
|
139
|
-
} finally {
|
|
140
|
-
setLoading(false)
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
getAddonsPageInfo()
|
|
145
|
-
}, [eventId, onGetAddonsPageInfoError, onGetAddonsPageInfoSuccess])
|
|
146
|
-
|
|
147
|
-
const recreateGroupVariantsSelectOptions = (groupId: any, changedGroupd: any) => {
|
|
148
|
-
const { choosedVariants, limit, selectedCount } = changedGroupd
|
|
149
|
-
const remainingGroupStock = limit - selectedCount
|
|
150
|
-
const recreatedVariantsOptions: ObjectLiteral = {}
|
|
151
|
-
|
|
152
|
-
// Regenerate variants allowed stock counts
|
|
153
|
-
for (const variant in choosedVariants) {
|
|
154
|
-
const variantId = variant
|
|
155
|
-
const variantCurrSelectedValue = choosedVariants[variant]
|
|
156
|
-
let allowedOptionCount
|
|
157
|
-
|
|
158
|
-
// Formula for regenerating
|
|
159
|
-
if (
|
|
160
|
-
remainingGroupStock >=
|
|
161
|
-
groupsWithInitialVariantsValues[groupId][variantId] - variantCurrSelectedValue
|
|
162
|
-
) {
|
|
163
|
-
allowedOptionCount = groupsWithInitialVariantsValues[groupId][variantId]
|
|
164
|
-
} else {
|
|
165
|
-
allowedOptionCount = remainingGroupStock + variantCurrSelectedValue
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
recreatedVariantsOptions[variantId] = generateSelectOptions(0, allowedOptionCount)
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
setAddonsOptions((prevState: any) =>
|
|
172
|
-
Object.assign({}, prevState, recreatedVariantsOptions)
|
|
173
|
-
)
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
const onFieldChange = (id: any, value: any, addon: any) => {
|
|
177
|
-
// If changeableGroup exsists it means that group with limitation variant was changed
|
|
178
|
-
const changeableGroup = groupsWithSelectedVariants[addon.id]
|
|
179
|
-
|
|
180
|
-
if (changeableGroup) {
|
|
181
|
-
const currGroupId = addon.id
|
|
182
|
-
const currSelectedVariantId = id
|
|
183
|
-
const currSelectedVariantCount = Number(value)
|
|
184
|
-
const currSelectedVariantPrevCount =
|
|
185
|
-
groupsWithSelectedVariants[currGroupId].choosedVariants[currSelectedVariantId]
|
|
186
|
-
|
|
187
|
-
const currSelectedGroupCount =
|
|
188
|
-
changeableGroup.selectedCount +
|
|
189
|
-
(currSelectedVariantCount - currSelectedVariantPrevCount)
|
|
190
|
-
|
|
191
|
-
// Update Group info
|
|
192
|
-
const updatedGroupsWithSelectedVariants = {
|
|
193
|
-
...groupsWithSelectedVariants,
|
|
194
|
-
[currGroupId]: {
|
|
195
|
-
...groupsWithSelectedVariants[currGroupId],
|
|
196
|
-
selectedCount: currSelectedGroupCount,
|
|
197
|
-
choosedVariants: {
|
|
198
|
-
...groupsWithSelectedVariants[currGroupId].choosedVariants,
|
|
199
|
-
[currSelectedVariantId]: currSelectedVariantCount,
|
|
200
|
-
},
|
|
201
|
-
},
|
|
202
|
-
}
|
|
203
|
-
setGroupsWithSelectedVariants(updatedGroupsWithSelectedVariants)
|
|
204
|
-
|
|
205
|
-
// Recreate Select Options for Addon Group Variants
|
|
206
|
-
recreateGroupVariantsSelectOptions(
|
|
207
|
-
currGroupId,
|
|
208
|
-
updatedGroupsWithSelectedVariants[currGroupId]
|
|
209
|
-
)
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// Cross-group cap: when addonMaxQuantityGroups is set, limits total selections
|
|
214
|
-
// across ALL addon groups to that number by capping each stepper's max.
|
|
215
|
-
const effectiveAddonsOptions = useMemo(() => {
|
|
216
|
-
if (!addonMaxQuantityGroups) return addonsOptions
|
|
217
|
-
|
|
218
|
-
const totalSelected = Object.values(crossGroupSelections).reduce(
|
|
219
|
-
(sum: number, v: any) => sum + Number(v), 0
|
|
220
|
-
)
|
|
221
|
-
const globalRemaining = addonMaxQuantityGroups - totalSelected
|
|
222
|
-
const result: ObjectLiteral = {}
|
|
223
|
-
|
|
224
|
-
for (const id in addonsOptions) {
|
|
225
|
-
const opts = addonsOptions[id] || []
|
|
226
|
-
const sdkMax = opts.length ? opts[opts.length - 1].value : 0
|
|
227
|
-
const currSelected = Number(crossGroupSelections[id] || 0)
|
|
228
|
-
const allowedMax = Math.max(0, Math.min(sdkMax, globalRemaining + currSelected))
|
|
229
|
-
result[id] = opts.filter((opt: any) => opt.value <= allowedMax)
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
return result
|
|
233
|
-
}, [addonsOptions, crossGroupSelections, addonMaxQuantityGroups])
|
|
234
|
-
|
|
235
|
-
const handleCrossGroupChange = (id: any, value: any) => {
|
|
236
|
-
if (addonMaxQuantityGroups) {
|
|
237
|
-
setCrossGroupSelections((prev: ObjectLiteral) => ({ ...prev, [id]: Number(value) }))
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
const initialValues = useMemo(() => {
|
|
242
|
-
const addOnsData: any = {}
|
|
243
|
-
if (addons?.length > 0 && addOnDataWithCustomFields?.fields?.length > 0) {
|
|
244
|
-
_map(addons, addon => {
|
|
245
|
-
_map(addOnDataWithCustomFields.fields, field => {
|
|
246
|
-
const { id, groupItems } = field
|
|
247
|
-
_map(groupItems, item => {
|
|
248
|
-
addOnsData[`${addon.id}-${id}-${item.name}`] = item.value
|
|
249
|
-
})
|
|
250
|
-
})
|
|
251
|
-
})
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
return addOnsData
|
|
255
|
-
}, [addons, addOnDataWithCustomFields])
|
|
256
|
-
|
|
257
|
-
if (loading || !addons) {
|
|
258
|
-
return (
|
|
259
|
-
<div className={`${classNamePrefix}_loader`}>
|
|
260
|
-
<CircularProgress size={50} />
|
|
261
|
-
</div>
|
|
262
|
-
)
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
return (
|
|
266
|
-
<div className={`${classNamePrefix}_container`}>
|
|
267
|
-
<div className={`${classNamePrefix}_block`}>
|
|
268
|
-
<div className={`${classNamePrefix}_line_block`}>
|
|
269
|
-
{addons?.length > 0 && (
|
|
270
|
-
<div className={`${classNamePrefix}_title`}>UPGRADES & ADD-ONS</div>
|
|
271
|
-
)}
|
|
272
|
-
</div>
|
|
273
|
-
{addons?.length > 0 && (
|
|
274
|
-
<div className={`${classNamePrefix}_subtitle`}>
|
|
275
|
-
PLEASE SELECT FROM THE OPTIONAL ADD-ONS BELOW
|
|
276
|
-
</div>
|
|
277
|
-
)}
|
|
278
|
-
<Formik
|
|
279
|
-
initialValues={initialValues}
|
|
280
|
-
onSubmit={values => {
|
|
281
|
-
handleConfirm(values)
|
|
282
|
-
}}
|
|
283
|
-
validate={() => {
|
|
284
|
-
// Real-time validation can be handled here if needed
|
|
285
|
-
}}
|
|
286
|
-
>
|
|
287
|
-
{({ values, errors, setFieldTouched }) => {
|
|
288
|
-
return (
|
|
289
|
-
<Form autoComplete="off" className="form_holder">
|
|
290
|
-
<>
|
|
291
|
-
{addons.map((addon: any) => {
|
|
292
|
-
const price = addon.feeIncluded ? addon.price : addon.cost
|
|
293
|
-
const isAddonFree = Number(addon?.price) === 0
|
|
294
|
-
|
|
295
|
-
const addOnNormalizedCost = isAddonFree
|
|
296
|
-
? 'FREE'
|
|
297
|
-
: currencyNormalizerCreator(
|
|
298
|
-
getNormalizedPrice(addon?.cost ?? 0),
|
|
299
|
-
addon.currency
|
|
300
|
-
)
|
|
301
|
-
|
|
302
|
-
const addonNormalizedPrice = isAddonFree
|
|
303
|
-
? 'FREE'
|
|
304
|
-
: currencyNormalizerCreator(
|
|
305
|
-
getNormalizedPrice(
|
|
306
|
-
CONFIGS.FEES_STYLE === FEES_STYLES.DISPLAY_BOTH
|
|
307
|
-
? addon?.price ?? price
|
|
308
|
-
: price
|
|
309
|
-
),
|
|
310
|
-
addon.currency
|
|
311
|
-
)
|
|
312
|
-
|
|
313
|
-
return (
|
|
314
|
-
<div key={addon.id} className={`${classNamePrefix}_product_block`}>
|
|
315
|
-
<div className={`${classNamePrefix}_product_images`}>
|
|
316
|
-
{addon.imageUrl && (
|
|
317
|
-
<div className={`${classNamePrefix}_product_image_block`}>
|
|
318
|
-
<img src={addon.imageUrl} alt="No Data" />
|
|
319
|
-
</div>
|
|
320
|
-
)}
|
|
321
|
-
</div>
|
|
322
|
-
<div className={`${classNamePrefix}_product_info_block`}>
|
|
323
|
-
<div className={`${classNamePrefix}_product_title`}>
|
|
324
|
-
{addon.name}
|
|
325
|
-
{addon.description && descriptionTrigger !== 'always' && (
|
|
326
|
-
<>
|
|
327
|
-
<span
|
|
328
|
-
aria-hidden
|
|
329
|
-
className="info-icon"
|
|
330
|
-
onClick={
|
|
331
|
-
descriptionTrigger === 'click'
|
|
332
|
-
? () => handleDescriptionToggle(addon.id)
|
|
333
|
-
: undefined
|
|
334
|
-
}
|
|
335
|
-
onMouseEnter={
|
|
336
|
-
descriptionTrigger === 'hover'
|
|
337
|
-
? () => setVisibleDescription(addon.id)
|
|
338
|
-
: undefined
|
|
339
|
-
}
|
|
340
|
-
onMouseLeave={
|
|
341
|
-
descriptionTrigger === 'hover'
|
|
342
|
-
? () => setVisibleDescription(null)
|
|
343
|
-
: undefined
|
|
344
|
-
}
|
|
345
|
-
style={{
|
|
346
|
-
marginLeft: 8,
|
|
347
|
-
cursor: 'pointer',
|
|
348
|
-
display: 'flex',
|
|
349
|
-
}}
|
|
350
|
-
data-tooltip-id={`tooltip-${addon.id}`}
|
|
351
|
-
data-tooltip-content="View Add-On info"
|
|
352
|
-
>
|
|
353
|
-
<InfoIcon size={14} />
|
|
354
|
-
</span>
|
|
355
|
-
<Tooltip id={`tooltip-${addon.id}`} place="top">
|
|
356
|
-
{addon.description || 'No description available'}
|
|
357
|
-
</Tooltip>
|
|
358
|
-
</>
|
|
359
|
-
)}
|
|
360
|
-
</div>
|
|
361
|
-
<div className={`${classNamePrefix}_product_price`}>
|
|
362
|
-
{CONFIGS.FEES_STYLE === FEES_STYLES.TRADITIONAL
|
|
363
|
-
? addonNormalizedPrice
|
|
364
|
-
: addOnNormalizedCost}
|
|
365
|
-
{!isAddonFree &&
|
|
366
|
-
CONFIGS.FEES_STYLE === FEES_STYLES.TRADITIONAL && (
|
|
367
|
-
<span className={`${classNamePrefix}_product_fee`}>
|
|
368
|
-
{addon.feeIncluded ? '(incl. Fees)' : '(excl. Fees)'}
|
|
369
|
-
</span>
|
|
370
|
-
)}
|
|
371
|
-
{!isAddonFree &&
|
|
372
|
-
CONFIGS.FEES_STYLE === FEES_STYLES.DISPLAY_BOTH && (
|
|
373
|
-
<>
|
|
374
|
-
<span className={`${classNamePrefix}_product_fee`}>
|
|
375
|
-
{`(${addonNormalizedPrice} with fees)`}
|
|
376
|
-
</span>
|
|
377
|
-
</>
|
|
378
|
-
)}
|
|
379
|
-
</div>
|
|
380
|
-
</div>
|
|
381
|
-
{(visibleDescription === addon.id ||
|
|
382
|
-
descriptionTrigger === 'always') && (
|
|
383
|
-
<div
|
|
384
|
-
className={`${classNamePrefix}_product_desc`}
|
|
385
|
-
dangerouslySetInnerHTML={createMarkup(addon.description)}
|
|
386
|
-
/>
|
|
387
|
-
)}
|
|
388
|
-
<div className={`${classNamePrefix}_product_select_container`}>
|
|
389
|
-
{addon.variants ? (
|
|
390
|
-
addon.variants.map((variant: any) => (
|
|
391
|
-
// Group Variants
|
|
392
|
-
<AddonComponent
|
|
393
|
-
key={variant.id}
|
|
394
|
-
data={variant}
|
|
395
|
-
selectOptions={effectiveAddonsOptions[variant.id]}
|
|
396
|
-
classNamePrefix={classNamePrefix}
|
|
397
|
-
siblingIds={addon.variants.filter((v: any) => v.id !== variant.id).map((v: any) => v.id)}
|
|
398
|
-
handleAddonChange={(id, value) => {
|
|
399
|
-
handleCrossGroupChange(id, value)
|
|
400
|
-
onFieldChange(id, value, addon)
|
|
401
|
-
const fieldUpdates = collectAddonFieldUpdates(
|
|
402
|
-
addon,
|
|
403
|
-
values
|
|
404
|
-
)
|
|
405
|
-
onAddOnSelect(id, value, addon, fieldUpdates)
|
|
406
|
-
}}
|
|
407
|
-
onCustomFieldChange={handleCustomFieldChange}
|
|
408
|
-
addOnDataWithCustomFields={addOnDataWithCustomFields}
|
|
409
|
-
configs={configs}
|
|
410
|
-
values={values}
|
|
411
|
-
errors={errors}
|
|
412
|
-
useStepperQty={useStepperQty}
|
|
413
|
-
/>
|
|
414
|
-
))
|
|
415
|
-
) : (
|
|
416
|
-
// Simple Addon
|
|
417
|
-
<AddonComponent
|
|
418
|
-
key={addon.id}
|
|
419
|
-
data={addon}
|
|
420
|
-
selectOptions={effectiveAddonsOptions[addon.id]}
|
|
421
|
-
classNamePrefix={classNamePrefix}
|
|
422
|
-
handleAddonChange={(id, value) => {
|
|
423
|
-
handleCrossGroupChange(id, value)
|
|
424
|
-
onFieldChange(id, value, addon)
|
|
425
|
-
const fieldUpdates = collectAddonFieldUpdates(addon, values)
|
|
426
|
-
onAddOnSelect(id, value, addon, fieldUpdates)
|
|
427
|
-
_map(addOnDataWithCustomFields.fields, fieldGroup => {
|
|
428
|
-
const { id, groupItems } = fieldGroup
|
|
429
|
-
_map(groupItems, field => {
|
|
430
|
-
setFieldTouched(
|
|
431
|
-
`${addon.id}-${id}-${field.name}`,
|
|
432
|
-
true,
|
|
433
|
-
true
|
|
434
|
-
)
|
|
435
|
-
})
|
|
436
|
-
})
|
|
437
|
-
}}
|
|
438
|
-
onCustomFieldChange={handleCustomFieldChange}
|
|
439
|
-
addOnDataWithCustomFields={addOnDataWithCustomFields}
|
|
440
|
-
configs={configs}
|
|
441
|
-
values={values}
|
|
442
|
-
errors={errors}
|
|
443
|
-
useStepperQty={useStepperQty}
|
|
444
|
-
/>
|
|
445
|
-
)}
|
|
446
|
-
</div>
|
|
447
|
-
</div>
|
|
448
|
-
)
|
|
449
|
-
})}
|
|
450
|
-
</>
|
|
451
|
-
</Form>
|
|
452
|
-
)}}
|
|
453
|
-
</Formik>
|
|
454
|
-
</div>
|
|
455
|
-
</div>
|
|
456
|
-
)
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
export default SimpleAddonsContainer
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import _get from 'lodash/get'
|
|
2
|
-
import _isEmpty from 'lodash/isEmpty'
|
|
3
|
-
|
|
4
|
-
export interface IAddOnsData {
|
|
5
|
-
add_on_groups: Array<{ [key: string]: any }>;
|
|
6
|
-
add_ons: Array<[]>;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const addonsWithGroupsAdapter = (data: IAddOnsData) => {
|
|
10
|
-
const addonsData = { ...data }
|
|
11
|
-
const addOnsGroups = _get(addonsData, 'add_on_groups', [])
|
|
12
|
-
const addons = _get(addonsData, 'add_ons', [])
|
|
13
|
-
|
|
14
|
-
if (!_isEmpty(addOnsGroups)) {
|
|
15
|
-
const addOnGroupsWithVariants: any = []
|
|
16
|
-
const addOnsWithoutVariants: any = []
|
|
17
|
-
|
|
18
|
-
addons.forEach((addon: any) => {
|
|
19
|
-
if (addon.attributes.addOnGroupId) {
|
|
20
|
-
// Collect addons groups inside with their variants
|
|
21
|
-
const currentGroupId = addon.attributes.addOnGroupId
|
|
22
|
-
const exsistingGroupIndex = addOnGroupsWithVariants.findIndex(
|
|
23
|
-
(item: any) => item.id === currentGroupId
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
if (addOnGroupsWithVariants[exsistingGroupIndex]) {
|
|
27
|
-
const addOnGroup = addOnGroupsWithVariants[exsistingGroupIndex]
|
|
28
|
-
addOnGroupsWithVariants[exsistingGroupIndex] = {
|
|
29
|
-
...addOnGroup,
|
|
30
|
-
variants: [...addOnGroup.variants, ...addon.attributes],
|
|
31
|
-
}
|
|
32
|
-
} else {
|
|
33
|
-
const group =
|
|
34
|
-
addOnsGroups.find(group => group.attributes.id === currentGroupId) || {}
|
|
35
|
-
|
|
36
|
-
addOnGroupsWithVariants.push({
|
|
37
|
-
...group.attributes,
|
|
38
|
-
variants: [...addon.attributes],
|
|
39
|
-
})
|
|
40
|
-
}
|
|
41
|
-
} else {
|
|
42
|
-
addOnsWithoutVariants.push(addon.attributes)
|
|
43
|
-
}
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
return addOnGroupsWithVariants.concat(addOnsWithoutVariants)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Adapt only simple addons data
|
|
50
|
-
const adaptedAddons = (addons as any[]).map((addon: any) => ({
|
|
51
|
-
...addon.attributes,
|
|
52
|
-
}))
|
|
53
|
-
return adaptedAddons
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export const cartAdapter = (cart: any) => {
|
|
57
|
-
const cartData = _get(cart, 'data.attributes', [])
|
|
58
|
-
const { expiresAt, cart: carts_arr } = cartData
|
|
59
|
-
const { id, quantity } = carts_arr[0] || {}
|
|
60
|
-
|
|
61
|
-
return { id, quantity, expiresAt }
|
|
62
|
-
}
|