tf-checkout-react 1.6.6 → 1.7.2

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.
Files changed (137) hide show
  1. package/README.md +401 -59
  2. package/dist/adapters/customFields.d.ts +1 -0
  3. package/dist/api/checkout.d.ts +2 -0
  4. package/dist/api/common.d.ts +1 -0
  5. package/dist/api/index.d.ts +2 -0
  6. package/dist/api/preRegistrationComplete.d.ts +1 -1
  7. package/dist/components/addonsContainer/AddonComponent.d.ts +6 -1
  8. package/dist/components/addonsContainer/SimpleAddonsContainer.d.ts +17 -0
  9. package/dist/components/addonsContainer/index.d.ts +6 -1
  10. package/dist/components/billing-info-container/hooks/index.d.ts +3 -0
  11. package/dist/components/billing-info-container/hooks/usePaymentContext.d.ts +5 -0
  12. package/dist/components/billing-info-container/hooks/usePaymentRedirect.d.ts +14 -0
  13. package/dist/components/billing-info-container/hooks/useStripePayment.d.ts +18 -0
  14. package/dist/components/billing-info-container/index.d.ts +13 -2
  15. package/dist/components/billing-info-container/utils.d.ts +26 -1
  16. package/dist/components/common/DatePickerField.d.ts +7 -1
  17. package/dist/components/common/PhoneNumberField.d.ts +1 -1
  18. package/dist/components/confirmationContainer/index.d.ts +4 -1
  19. package/dist/components/countdown/index.d.ts +1 -1
  20. package/dist/components/forgotPasswordModal/index.d.ts +2 -1
  21. package/dist/components/myTicketsContainer/index.d.ts +3 -2
  22. package/dist/components/orderDetailsContainer/index.d.ts +8 -1
  23. package/dist/components/paymentContainer/OrderDetails.d.ts +9 -0
  24. package/dist/components/paymentContainer/handlePayment.d.ts +15 -0
  25. package/dist/components/paymentContainer/index.d.ts +12 -6
  26. package/dist/components/preRegistration/FieldsSection.d.ts +7 -1
  27. package/dist/components/preRegistration/PreRegistrationComplete.d.ts +8 -0
  28. package/dist/components/preRegistration/constants.d.ts +2 -2
  29. package/dist/components/preRegistration/index.d.ts +6 -0
  30. package/dist/components/resetPasswordContainer/index.d.ts +2 -2
  31. package/dist/components/ticketsContainer/InfoIcon.d.ts +5 -0
  32. package/dist/components/ticketsContainer/TicketsSection.d.ts +3 -2
  33. package/dist/components/ticketsContainer/TimeSlotsSection.d.ts +25 -0
  34. package/dist/components/ticketsContainer/index.d.ts +29 -5
  35. package/dist/components/timerWidget/index.d.ts +2 -1
  36. package/dist/constants/index.d.ts +5 -0
  37. package/dist/index.d.ts +4 -1
  38. package/dist/tf-checkout-react.cjs.development.js +11284 -9565
  39. package/dist/tf-checkout-react.cjs.development.js.map +1 -1
  40. package/dist/tf-checkout-react.cjs.production.min.js +1 -1
  41. package/dist/tf-checkout-react.cjs.production.min.js.map +1 -1
  42. package/dist/tf-checkout-react.esm.js +11293 -9577
  43. package/dist/tf-checkout-react.esm.js.map +1 -1
  44. package/dist/tf-checkout-styles.css +1 -1
  45. package/dist/types/add_on.d.ts +1 -0
  46. package/dist/types/checkoutPageConfigs.d.ts +1 -1
  47. package/dist/types/order-data.d.ts +3 -1
  48. package/dist/utils/auth.d.ts +8 -0
  49. package/dist/utils/createCheckoutDataBodyWithDefaultHolder.d.ts +1 -0
  50. package/dist/utils/customFields.d.ts +11 -0
  51. package/dist/utils/getDomain.d.ts +1 -1
  52. package/dist/utils/index.d.ts +1 -1
  53. package/dist/utils/setConfigs.d.ts +1 -0
  54. package/package.json +14 -8
  55. package/src/adapters/customFields.ts +7 -1
  56. package/src/api/auth.ts +2 -1
  57. package/src/api/checkout.ts +9 -4
  58. package/src/api/common.ts +49 -2
  59. package/src/api/index.ts +1 -0
  60. package/src/api/interceptors.ts +7 -23
  61. package/src/api/preRegistrationComplete.ts +1 -1
  62. package/src/api/publicRequest.ts +10 -0
  63. package/src/components/addonsContainer/AddonComponent.tsx +96 -11
  64. package/src/components/addonsContainer/SimpleAddonsContainer.tsx +420 -0
  65. package/src/components/addonsContainer/index.tsx +198 -47
  66. package/src/components/billing-info-container/hooks/index.ts +3 -0
  67. package/src/components/billing-info-container/hooks/usePaymentContext.ts +22 -0
  68. package/src/components/billing-info-container/hooks/usePaymentRedirect.ts +147 -0
  69. package/src/components/billing-info-container/hooks/useStripePayment.ts +121 -0
  70. package/src/components/billing-info-container/index.tsx +859 -418
  71. package/src/components/billing-info-container/{utils.ts → utils.tsx} +124 -1
  72. package/src/components/common/CheckboxField/index.tsx +1 -1
  73. package/src/components/common/CustomField.tsx +39 -3
  74. package/src/components/common/DatePickerField.tsx +25 -10
  75. package/src/components/common/PhoneNumberField.tsx +4 -2
  76. package/src/components/common/SnackbarAlert.tsx +32 -34
  77. package/src/components/confirmationContainer/config.ts +3 -3
  78. package/src/components/confirmationContainer/index.tsx +20 -1
  79. package/src/components/confirmationContainer/social-buttons.tsx +5 -3
  80. package/src/components/confirmationContainer/style.css +9 -5
  81. package/src/components/countdown/index.tsx +22 -22
  82. package/src/components/delegationsContainer/IssueComponent.tsx +2 -1
  83. package/src/components/forgotPasswordModal/index.tsx +44 -13
  84. package/src/components/loginForm/index.tsx +1 -1
  85. package/src/components/loginModal/index.tsx +19 -27
  86. package/src/components/loginModal/style.css +3 -1
  87. package/src/components/myTicketsContainer/index.tsx +13 -9
  88. package/src/components/orderDetailsContainer/index.tsx +206 -174
  89. package/src/components/paymentContainer/OrderDetails.tsx +257 -0
  90. package/src/components/paymentContainer/handlePayment.ts +86 -0
  91. package/src/components/paymentContainer/index.tsx +299 -259
  92. package/src/components/paymentContainer/style.css +141 -0
  93. package/src/components/preRegistration/FieldsSection.tsx +8 -0
  94. package/src/components/preRegistration/PreRegistrationComplete.tsx +138 -118
  95. package/src/components/preRegistration/PreRegistrationInformations.tsx +21 -15
  96. package/src/components/preRegistration/constants.tsx +10 -4
  97. package/src/components/preRegistration/index.tsx +233 -179
  98. package/src/components/preRegistration/style.css +3 -0
  99. package/src/components/registerForm/constants.tsx +3 -1
  100. package/src/components/registerForm/index.tsx +3 -3
  101. package/src/components/registerModal/index.tsx +47 -72
  102. package/src/components/resetPasswordContainer/index.tsx +20 -14
  103. package/src/components/seatMapContainer/TicketsSection.tsx +2 -2
  104. package/src/components/signupModal/index.tsx +13 -6
  105. package/src/components/ticketResale/index.tsx +7 -0
  106. package/src/components/ticketsContainer/InfoIcon.tsx +35 -0
  107. package/src/components/ticketsContainer/PromoCodeSection.tsx +34 -28
  108. package/src/components/ticketsContainer/TicketRow.tsx +1 -1
  109. package/src/components/ticketsContainer/TicketsSection.tsx +189 -57
  110. package/src/components/ticketsContainer/TimeSlotsSection.tsx +120 -0
  111. package/src/components/ticketsContainer/index.tsx +268 -106
  112. package/src/components/timerWidget/index.tsx +15 -3
  113. package/src/components/timerWidget/style.css +2 -1
  114. package/src/constants/index.ts +2 -0
  115. package/src/env.ts +14 -6
  116. package/src/hoc/CustomFields/index.tsx +9 -1
  117. package/src/index.ts +7 -2
  118. package/src/types/add_on.ts +1 -0
  119. package/src/types/api/cart.d.ts +8 -0
  120. package/src/types/api/checkout.d.ts +58 -7
  121. package/src/types/api/common.d.ts +30 -0
  122. package/src/types/api/orders.d.ts +19 -3
  123. package/src/types/api/payment.d.ts +6 -2
  124. package/src/types/api/preRegistrationComplete.d.ts +2 -2
  125. package/src/types/checkoutPageConfigs.ts +1 -1
  126. package/src/types/order-data.ts +3 -1
  127. package/src/types/pre-registration-complete.d.ts +6 -1
  128. package/src/utils/auth.ts +32 -0
  129. package/src/utils/cookies.ts +42 -11
  130. package/src/utils/createCheckoutDataBodyWithDefaultHolder.ts +3 -1
  131. package/src/utils/customFields.ts +22 -0
  132. package/src/utils/getDomain.ts +10 -4
  133. package/src/utils/index.ts +1 -1
  134. package/src/utils/setConfigs.ts +3 -1
  135. package/dist/components/stripePayment/index.d.ts +0 -24
  136. package/src/components/stripePayment/index.tsx +0 -281
  137. package/src/components/stripePayment/style.css +0 -60
@@ -3,6 +3,7 @@ import './style.css'
3
3
  import _identity from 'lodash/identity'
4
4
  import React, { memo, useState } from 'react'
5
5
  import Countdown from 'react-countdown'
6
+ import ReactDOM from 'react-dom'
6
7
  import SVG from 'react-inlinesvg'
7
8
 
8
9
  import Cross from '../../assets/images/cross.svg'
@@ -12,6 +13,7 @@ export interface ITimerWidgetPage {
12
13
  expires_at: number;
13
14
  buyLoading?: boolean;
14
15
  onCountdownFinish?: () => void;
16
+ container?: string;
15
17
  }
16
18
 
17
19
  export interface IRenderer {
@@ -25,6 +27,7 @@ const TimerWidget = ({
25
27
  expires_at,
26
28
  buyLoading,
27
29
  onCountdownFinish = _identity,
30
+ container,
28
31
  }: ITimerWidgetPage) => {
29
32
  const [showTimer, setShowTimer] = useState(true)
30
33
 
@@ -59,9 +62,9 @@ const TimerWidget = ({
59
62
  }
60
63
  }
61
64
 
62
- return showTimer && !!expires_at ? (
65
+ const timerComponent = (
63
66
  <div className="timer">
64
- <div className="close-icon" onClick={hideTimer}>
67
+ <div aria-hidden className="close-icon" onClick={hideTimer}>
65
68
  <SVG src={Cross} width="10" height="10" fill="#fff" />
66
69
  </div>
67
70
  <div className="toast-message">
@@ -79,7 +82,16 @@ const TimerWidget = ({
79
82
  </p>
80
83
  </div>
81
84
  </div>
82
- ) : null
85
+ )
86
+
87
+ return showTimer && !!expires_at
88
+ ? container
89
+ ? ReactDOM.createPortal(
90
+ timerComponent,
91
+ document.querySelector(container) as HTMLElement
92
+ )
93
+ : timerComponent
94
+ : null
83
95
  }
84
96
 
85
97
  export default memo(TimerWidget)
@@ -1,5 +1,5 @@
1
1
  .timer {
2
- position: absolute;
2
+ position: fixed;
3
3
  pointer-events: auto;
4
4
  background-color: #000000;
5
5
  overflow: hidden;
@@ -18,6 +18,7 @@
18
18
  color: #fff;
19
19
  background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAGwSURBVEhLtZa9SgNBEMc9sUxxRcoUKSzSWIhXpFMhhYWFhaBg4yPYiWCXZxBLERsLRS3EQkEfwCKdjWJAwSKCgoKCcudv4O5YLrt7EzgXhiU3/4+b2ckmwVjJSpKkQ6wAi4gwhT+z3wRBcEz0yjSseUTrcRyfsHsXmD0AmbHOC9Ii8VImnuXBPglHpQ5wwSVM7sNnTG7Za4JwDdCjxyAiH3nyA2mtaTJufiDZ5dCaqlItILh1NHatfN5skvjx9Z38m69CgzuXmZgVrPIGE763Jx9qKsRozWYw6xOHdER+nn2KkO+Bb+UV5CBN6WC6QtBgbRVozrahAbmm6HtUsgtPC19tFdxXZYBOfkbmFJ1VaHA1VAHjd0pp70oTZzvR+EVrx2Ygfdsq6eu55BHYR8hlcki+n+kERUFG8BrA0BwjeAv2M8WLQBtcy+SD6fNsmnB3AlBLrgTtVW1c2QN4bVWLATaIS60J2Du5y1TiJgjSBvFVZgTmwCU+dAZFoPxGEEs8nyHC9Bwe2GvEJv2WXZb0vjdyFT4Cxk3e/kIqlOGoVLwwPevpYHT+00T+hWwXDf4AJAOUqWcDhbwAAAAASUVORK5CYII=);
20
20
  right: 15px;
21
+ z-index: 9;
21
22
  }
22
23
 
23
24
  .timer .close-icon {
@@ -1 +1,3 @@
1
1
  export const X_TF_ECOMMERCE = 'X-TF-ECOMMERCE'
2
+ export const FEES_STYLES = { TRADITIONAL: 'TRADITIONAL', DISPLAY_BOTH: 'DISPLAY_BOTH' }
3
+ export const DEFAULT_FEES_STYLE = FEES_STYLES.TRADITIONAL
package/src/env.ts CHANGED
@@ -1,13 +1,21 @@
1
1
  // preview
2
2
  export const ENV = {
3
- EVENT_ID: 13030,
4
- BASE_URL: 'https://test.ticketfairy.com',
5
- CLIENT_ID: 'e9d8f8922797b4621e562255afe90dbf',
6
- CLIENT_SECRET: 'b89c191eff22fdcf84ac9bfd88d005355a151ec2c83b26b9',
3
+ // EVENT_ID: 13090,
4
+ // BASE_URL: 'https://test.ticketfairy.com',
5
+ // CLIENT_ID: 'e9d8f8922797b4621e562255afe90dbf',
6
+ // CLIENT_SECRET: 'b89c191eff22fdcf84ac9bfd88d005355a151ec2c83b26b9',
7
+ // STRIPE_PUBLISHABLE_KEY:
8
+ // 'pk_test_51H4BkOGqveRD6EShliLrT9vd7mPOBPvQSuqmvc3wIinDqxWsCLeS2N7HonPPn6MhjU35ayYy5v4I6MLlD4jNWrd000NSgAF6UL',
9
+ // BRAND_SLUG: 'test-mana-brand',
10
+ // X_SOURCE_ORIGIN: 'manacommon.com'
11
+ EVENT_ID: 6607,
12
+ BASE_URL: 'https://ttf.localhost',
13
+ CLIENT_ID: '11b907373250ac4813129922b039a828',
14
+ CLIENT_SECRET: '48118a9b8ffd4b120dc63861e6d6c0202fef4a5dbc46b53b',
7
15
  STRIPE_PUBLISHABLE_KEY:
8
16
  'pk_test_51H4BkOGqveRD6EShliLrT9vd7mPOBPvQSuqmvc3wIinDqxWsCLeS2N7HonPPn6MhjU35ayYy5v4I6MLlD4jNWrd000NSgAF6UL',
9
- BRAND_SLUG: 'mana-common',
10
- X_SOURCE_ORIGIN: 'tickets-staging.manacommon.com',
17
+ BRAND_SLUG: 'nop',
18
+ X_SOURCE_ORIGIN: 'ttf.localhost'
11
19
  }
12
20
 
13
21
  // prod
@@ -9,6 +9,7 @@ import {
9
9
  getFieldsKeys,
10
10
  getQueryVariable,
11
11
  } from '../../utils'
12
+ import { getAddOnDataWithCustomFields } from '../../utils/customFields'
12
13
 
13
14
  const withCustomFields = (Children: any) => (props: any) => {
14
15
  const {
@@ -27,18 +28,21 @@ const withCustomFields = (Children: any) => (props: any) => {
27
28
  const [customFieldsData, setCustomFieldsData] = useState({} as any)
28
29
  const [customFieldsOrderKeys, setCustomFieldsOrderKeys] = useState([] as any)
29
30
  const [customFieldsTicketHolderKeys, setCustomFieldsTicketHolderKeys] = useState([] as any)
31
+ const [customFieldsAddOnKeys, setCustomFieldsAddOnKeys] = useState([] as any)
30
32
 
31
33
  const getFields = async () => {
32
34
  try {
33
- const eventId = getQueryVariable('event_id') || ''
35
+ const eventId = getQueryVariable('event_id') || getQueryVariable("eventId") || ''
34
36
  const customFields = await getCustomFields(eventId)
35
37
 
36
38
  const orderFieldsKeys = getFieldsKeys(_get(customFields, 'orderFields', []))
37
39
  const ticketHoldersFieldsKeys = getFieldsKeys(_get(customFields, 'ticketsFields', []))
40
+ const addOnFieldsKeys = getFieldsKeys(_get(customFields, 'addOnFields', []))
38
41
 
39
42
  setCustomFieldsTicketHolderKeys(ticketHoldersFieldsKeys)
40
43
  setCustomFieldsOrderKeys(orderFieldsKeys)
41
44
  setCustomFieldsData(customFields)
45
+ setCustomFieldsAddOnKeys(addOnFieldsKeys)
42
46
 
43
47
  onGetCustomFieldsSuccess(customFields)
44
48
  } catch (e) {
@@ -59,6 +63,8 @@ const withCustomFields = (Children: any) => (props: any) => {
59
63
  ticketHoldersWithCustomFields,
60
64
  } = getDataWithCustomFields(data, ticketHoldersFields, customFieldsData)
61
65
 
66
+ const { addOnDataWithCustomFields } = getAddOnDataWithCustomFields(customFieldsData)
67
+
62
68
  if (lodaing) {
63
69
  return <CircularProgress size={50} />
64
70
  }
@@ -70,6 +76,8 @@ const withCustomFields = (Children: any) => (props: any) => {
70
76
  ticketHoldersFields={ticketHoldersWithCustomFields}
71
77
  customFieldsOrderKeys={customFieldsOrderKeys}
72
78
  customFieldsTicketHolderKeys={customFieldsTicketHolderKeys}
79
+ customFieldsAddOnKeys={customFieldsAddOnKeys}
80
+ addOnDataWithCustomFields={addOnDataWithCustomFields}
73
81
  />
74
82
  )
75
83
  }
package/src/index.ts CHANGED
@@ -6,7 +6,7 @@ export { currencyNormalizerCreator, createFixedFloatNormalizer } from './normali
6
6
  export { LoginModal } from './components/loginModal'
7
7
  export { MyTicketsContainer } from './components/myTicketsContainer'
8
8
  export { OrderDetailsContainer } from './components/orderDetailsContainer'
9
- export { setConfigs } from './utils/setConfigs'
9
+ export { DEFAULT_FEES_STYLE } from './constants/index'
10
10
  export { TicketResaleContainer } from './components'
11
11
  export { RedirectModal } from './components/common/RedirectModal'
12
12
  export { RsvpContainer } from './components/rsvpContainer'
@@ -22,4 +22,9 @@ export { DelegationsContainer } from './components/delegationsContainer'
22
22
  export { PoweredBy } from './components/common/PoweredBy'
23
23
  export { SeatMapContainer } from './components/seatMapContainer'
24
24
  export { IDVerification } from './components/idVerificationContainer'
25
- export { VERIFICATION_STATUSES } from './components/idVerificationContainer/constants'
25
+ export { VERIFICATION_STATUSES } from './components/idVerificationContainer/constants'
26
+
27
+ export { setConfigs } from './utils/setConfigs'
28
+ export { logoutUser } from './utils/auth'
29
+
30
+ export { OrderDetails } from './components/paymentContainer/OrderDetails'
@@ -3,5 +3,6 @@ export interface IAddOn {
3
3
  name: string;
4
4
  groupName: string | null;
5
5
  price: string;
6
+ cost: string;
6
7
  quantity: string | number;
7
8
  }
@@ -21,12 +21,19 @@ interface ICartRequestData {
21
21
  attributes: ICartData;
22
22
  }
23
23
 
24
+ interface ICart {
25
+ id: string;
26
+ price: number;
27
+ quantity: number;
28
+ }
29
+
24
30
  interface ICartResponseData {
25
31
  ageRequired: boolean;
26
32
  namesRequired: boolean;
27
33
  phoneRequired: boolean;
28
34
  skipBillingPage: boolean;
29
35
  minimumAge?: string | null;
36
+ cart?: ICart[];
30
37
  }
31
38
 
32
39
  interface ICartResponseExtendedData extends ICartResponseData {
@@ -40,6 +47,7 @@ interface ICartResponse extends IAxiosResponseData {
40
47
  attributes: ICartResponseData;
41
48
  relationships: Array<unknown>;
42
49
  type: string;
50
+ cart: ICart[];
43
51
  };
44
52
  }
45
53
 
@@ -1,3 +1,5 @@
1
+ import { StripeElementsOptions } from '@stripe/stripe-js'
2
+
1
3
  interface ITicketHolderData {
2
4
  firstName?: string;
3
5
  lastName?: string;
@@ -23,13 +25,62 @@ interface ICheckoutData {
23
25
  }
24
26
 
25
27
  interface ICheckoutResponseData {
26
- id: string | number;
27
- hash: string | number;
28
- total: string | number;
29
- debt: string | number;
30
- pay_now: string | number;
31
- guest_count: number | null;
32
- status: string;
28
+ hash?: string;
29
+ total?: string;
30
+ cart_price_breakdown?: {
31
+ total: number;
32
+ debt: number;
33
+ guest_count: number;
34
+ guest_revenue: number;
35
+ currency: {
36
+ currency: string;
37
+ decimal_places: number;
38
+ symbol: string;
39
+ };
40
+ insurance_amount: number;
41
+ goods_tax: number;
42
+ goods_tax_name: string;
43
+ total_add_ons: number;
44
+ payment_option_additional_fees: number;
45
+ tickets_price_breakdown: [
46
+ {
47
+ fees_breakdown: Array<{
48
+ name: string;
49
+ amount: number;
50
+ }>;
51
+ is_table: boolean;
52
+ ticket_type_name: string;
53
+ ticket_type_id: string;
54
+ quantity: number;
55
+ fees_per_ticket: number;
56
+ discount: number;
57
+ description: string;
58
+ refund_on_checkin: boolean;
59
+ price_per_ticket: string;
60
+ cost_per_ticket: string;
61
+ total_price: number;
62
+ }
63
+ ];
64
+ add_ons_price_breakdown: [];
65
+ insurance_items_breakdown: [];
66
+ event_name: string;
67
+ };
68
+ additional_payment_information?: {
69
+ basic_config: {
70
+ apiKey: string;
71
+ accountId: string;
72
+ };
73
+ elements_config: StripeElementsOptions;
74
+ additional_config: {
75
+ decimalMultiplier: number;
76
+ canChangeCaptureMode: boolean;
77
+ };
78
+ stripe_wallets: {
79
+ applePay?: 'auto' | 'never';
80
+ googlePay?: 'auto' | 'never';
81
+ };
82
+ payment_plan_available: boolean;
83
+ };
33
84
  }
34
85
 
35
86
  interface ICheckoutResponse extends IAxiosResponseData {
@@ -14,7 +14,20 @@ interface IEventResponseData {
14
14
  startDate: string;
15
15
  timezone: string;
16
16
  country: any;
17
+ timeslotSettings: ITimeslotSettings | undefined | null;
18
+ preregEnabled: boolean;
19
+ preregStarted: boolean;
20
+ preregEnded: boolean;
17
21
  }
22
+
23
+ interface ITimeslotSettings {
24
+ minPricePerDate: any;
25
+ showPrice: boolean;
26
+ groupsInfo: any;
27
+ availableDates: string[];
28
+ timeSlotDateInfo: any;
29
+ }
30
+
18
31
  interface IEventResponse extends IAxiosResponseData {
19
32
  data: {
20
33
  attributes: IEventResponseData;
@@ -62,6 +75,11 @@ interface ITicketsResponseData {
62
75
  interface ITicketsAdaptedResponseData extends ITicketsResponseData {
63
76
  tickets: ITicketData[];
64
77
  }
78
+
79
+ interface ITimeslotsAdaptedData extends ITicketsResponseData {
80
+ timeslots: {[key: string]: { [key: string]: ITicketData[] }};
81
+ }
82
+
65
83
  interface ITicketsResponse extends IAxiosResponseData {
66
84
  data: {
67
85
  attributes: ITicketsResponseData;
@@ -77,6 +95,14 @@ interface ITicketsAdaptedResponse extends IAxiosResponseData {
77
95
  };
78
96
  }
79
97
 
98
+ interface ITimeslotsAdaptedResponse extends IAxiosResponseData {
99
+ data: {
100
+ attributes: ITimeslotsAdaptedData;
101
+ relationships: Array<unknown>;
102
+ type: string;
103
+ };
104
+ }
105
+
80
106
  // Countries
81
107
  interface ICountriesAdaptedData {
82
108
  label: string;
@@ -117,3 +143,7 @@ interface IRSVPRequestData {
117
143
  email: string;
118
144
  }
119
145
  type IRSVPResponse = IAxiosResponseData
146
+
147
+ interface TimeSlotsResponse extends IAxiosResponseData {
148
+ data: string[];
149
+ }
@@ -57,18 +57,34 @@ interface IOrderAddOn {
57
57
  interface IOrderTicketAddOn {
58
58
  status: string;
59
59
  name: string;
60
+ groupName: string;
60
61
  }
61
62
 
62
- interface IOrderTicketData {
63
+ interface ITicketTypes {
64
+ add_ons?: IOrderTicketAddOn[];
63
65
  hash: string;
66
+ ticket_type: string;
67
+ holder_name: string;
68
+ status: string;
69
+ pdf_link: string;
70
+ is_sellable: boolean;
71
+ is_on_sale?: boolean;
72
+ event_name: string;
73
+ currency: string;
74
+ ticket_type_hash: string;
75
+ ticket_type_is_active?: boolean;
76
+ canSellTicket?: boolean;
77
+ retain_amount_on_sale: number | string;
78
+ ticketsTitle: string;
79
+ }
80
+
81
+ interface IOrderTicketData extends ITicketTypes {
64
82
  qrData: string;
65
83
  ticketType: string;
66
84
  description: string | null;
67
85
  descriptionPlain: string | null;
68
86
  holderName: string;
69
- status: string;
70
87
  eventName: string;
71
- currency: string;
72
88
  resaleFeeAmount: number;
73
89
  holderEmail: string;
74
90
  holderPhone: string | null;
@@ -18,6 +18,7 @@ interface IPaymentOrderDetails {
18
18
  id: string;
19
19
  name: string;
20
20
  price: number | string;
21
+ cost: number | string;
21
22
  quantity: number | string;
22
23
  guest_count?: string | number;
23
24
  }>;
@@ -25,6 +26,8 @@ interface IPaymentOrderDetails {
25
26
  pay_now?: string | number;
26
27
  guest_count?: string | number;
27
28
  debt?: number;
29
+ subtotal?: number | string;
30
+ fees?: number | string;
28
31
  }
29
32
 
30
33
  interface IPaymentMethodData {
@@ -34,7 +37,8 @@ interface IPaymentMethodData {
34
37
  stripe_payment_plan_enabled: boolean;
35
38
  stripe_payment_plan_configuration: any;
36
39
  stripeConnectedAccount: string;
37
- stripePublishableKey: string;
40
+ stripe_publishable_key: string;
41
+ payment_method_types?: string[];
38
42
  }
39
43
 
40
44
  interface IShippingBillingInfoData {
@@ -171,4 +175,4 @@ interface ICheckoutCompleteDataResponse extends IAxiosResponseData {
171
175
  relationships: Array<unknown>;
172
176
  type: string;
173
177
  };
174
- }
178
+ }
@@ -1,4 +1,4 @@
1
- interface IInfluancerData {
1
+ interface IInfluencerData {
2
2
  customer_id: string;
3
3
  data_capture: any;
4
4
  email: string;
@@ -25,7 +25,7 @@ interface IPrizeData {
25
25
 
26
26
  interface IInfluancersData {
27
27
  attributes: {
28
- influencers: IInfluancerData[];
28
+ influencers: IInfluencerData[];
29
29
  prizes: IPrizeData[];
30
30
  };
31
31
  relationships: Array<unknown>;
@@ -2,7 +2,7 @@ export interface ICheckoutPageConfigs {
2
2
  age_required: boolean;
3
3
  event_id: string;
4
4
  has_add_on: boolean;
5
- minimum_age: number | string | null;
5
+ minimum_age?: number | string | null;
6
6
  names_required: boolean;
7
7
  phone_required: boolean;
8
8
  skip_billing_page: boolean;
@@ -3,7 +3,7 @@ import { IAddOn } from './add_on'
3
3
  export interface IOrderData {
4
4
  id: string;
5
5
  product_name: string;
6
- ticketType: string;
6
+ ticketType: string | Array<any>;
7
7
  quantity: string | number;
8
8
  price: string | number;
9
9
  total: string | number;
@@ -11,4 +11,6 @@ export interface IOrderData {
11
11
  guest_count: string | number;
12
12
  pay_now: string | number;
13
13
  add_ons: IAddOn[];
14
+ cost: string | number;
15
+ expires_at?: number;
14
16
  }
@@ -5,7 +5,7 @@ interface IPrewardsProps {
5
5
  }
6
6
 
7
7
  interface IInfluancersProps {
8
- data: Array<IInfluancerData>;
8
+ data: Array<IInfluencerData>;
9
9
  classNamePrefix: string;
10
10
  headerNode?: string | Node;
11
11
  }
@@ -28,6 +28,11 @@ interface IPreRegistrationInformationProps {
28
28
  onGetPreregistrationDataError?: () => void;
29
29
  influancersHeaderNode?: string | Node;
30
30
  prewardsHeaderNode?: string | Node;
31
+
32
+ themeOptions?: ThemeOptions & {
33
+ input?: CSSProperties;
34
+ checkbox?: CSSProperties;
35
+ };
31
36
  }
32
37
 
33
38
  interface IPreRegistrationCompleteProps extends IShareOptionsProps {
package/src/utils/auth.ts CHANGED
@@ -1,3 +1,9 @@
1
+ import { AxiosError } from 'axios'
2
+
3
+ import { logout } from '../api'
4
+ import { deleteCookieByName } from './cookies'
5
+ import { isBrowser } from './isBrowser'
6
+
1
7
  export const setLoggedUserData = (data: IProfileData) => ({
2
8
  id: data.id,
3
9
  first_name: data.firstName,
@@ -11,3 +17,29 @@ export const setLoggedUserData = (data: IProfileData) => ({
11
17
  state: data?.stateId || '',
12
18
  zip: data?.zipCode || '',
13
19
  })
20
+
21
+ interface LogoutUserParams {
22
+ onLogoutSuccess?: () => void;
23
+ onLogoutError?: (error: AxiosError) => void;
24
+ setIsLogged?: (isLogged: boolean) => void;
25
+ }
26
+
27
+ export const logoutUser = async ({
28
+ onLogoutSuccess,
29
+ onLogoutError,
30
+ setIsLogged,
31
+ }: LogoutUserParams) => {
32
+ try {
33
+ await logout()
34
+ onLogoutSuccess && onLogoutSuccess()
35
+ if (isBrowser) {
36
+ window.localStorage.removeItem('user_data')
37
+ setIsLogged && setIsLogged(false)
38
+ const event = new window.CustomEvent('tf-logout')
39
+ deleteCookieByName('X-TF-ECOMMERCE')
40
+ window.document.dispatchEvent(event)
41
+ }
42
+ } catch (e) {
43
+ onLogoutError && onLogoutError(e as AxiosError)
44
+ }
45
+ }
@@ -1,5 +1,7 @@
1
1
  import { getDomain } from './getDomain'
2
2
 
3
+ let generalDomain: string
4
+
3
5
  export function setCustomCookie(name: string, value: string, days = 5) {
4
6
  let expires = ''
5
7
  if (days) {
@@ -7,11 +9,25 @@ export function setCustomCookie(name: string, value: string, days = 5) {
7
9
  date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000)
8
10
  expires = '; expires=' + date.toUTCString()
9
11
  }
10
- if (typeof window !== 'undefined') {
11
- const domain = getDomain(window.location.hostname)
12
- document.cookie =
13
- name + '=' + (value || '') + expires + `; path=/; domain=${domain}`
12
+ if (typeof window === 'undefined') {
13
+ return
14
+ }
15
+
16
+ const { hostname } = window.location
17
+
18
+ if (generalDomain && generalDomain.endsWith(getDomain(hostname))) {
19
+ document.cookie = name + '=' + (value || '') + expires + `; path=/;domain=${generalDomain}`
20
+ return
14
21
  }
22
+
23
+ let previousDomain = undefined
24
+ let domain = undefined
25
+ do {
26
+ previousDomain = domain
27
+ domain = getDomain(hostname, undefined, previousDomain)
28
+ document.cookie = name + '=' + (value || '') + expires + `; path=/;domain=${domain}`
29
+ } while (getCookieByName(name) === '' && hostname !== domain)
30
+ generalDomain = domain
15
31
  }
16
32
 
17
33
  export function getCookieByName(cname: string) {
@@ -31,12 +47,27 @@ export function getCookieByName(cname: string) {
31
47
  }
32
48
 
33
49
  export function deleteCookieByName(name: string) {
34
- if (typeof window !== 'undefined') {
35
- const domain = getDomain(window.location.hostname)
36
- document.cookie =
37
- name +
38
- '=; Path=/' +
39
- `; domain=${domain}` +
40
- '; Expires=Thu, 01 Jan 1970 00:00:01 GMT;'
50
+ if (getCookieByName(name) === '') {
51
+ return
41
52
  }
53
+
54
+ if (typeof window === 'undefined') {
55
+ return
56
+ }
57
+
58
+ const { hostname } = window.location
59
+
60
+ if (generalDomain && generalDomain.endsWith(getDomain(hostname))) {
61
+ document.cookie = name + `=; Path=/;domain=${generalDomain}; Expires=Thu, 01 Jan 1970 00:00:01 GMT;`
62
+ return
63
+ }
64
+
65
+ let previousDomain = undefined
66
+ let domain = undefined
67
+ do {
68
+ previousDomain = domain
69
+ domain = getDomain(hostname, undefined, previousDomain)
70
+ document.cookie = name + `=; Path=/;domain=${domain}; Expires=Thu, 01 Jan 1970 00:00:01 GMT;`
71
+ } while (getCookieByName(name) !== '' && hostname !== domain)
72
+ generalDomain = domain
42
73
  }
@@ -24,6 +24,7 @@ interface IUserCredentialsValues {
24
24
  emailLogged?: string;
25
25
  firstNameLogged?: string;
26
26
  lastNameLogged?: string;
27
+ phoneLogged?: string;
27
28
  }
28
29
 
29
30
  export const createCheckoutDataBodyWithDefaultHolder = (
@@ -45,7 +46,8 @@ export const createCheckoutDataBodyWithDefaultHolder = (
45
46
  _get(logedInValues, 'last_name') ||
46
47
  _get(userCredentials, 'lastNameLogged') ||
47
48
  ''
48
- const phone = _get(logedInValues, 'phone', '')
49
+ const phone =
50
+ _get(logedInValues, 'phone') || _get(userCredentials, 'phoneLogged') || ''
49
51
  const email =
50
52
  _get(logedInValues, 'email') || _get(userCredentials, 'emailLogged') || ''
51
53
 
@@ -54,5 +54,27 @@ export const getDataWithCustomFields = (
54
54
  return { dataWithCustomFields, ticketHoldersWithCustomFields }
55
55
  }
56
56
 
57
+ export const getAddOnDataWithCustomFields = (customFields: any) => {
58
+ // Custom Fields are not specified case
59
+ if (_isEmpty(customFields)) {
60
+ return { addOnDataWithCustomFields: [] }
61
+ }
62
+
63
+ // Add Custom Fields for Order
64
+ const orderWithCustomFields = [
65
+ {
66
+ id: 1,
67
+ groupClassname: 'billing-info-container__customFields',
68
+ groupItems: [...customFields.addOnFields],
69
+ },
70
+ ]
71
+
72
+ const addOnDataWithCustomFields = {
73
+ fields: orderWithCustomFields,
74
+ }
75
+
76
+ return { addOnDataWithCustomFields }
77
+ }
78
+
57
79
  export const getFieldsKeys = (customFields: any) =>
58
80
  _map(customFields, field => field.name)
@@ -1,10 +1,16 @@
1
- export function getDomain(url: string, subdomain?: string): string {
1
+ export function getDomain(url: string, subdomain?: string, publicSuffix?: string): string {
2
2
  let updatedUrl: any = url.replace(/(https?:\/\/)?(www.)?/i, '')
3
3
 
4
4
  if (!subdomain) {
5
- updatedUrl = updatedUrl.split('.')
6
-
7
- updatedUrl = updatedUrl.slice(updatedUrl.length - 2).join('.')
5
+ if (publicSuffix) {
6
+ const updatedPublicSuffix = publicSuffix.startsWith('.') ? publicSuffix : '.' + publicSuffix
7
+ updatedUrl = url.replace(updatedPublicSuffix, '').split('.')
8
+ updatedUrl = updatedUrl.length > 0 ? updatedUrl[updatedUrl.length - 1] : ''
9
+ updatedUrl += updatedPublicSuffix
10
+ } else {
11
+ updatedUrl = updatedUrl.split(".")
12
+ updatedUrl = updatedUrl.slice(updatedUrl.length - 2).join(".")
13
+ }
8
14
  }
9
15
 
10
16
  if (updatedUrl.indexOf('/') !== -1) {
@@ -9,7 +9,7 @@ export { createMarkup } from './createMarkup'
9
9
  export { replaceVarInString } from './replaceVarInString'
10
10
  export { isBrowser } from './isBrowser'
11
11
  export { getFormInitialValues } from './form'
12
- export { setLoggedUserData } from './auth'
12
+ export { setLoggedUserData, logoutUser } from './auth'
13
13
  export { getDataWithCustomFields, getFieldsKeys } from './customFields'
14
14
  export { createElementFromHTML } from './htmlNodeFromString'
15
15
  export { isJson } from './jsonUtils'