tf-checkout-react 1.0.78 → 1.0.79

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.0.78",
2
+ "version": "1.0.79",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -47,7 +47,7 @@ import { SelectField } from '../common/SelectField'
47
47
  import { ErrorFocus } from '../../utils/formikErrorFocus'
48
48
  import { FormikPhoneNumberField } from '../common/FormikPhoneNumberField'
49
49
  import { ThemeProvider, createTheme } from '@mui/material/styles'
50
- import { CSSProperties } from '@mui/styled-engine'
50
+ import { CSSProperties } from '@mui/styles'
51
51
 
52
52
  export interface IBillingInfoPage {
53
53
  data?: IBillingInfoData[];
@@ -4,6 +4,7 @@ import FormControlLabel from '@mui/material/FormControlLabel'
4
4
  import Checkbox from '@mui/material/Checkbox'
5
5
  import { FieldInputProps } from 'formik'
6
6
  import { useTheme } from '@mui/styles'
7
+ import { FormControl, FormHelperText } from '@mui/material'
7
8
 
8
9
  export interface ICheckboxField {
9
10
  label: string | number | JSX.Element;
@@ -24,14 +25,17 @@ export const CheckboxField = ({
24
25
  }: ICheckboxField & IOtherProps) => {
25
26
  const customTheme: any = useTheme()
26
27
  return (
27
- <FormGroup>
28
- <FormControlLabel
29
- control={<Checkbox {...field} {...rest} />}
30
- label={label}
31
- componentsProps={{
32
- typography: customTheme?.checkbox
33
- }}
34
- />
35
- </FormGroup>
28
+ <FormControl error={!!(rest?.form?.errors && rest.form.errors[field?.name ?? ""])}>
29
+ <FormGroup>
30
+ <FormControlLabel
31
+ control={<Checkbox {...field} {...rest} />}
32
+ label={label}
33
+ componentsProps={{
34
+ typography: customTheme?.checkbox
35
+ }}
36
+ />
37
+ </FormGroup>
38
+ {!!(rest?.form?.errors && rest.form.errors[field?.name ?? ""]) ? <FormHelperText>Required</FormHelperText> : null}
39
+ </FormControl>
36
40
  )
37
41
  }
@@ -1,10 +1,10 @@
1
- import React, { CSSProperties, useEffect, useState } from 'react'
1
+ import React, { useEffect, useState } from 'react'
2
2
  import { AxiosError } from 'axios'
3
3
  import Container from '@mui/material/Container'
4
4
  import CircularProgress from '@mui/material/CircularProgress'
5
5
  import Alert from '@mui/material/Alert'
6
6
  import { Elements } from '@stripe/react-stripe-js'
7
- import { loadStripe, StripeConstructorOptions } from '@stripe/stripe-js'
7
+ import { loadStripe, StripeConstructorOptions, StripeElementsOptions } from '@stripe/stripe-js'
8
8
  import _map from 'lodash/map'
9
9
  import _get from 'lodash/get'
10
10
  import _identity from 'lodash/identity'
@@ -20,6 +20,7 @@ import { getPaymentData, handlePaymentSuccess, getConditions } from '../../api'
20
20
  import { StripeCardNumberElementOptions } from '@stripe/stripe-js'
21
21
  import { ThemeProvider, createTheme } from '@mui/material/styles'
22
22
  import { ThemeOptions } from '@mui/material'
23
+ import { CSSProperties } from "@mui/styles"
23
24
 
24
25
  const publishableKey = CONFIGS.STRIPE_PUBLISHABLE_KEY || ''
25
26
 
@@ -61,6 +62,7 @@ export interface IPaymentPage {
61
62
  stripeCardOptions?: StripeCardNumberElementOptions;
62
63
  disableZipSection: boolean;
63
64
  themeOptions?: ThemeOptions & { input?: CSSProperties; checkbox?: CSSProperties };
65
+ elementsOptions?: StripeElementsOptions;
64
66
  }
65
67
 
66
68
  const initialOrderValues: IOrderData = {
@@ -94,6 +96,7 @@ export const PaymentContainer = ({
94
96
  stripeCardOptions = {},
95
97
  disableZipSection = false,
96
98
  themeOptions,
99
+ elementsOptions
97
100
  }: IPaymentPage) => {
98
101
  const [reviewData, setReviewData] = useState(initialReviewValues)
99
102
  const [orderData, setOrderData] = useState(initialOrderValues)
@@ -226,7 +229,7 @@ export const PaymentContainer = ({
226
229
  <p className="payment_info__error">{errorText}</p>
227
230
  )}
228
231
  <div>
229
- <Elements stripe={getStripePromise(reviewData)}>
232
+ <Elements stripe={getStripePromise(reviewData)} options={elementsOptions}>
230
233
  <StripePayment
231
234
  stripe_client_secret={_get(
232
235
  reviewData,
@@ -191,7 +191,7 @@ const CheckoutForm = ({
191
191
  <label className="card_number_element">
192
192
  <span className="card_label_text">Card number</span>
193
193
  <CardNumberElement
194
- options={{ ...options.style, ...stripeCardOptions }}
194
+ options={{ ...options, ...stripeCardOptions, }}
195
195
  onReady={_identity}
196
196
  onChange={_identity}
197
197
  onBlur={_identity}
@@ -200,11 +200,11 @@ const CheckoutForm = ({
200
200
  </label>
201
201
  <label className="expiration_element">
202
202
  <span className="card_label_text">Expiration date</span>
203
- <CardExpiryElement options={{ ...options.style, ...stripeCardOptions }} />
203
+ <CardExpiryElement options={{ ...options, ...stripeCardOptions }} />
204
204
  </label>
205
205
  <label className="cvc_element">
206
206
  <span className="card_label_text">CVC</span>
207
- <CardCvcElement options={{ ...options.style, ...stripeCardOptions }} />
207
+ <CardCvcElement options={{ ...options, ...stripeCardOptions }} />
208
208
  </label>
209
209
  {!disableZipSection && (
210
210
  <label className="zip_element">
@@ -22,6 +22,9 @@ import { PromoCodeSection } from './PromoCodeSection'
22
22
  import { LoginModal } from '../loginModal'
23
23
  import Countdown from '../countdown'
24
24
  import { createCheckoutDataBodyWithDefaultHolder } from '../../utils'
25
+ import { ThemeProvider } from '@mui/private-theming'
26
+ import { createTheme, ThemeOptions } from '@mui/material'
27
+ import { CSSProperties } from '@mui/styles'
25
28
 
26
29
  function Loader() {
27
30
  return (
@@ -52,6 +55,7 @@ export interface IGetTickets {
52
55
  theme?: 'light' | 'dark';
53
56
  queryPromoCode?: string;
54
57
  isPromotionsEnabled?: boolean;
58
+ themeOptions?: ThemeOptions & { input?: CSSProperties; checkbox?: CSSProperties }
55
59
  }
56
60
 
57
61
  export interface ITicket {
@@ -75,6 +79,7 @@ export const TicketsContainer = ({
75
79
  theme = 'light',
76
80
  queryPromoCode = '',
77
81
  isPromotionsEnabled = true,
82
+ themeOptions,
78
83
  }: IGetTickets) => {
79
84
  const [selectedTickets, setSelectedTickets] = useState(
80
85
  {} as ISelectedTickets
@@ -274,6 +279,8 @@ export const TicketsContainer = ({
274
279
  item => !(item.sold_out || item.soldOut)
275
280
  )
276
281
 
282
+ const themeMui = createTheme(themeOptions)
283
+
277
284
  useEffect(() => {
278
285
  isWindowDefined &&
279
286
  window.document.addEventListener('custom-logout', handleLogout)
@@ -296,91 +303,93 @@ export const TicketsContainer = ({
296
303
  }, [])
297
304
 
298
305
  return (
299
- <div className={`get-tickets-page ${theme}`} style={contentStyle}>
300
- {isLoading ? (
301
- <Loader />
302
- ) : (
303
- <div>
304
- <TicketsSection
305
- ticketsList={tickets}
306
- selectedTickets={selectedTickets}
307
- handleTicketSelect={handleTicketSelect}
308
- promoCodeIsApplied={promoCodeIsApplied}
309
- />
310
- {event?.salesEnded ? (
311
- <p>Sales for this event are closed.</p>
312
- ) : event?.salesStart ? (
313
- <Countdown
314
- startDate={event.salesStart}
315
- timezone={event.timezone}
316
- title="Sales start in:"
317
- message="No tickets are currently available for this event."
318
- callback={updateTickets}
306
+ <ThemeProvider theme={themeMui}>
307
+ <div className={`get-tickets-page ${theme}`} style={contentStyle}>
308
+ {isLoading ? (
309
+ <Loader />
310
+ ) : (
311
+ <div>
312
+ <TicketsSection
313
+ ticketsList={tickets}
314
+ selectedTickets={selectedTickets}
315
+ handleTicketSelect={handleTicketSelect}
316
+ promoCodeIsApplied={promoCodeIsApplied}
319
317
  />
320
- ) : null}
321
- {showWaitingList && (
322
- <WaitingList tickets={tickets} eventId={eventId} />
323
- )}
324
- <PromoCodeSection
325
- promoCode={promoCode}
326
- promoCodeIsApplied={promoCodeIsApplied}
327
- showPromoInput={showPromoInput}
328
- setPromoCode={setPromoCode}
329
- setPromoCodeUpdated={setPromoCodeUpdated}
330
- setShowPromoInput={setShowPromoInput}
331
- isPromotionsEnabled={isPromotionsEnabled}
332
- isAllTicketsSoldOut={isAllTicketsSoldOut}
333
- />
334
- {!isAllTicketsSoldOut && (
335
- <Button
336
- aria-hidden={true}
337
- className={`book-button ${
338
- handleBookIsLoading ||
339
- _isEmpty(selectedTickets) ||
340
- Object.values(selectedTickets)[0] === 0
341
- ? 'disabled'
342
- : ''
343
- }`}
344
- onClick={
345
- !handleBookIsLoading &&
346
- !_isEmpty(selectedTickets) &&
347
- Object.values(selectedTickets)[0] > 0
348
- ? handleBook
349
- : () => {}
350
- }
351
- >
352
- {getTicketsLabel || 'GET TICKETS'}
353
- </Button>
354
- )}
355
- {isLogged ? (
356
- <div className="session-wrapper">
357
- <span className="session-container">
358
- <Button
359
- variant="outline-light"
360
- className="session-buttons"
361
- onClick={handleOrdersClick}
362
- >
363
- My Orders
364
- </Button>
365
- </span>
366
- <span className="session-container">
367
- <Button
368
- variant="outline-light"
369
- className="session-buttons"
370
- onClick={handleLogout}
371
- >
372
- Log out
373
- </Button>
374
- </span>
375
- </div>
376
- ) : (
377
- ''
378
- )}
379
- </div>
380
- )}
381
- {showLoginModal ? (
382
- <LoginModal onClose={handleOnClose} onLogin={handleOnLogin} />
383
- ) : null}
384
- </div>
318
+ {event?.salesEnded ? (
319
+ <p>Sales for this event are closed.</p>
320
+ ) : event?.salesStart ? (
321
+ <Countdown
322
+ startDate={event.salesStart}
323
+ timezone={event.timezone}
324
+ title="Sales start in:"
325
+ message="No tickets are currently available for this event."
326
+ callback={updateTickets}
327
+ />
328
+ ) : null}
329
+ {showWaitingList && event.salesStarted && (
330
+ <WaitingList tickets={tickets} eventId={eventId} />
331
+ )}
332
+ <PromoCodeSection
333
+ promoCode={promoCode}
334
+ promoCodeIsApplied={promoCodeIsApplied}
335
+ showPromoInput={showPromoInput}
336
+ setPromoCode={setPromoCode}
337
+ setPromoCodeUpdated={setPromoCodeUpdated}
338
+ setShowPromoInput={setShowPromoInput}
339
+ isPromotionsEnabled={isPromotionsEnabled}
340
+ isAllTicketsSoldOut={isAllTicketsSoldOut}
341
+ />
342
+ {!isAllTicketsSoldOut && (
343
+ <Button
344
+ aria-hidden={true}
345
+ className={`book-button ${
346
+ handleBookIsLoading ||
347
+ _isEmpty(selectedTickets) ||
348
+ Object.values(selectedTickets)[0] === 0
349
+ ? 'disabled'
350
+ : ''
351
+ }`}
352
+ onClick={
353
+ !handleBookIsLoading &&
354
+ !_isEmpty(selectedTickets) &&
355
+ Object.values(selectedTickets)[0] > 0
356
+ ? handleBook
357
+ : () => {}
358
+ }
359
+ >
360
+ {getTicketsLabel || 'GET TICKETS'}
361
+ </Button>
362
+ )}
363
+ {isLogged ? (
364
+ <div className="session-wrapper">
365
+ <span className="session-container">
366
+ <Button
367
+ variant="outline-light"
368
+ className="session-buttons"
369
+ onClick={handleOrdersClick}
370
+ >
371
+ My Orders
372
+ </Button>
373
+ </span>
374
+ <span className="session-container">
375
+ <Button
376
+ variant="outline-light"
377
+ className="session-buttons"
378
+ onClick={handleLogout}
379
+ >
380
+ Log out
381
+ </Button>
382
+ </span>
383
+ </div>
384
+ ) : (
385
+ ''
386
+ )}
387
+ </div>
388
+ )}
389
+ {showLoginModal ? (
390
+ <LoginModal onClose={handleOnClose} onLogin={handleOnLogin} />
391
+ ) : null}
392
+ </div>
393
+ </ThemeProvider>
385
394
  )
386
395
  }