tf-checkout-react 1.6.6-beta.33 → 1.6.6-beta.34

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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.6.6-beta.33",
2
+ "version": "1.6.6-beta.34",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -387,6 +387,7 @@ const BillingInfoContainer = React.memo(
387
387
  const hideInstagramField = !collectMandatoryInstagram && !collectOptionalInstagram
388
388
  const collectMandatoryBusinessCategory = configs?.collect_mandatory_business_category
389
389
  const collectOptionalBusinessCategory = configs?.collect_optional_business_category
390
+ const eventHasAddons = configs?.has_add_on
390
391
  const hideBusinessCategoryField =
391
392
  !collectMandatoryBusinessCategory && !collectOptionalBusinessCategory
392
393
 
@@ -674,6 +675,10 @@ const BillingInfoContainer = React.memo(
674
675
  localStorage.removeItem('checkoutAdditionalConfigs')
675
676
  }, [])
676
677
 
678
+ useEffect(() => {
679
+ onCheckoutUpdateSuccess({ expires_at: expirationTime, ...checkoutData })
680
+ }, [checkoutData, cartInfoData])
681
+
677
682
  const updateCheckoutWithAddOns = useCallback(
678
683
  async (addOns: { [key: string]: number } = {}) => {
679
684
  if (!isSinglePageCheckout) return
@@ -708,7 +713,6 @@ const BillingInfoContainer = React.memo(
708
713
  {}
709
714
  )
710
715
  setCheckoutData(checkoutDataObj)
711
- onCheckoutUpdateSuccess(checkoutResponse.data.attributes)
712
716
  setSingleCheckoutAddOns(mergedAddOns)
713
717
  }
714
718
  } catch (error) {
@@ -1160,7 +1164,7 @@ const BillingInfoContainer = React.memo(
1160
1164
  </div>
1161
1165
  </div>
1162
1166
  )}
1163
- {isSinglePageCheckout && !addOnsIncludedOnInvitation && eventId ? (
1167
+ {isSinglePageCheckout && !addOnsIncludedOnInvitation && eventHasAddons && eventId ? (
1164
1168
  <SimpleAddonsContainer
1165
1169
  {...(addonsProps ?? {})}
1166
1170
  eventId={eventId}
@@ -1168,7 +1172,7 @@ const BillingInfoContainer = React.memo(
1168
1172
  configs={configs}
1169
1173
  onAddOnSelect={onAddOnSelect}
1170
1174
  />
1171
- ) : !addOnsIncludedOnInvitation && includeAddons ? (
1175
+ ) : !addOnsIncludedOnInvitation && includeAddons && !isSinglePageCheckout ? (
1172
1176
  <AddonsContainter
1173
1177
  {...(addonsProps ?? {})}
1174
1178
  addOnDataWithCustomFields={addOnDataWithCustomFields}
@@ -2,23 +2,66 @@
2
2
  import _identity from 'lodash/identity'
3
3
  import _isEmpty from 'lodash/isEmpty'
4
4
  import _map from 'lodash/map'
5
- import React, { useState } from 'react'
5
+ import React, { memo, useState } from 'react'
6
6
 
7
7
  import { FEES_STYLES } from '../../constants'
8
8
  import { createFixedFloatNormalizer, currencyNormalizerCreator } from '../../normalizers'
9
9
  import { IOrderData } from '../../types'
10
10
  import { CONFIGS } from '../../utils'
11
+ import Countdown from 'react-countdown'
12
+ import { showZero } from '../../utils/showZero'
13
+ import { IRenderer } from '../timerWidget'
11
14
 
12
15
  interface OrderDetailsProps {
13
16
  orderData: any;
14
17
  paymentFieldsData: any[];
15
18
  customMobileText?: string;
19
+ handleCountdownFinish?: () => void;
16
20
  }
17
21
 
22
+ interface CountdownI {
23
+ expiresAt: number;
24
+ handleCountdownFinish: () => void;
25
+ }
26
+
27
+ const SimpleCountdown = memo(({ expiresAt, handleCountdownFinish }: CountdownI) => {
28
+ const renderer = ({
29
+ minutes,
30
+ seconds,
31
+ completed,
32
+ handleCountdownFinish,
33
+ }: IRenderer) => {
34
+ if (completed) {
35
+ handleCountdownFinish()
36
+ return null
37
+ }
38
+ return (
39
+ <span>
40
+ {showZero(minutes)}:{showZero(seconds)}
41
+ </span>
42
+ )
43
+ }
44
+
45
+ return (<div className="mobile-order-timer">
46
+ {expiresAt && (
47
+ <Countdown
48
+ date={Date.now() + expiresAt * 1000}
49
+ renderer={(props: any) =>
50
+ renderer({
51
+ ...props,
52
+ handleCountdownFinish,
53
+ })
54
+ }
55
+ />
56
+ )}
57
+ </div>)
58
+ })
59
+
18
60
  export const OrderDetails = ({
19
61
  orderData = {},
20
62
  paymentFieldsData = [],
21
63
  customMobileText = 'Your order total',
64
+ handleCountdownFinish = _identity
22
65
  }: OrderDetailsProps) => {
23
66
  const { currency, guest_count } = orderData
24
67
  const hasTableTypes = Boolean(Number(guest_count))
@@ -37,6 +80,78 @@ export const OrderDetails = ({
37
80
  setIsExpanded(!isExpanded)
38
81
  }
39
82
 
83
+ const defaultItemRenderer = (item: any) => {
84
+ return (<div>
85
+ <div key={item.id} className="add-on-container">
86
+ <span>{item.quantity}</span>
87
+ <span className="add-on-x">{' x '}</span>
88
+ <span>{item.groupName ? item.groupName + ' - ' : ''}</span>
89
+ <span>{item.name}</span>
90
+ <span>{' - '}</span>
91
+ <span>
92
+ {CONFIGS.FEES_STYLE === FEES_STYLES.TRADITIONAL &&
93
+ currencyNormalizerCreator(
94
+ createFixedFloatNormalizer(2)(parseFloat(item.price)),
95
+ currency,
96
+ ) + ' (incl. fees)'}
97
+ {CONFIGS.FEES_STYLE === FEES_STYLES.DISPLAY_BOTH &&
98
+ currencyNormalizerCreator(
99
+ createFixedFloatNormalizer(2)(parseFloat(item.cost)),
100
+ currency,
101
+ )}
102
+ </span>
103
+ <span className="add-on-each">{' each'}</span>
104
+ </div>
105
+ {CONFIGS.FEES_STYLE === FEES_STYLES.DISPLAY_BOTH && (
106
+ <p className="fees">
107
+ {`(${currencyNormalizerCreator(
108
+ createFixedFloatNormalizer(2)(
109
+ parseFloat(String(item.price)),
110
+ ),
111
+ currency,
112
+ )} with fees)`}
113
+ </p>
114
+ )}
115
+ </div>)
116
+ }
117
+
118
+ const defaultTableRenderer = (item: any) => {
119
+ return (<div>
120
+ <div key={item.id} className="table-type-container">
121
+ <span>{item.groupName ? item.groupName + ' - ' : ''}</span>
122
+ <span>{item.name}</span>
123
+ <span>{' - '}</span>
124
+ <span>Guest Count{': '}</span>
125
+ <span>{item.guestCount}</span>
126
+ </div>
127
+ <div>
128
+ <span>
129
+ {CONFIGS.FEES_STYLE === FEES_STYLES.TRADITIONAL &&
130
+ currencyNormalizerCreator(
131
+ createFixedFloatNormalizer(2)(parseFloat(item.price)),
132
+ currency,
133
+ ) + ' (incl. fees)'}
134
+ {CONFIGS.FEES_STYLE === FEES_STYLES.DISPLAY_BOTH &&
135
+ currencyNormalizerCreator(
136
+ createFixedFloatNormalizer(2)(parseFloat(item.cost)),
137
+ currency,
138
+ )}
139
+ </span>
140
+ <br/>
141
+ {CONFIGS.FEES_STYLE === FEES_STYLES.DISPLAY_BOTH && (
142
+ <p className="fees">
143
+ {`(${currencyNormalizerCreator(
144
+ createFixedFloatNormalizer(2)(
145
+ parseFloat(String(item.price)),
146
+ ),
147
+ currency,
148
+ )} with fees)`}
149
+ </p>
150
+ )}
151
+ </div>
152
+ </div>)
153
+ }
154
+
40
155
  return (
41
156
  <div className="payment_page payment_page_single">
42
157
  {/* Mobile view summary */}
@@ -50,11 +165,14 @@ export const OrderDetails = ({
50
165
  >
51
166
  <div className="mobile-order-text">{customMobileText}</div>
52
167
  </div>
53
- {!isExpanded && (
54
- <div className="mobile-order-info-container order-info-container-right">
168
+ <div className="mobile-order-info-container order-info-container-right">
169
+ {!isExpanded && (
55
170
  <div className="mobile-order-total">{totalValue}</div>
56
- </div>
57
- )}
171
+ )}
172
+ {orderData?.expires_at && (
173
+ <SimpleCountdown expiresAt={orderData?.expires_at} handleCountdownFinish={handleCountdownFinish} />
174
+ )}
175
+ </div>
58
176
  </div>
59
177
  </div>
60
178
  </div>
@@ -126,39 +244,8 @@ export const OrderDetails = ({
126
244
  {typeof value === 'string' || typeof value === 'number'
127
245
  ? normalizer(value, currency, orderData)
128
246
  : _map(value, item => (
129
- <div>
130
- <div key={item.id} className="add-on-container">
131
- <span>{item.quantity}</span>
132
- <span className="add-on-x">{' x '}</span>
133
- <span>{item.groupName ? item.groupName + ' - ' : ''}</span>
134
- <span>{item.name}</span>
135
- <span>{' - '}</span>
136
- <span>
137
- {CONFIGS.FEES_STYLE === FEES_STYLES.TRADITIONAL &&
138
- currencyNormalizerCreator(
139
- createFixedFloatNormalizer(2)(parseFloat(item.price)),
140
- currency
141
- ) + ' (incl. fees)'}
142
- {CONFIGS.FEES_STYLE === FEES_STYLES.DISPLAY_BOTH &&
143
- currencyNormalizerCreator(
144
- createFixedFloatNormalizer(2)(parseFloat(item.cost)),
145
- currency
146
- )}
147
- </span>
148
- <span className="add-on-each">{' each'}</span>
149
- </div>
150
- {CONFIGS.FEES_STYLE === FEES_STYLES.DISPLAY_BOTH && (
151
- <p className="fees">
152
- {`(${currencyNormalizerCreator(
153
- createFixedFloatNormalizer(2)(
154
- parseFloat(String(item.price))
155
- ),
156
- currency
157
- )} with fees)`}
158
- </p>
159
- )}
160
- </div>
161
- ))}
247
+ item.isTable ? defaultTableRenderer(item) : defaultItemRenderer(item)
248
+ ))}
162
249
  </div>
163
250
  </div>
164
251
  )
package/src/env.ts CHANGED
@@ -1,13 +1,21 @@
1
1
  // preview
2
2
  export const ENV = {
3
- EVENT_ID: 13119,
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