tf-checkout-react 1.0.99 → 1.0.100-beta.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.
- package/README.md +278 -1
- package/dist/api/index.d.ts +31 -26
- package/dist/components/account-settings/index.d.ts +3 -0
- package/dist/components/billing-info-container/index.d.ts +5 -5
- package/dist/components/billing-info-container/utils.d.ts +1 -0
- package/dist/components/common/CustomField.d.ts +1 -1
- package/dist/components/common/DatePickerField.d.ts +14 -0
- package/dist/components/common/RedirectModal.d.ts +7 -0
- package/dist/components/common/SnackbarAlert.d.ts +13 -0
- package/dist/components/confirmationContainer/index.d.ts +2 -1
- package/dist/components/countdown/index.d.ts +4 -1
- package/dist/components/myTicketsContainer/tableConfig.d.ts +0 -1
- package/dist/components/orderDetailsContainer/index.d.ts +5 -1
- package/dist/components/orderDetailsContainer/ticketsTable.d.ts +4 -1
- package/dist/components/paymentContainer/index.d.ts +3 -1
- package/dist/components/rsvpContainer/index.d.ts +7 -0
- package/dist/components/stripePayment/index.d.ts +2 -1
- package/dist/components/ticketResale/index.d.ts +5 -3
- package/dist/components/ticketsContainer/AccessCodeSection.d.ts +7 -0
- package/dist/components/ticketsContainer/PromoCodeSection.d.ts +6 -9
- package/dist/components/ticketsContainer/TicketsSection.d.ts +5 -3
- package/dist/components/ticketsContainer/index.d.ts +13 -2
- package/dist/components/timerWidget/index.d.ts +3 -3
- package/dist/env.d.ts +1 -0
- package/dist/images/cross.svg +44 -0
- package/dist/images/done.svg +3 -3
- package/dist/index.d.ts +2 -0
- package/dist/tf-checkout-react.cjs.development.js +1400 -575
- package/dist/tf-checkout-react.cjs.development.js.map +1 -1
- package/dist/tf-checkout-react.cjs.production.min.js +1 -1
- package/dist/tf-checkout-react.cjs.production.min.js.map +1 -1
- package/dist/tf-checkout-react.esm.js +1409 -586
- package/dist/tf-checkout-react.esm.js.map +1 -1
- package/dist/tf-checkout-styles.css +1 -1
- package/dist/utils/cookies.d.ts +3 -0
- package/dist/utils/createCheckoutDataBodyWithDefaultHolder.d.ts +6 -1
- package/dist/utils/downloadPDF.d.ts +1 -1
- package/dist/utils/getDomain.d.ts +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/package.json +89 -89
- package/src/.DS_Store +0 -0
- package/src/.d.ts +2 -2
- package/src/api/index.ts +313 -278
- package/src/assets/images/cross.svg +44 -0
- package/src/assets/images/done.svg +3 -3
- package/src/components/.DS_Store +0 -0
- package/src/components/account-settings/index.tsx +161 -0
- package/src/components/account-settings/style.css +200 -0
- package/src/components/billing-info-container/index.tsx +821 -777
- package/src/components/billing-info-container/style.css +106 -106
- package/src/components/billing-info-container/utils.ts +233 -223
- package/src/components/common/CheckboxField.tsx +41 -41
- package/src/components/common/CustomField.tsx +87 -84
- package/src/components/common/DatePickerField.tsx +98 -0
- package/src/components/common/FormikPhoneNumberField.tsx +51 -51
- package/src/components/common/Loader.tsx +9 -9
- package/src/components/common/RadioField.tsx +35 -35
- package/src/components/common/RedirectModal.tsx +43 -0
- package/src/components/common/SelectField.tsx +80 -80
- package/src/components/common/SnackbarAlert.tsx +54 -0
- package/src/components/common/dist/PhoneNumberField.js +96 -0
- package/src/components/common/index.tsx +4 -4
- package/src/components/confirmModal/index.tsx +51 -51
- package/src/components/confirmModal/style.css +21 -21
- package/src/components/confirmationContainer/config.ts +72 -72
- package/src/components/confirmationContainer/index.tsx +197 -194
- package/src/components/confirmationContainer/social-buttons.tsx +94 -94
- package/src/components/confirmationContainer/style.css +202 -202
- package/src/components/countdown/index.tsx +100 -89
- package/src/components/countdown/style.css +9 -9
- package/src/components/index.ts +7 -7
- package/src/components/loginModal/index.tsx +171 -209
- package/src/components/loginModal/style.css +71 -71
- package/src/components/myTicketsContainer/index.tsx +201 -137
- package/src/components/myTicketsContainer/row.tsx +41 -41
- package/src/components/myTicketsContainer/style.css +40 -40
- package/src/components/myTicketsContainer/tableConfig.tsx +32 -34
- package/src/components/orderDetailsContainer/index.tsx +289 -249
- package/src/components/orderDetailsContainer/style.css +73 -73
- package/src/components/orderDetailsContainer/ticketsTable.tsx +177 -124
- package/src/components/paymentContainer/index.tsx +352 -284
- package/src/components/registerModal/index.tsx +183 -190
- package/src/components/rsvpContainer/index.tsx +126 -0
- package/src/components/stripePayment/index.tsx +258 -253
- package/src/components/stripePayment/style.css +60 -60
- package/src/components/ticketResale/index.tsx +74 -56
- package/src/components/ticketResaleModal/index.tsx +213 -210
- package/src/components/ticketResaleModal/style.css +28 -28
- package/src/components/ticketsContainer/AccessCodeSection.tsx +50 -0
- package/src/components/ticketsContainer/PromoCodeSection.tsx +89 -99
- package/src/components/ticketsContainer/ReferralLogic.tsx +31 -33
- package/src/components/ticketsContainer/TicketRow.tsx +89 -83
- package/src/components/ticketsContainer/TicketsSection.tsx +87 -81
- package/src/components/ticketsContainer/index.tsx +506 -409
- package/src/components/ticketsContainer/style.css +181 -181
- package/src/components/ticketsContainer/utils.ts +11 -11
- package/src/components/timerWidget/index.tsx +87 -70
- package/src/components/timerWidget/style.css +34 -26
- package/src/components/waitingList/index.tsx +178 -178
- package/src/components/waitingList/style.css +26 -26
- package/src/env.ts +20 -19
- package/src/index.ts +15 -13
- package/src/normalizers/index.ts +45 -45
- package/src/types/billing-info-data.ts +37 -37
- package/src/types/payment-field.ts +7 -7
- package/src/types/referral-promotion.ts +7 -7
- package/src/utils/cookies.ts +42 -0
- package/src/utils/createCheckoutDataBodyWithDefaultHolder.ts +71 -59
- package/src/utils/downloadPDF.tsx +52 -30
- package/src/utils/formikErrorFocus.ts +24 -24
- package/src/utils/getDomain.ts +15 -0
- package/src/utils/getImage.ts +14 -14
- package/src/utils/getQueryVariable.ts +13 -13
- package/src/utils/index.ts +7 -5
- package/src/utils/setConfigs.ts +26 -26
- package/src/utils/showZero.tsx +10 -10
- package/src/validators/index.ts +20 -20
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export interface IReferralPromotion {
|
|
2
|
-
label: string;
|
|
3
|
-
price: string;
|
|
4
|
-
id?: number | string;
|
|
5
|
-
|
|
6
|
-
subLabel?: string;
|
|
7
|
-
}
|
|
1
|
+
export interface IReferralPromotion {
|
|
2
|
+
label: string;
|
|
3
|
+
price: string;
|
|
4
|
+
id?: number | string;
|
|
5
|
+
|
|
6
|
+
subLabel?: string;
|
|
7
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { getDomain } from './getDomain'
|
|
2
|
+
|
|
3
|
+
export function setCustomCookie(name: string, value: string, days: number = 5) {
|
|
4
|
+
let expires = ''
|
|
5
|
+
if (days) {
|
|
6
|
+
let date = new Date()
|
|
7
|
+
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000)
|
|
8
|
+
expires = '; expires=' + date.toUTCString()
|
|
9
|
+
}
|
|
10
|
+
if (typeof window !== 'undefined') {
|
|
11
|
+
const domain = getDomain(window.location.hostname)
|
|
12
|
+
document.cookie =
|
|
13
|
+
name + '=' + (value || '') + expires + '; path=/' + `; domain=${domain}`
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function getCookieByName(cname: string) {
|
|
18
|
+
if (typeof window === 'undefined') return ''
|
|
19
|
+
let name = cname + '='
|
|
20
|
+
let ca = document.cookie.split(';')
|
|
21
|
+
for (let i = 0; i < ca.length; i++) {
|
|
22
|
+
let c = ca[i]
|
|
23
|
+
while (c.charAt(0) == ' ') {
|
|
24
|
+
c = c.substring(1)
|
|
25
|
+
}
|
|
26
|
+
if (c.indexOf(name) == 0) {
|
|
27
|
+
return c.substring(name.length, c.length)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return ''
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
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;'
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -1,59 +1,71 @@
|
|
|
1
|
-
import _get from 'lodash/get'
|
|
2
|
-
|
|
3
|
-
interface ICheckoutBody {
|
|
4
|
-
attributes: {
|
|
5
|
-
[key: string]: any;
|
|
6
|
-
};
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
interface IticketHolder {
|
|
10
|
-
first_name?: string;
|
|
11
|
-
last_name?: string;
|
|
12
|
-
phone?: string;
|
|
13
|
-
email?: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
last_name,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
1
|
+
import _get from 'lodash/get'
|
|
2
|
+
|
|
3
|
+
interface ICheckoutBody {
|
|
4
|
+
attributes: {
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface IticketHolder {
|
|
10
|
+
first_name?: string;
|
|
11
|
+
last_name?: string;
|
|
12
|
+
phone?: string;
|
|
13
|
+
email?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface IUserCredentialsValues {
|
|
17
|
+
emailLogged?: string;
|
|
18
|
+
firstNameLogged?: string;
|
|
19
|
+
lastNameLogged?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const createCheckoutDataBodyWithDefaultHolder = (
|
|
23
|
+
ticketsQuantity: number,
|
|
24
|
+
logedInValues: {},
|
|
25
|
+
includeDob: boolean = false,
|
|
26
|
+
userCredentials: IUserCredentialsValues = {}
|
|
27
|
+
): ICheckoutBody => {
|
|
28
|
+
const ticket_holders: IticketHolder[] = []
|
|
29
|
+
|
|
30
|
+
const first_name =
|
|
31
|
+
_get(logedInValues, 'firstName') ||
|
|
32
|
+
_get(logedInValues, 'first_name') ||
|
|
33
|
+
_get(userCredentials, 'firstNameLogged') ||
|
|
34
|
+
''
|
|
35
|
+
|
|
36
|
+
const last_name =
|
|
37
|
+
_get(logedInValues, 'lastName') ||
|
|
38
|
+
_get(logedInValues, 'last_name') ||
|
|
39
|
+
_get(userCredentials, 'lastNameLogged') ||
|
|
40
|
+
''
|
|
41
|
+
const phone = _get(logedInValues, 'phone', '')
|
|
42
|
+
const email = _get(logedInValues, 'email') || _get(userCredentials, 'emailLogged') || ''
|
|
43
|
+
|
|
44
|
+
for (let i = 0; i <= ticketsQuantity - 1; i++) {
|
|
45
|
+
const individualHolder = i
|
|
46
|
+
? { first_name: '', last_name: '', phone: '', email: '' }
|
|
47
|
+
: { first_name, last_name, phone, email }
|
|
48
|
+
|
|
49
|
+
ticket_holders.push(individualHolder)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const body: ICheckoutBody = {
|
|
53
|
+
attributes: {
|
|
54
|
+
...logedInValues,
|
|
55
|
+
email,
|
|
56
|
+
confirm_email: email,
|
|
57
|
+
first_name,
|
|
58
|
+
last_name,
|
|
59
|
+
ticket_holders,
|
|
60
|
+
},
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (includeDob) {
|
|
64
|
+
const holderAgeDate = new Date(_get(logedInValues, 'holderAge', ''))
|
|
65
|
+
body.attributes.dob_day = holderAgeDate.getDate()
|
|
66
|
+
body.attributes.dob_month = holderAgeDate.getMonth() + 1
|
|
67
|
+
body.attributes.dob_year = holderAgeDate.getFullYear()
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return body
|
|
71
|
+
}
|
|
@@ -1,30 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
1
|
+
import { getCookieByName } from './cookies'
|
|
2
|
+
|
|
3
|
+
export const downloadPDF = (pdfUrl: string) => {
|
|
4
|
+
if (typeof window === 'undefined') return
|
|
5
|
+
|
|
6
|
+
const xtfCookie = getCookieByName('X-TF-ECOMMERCE')
|
|
7
|
+
const accessToken: string | null = localStorage.getItem('access_token')
|
|
8
|
+
|
|
9
|
+
if (!accessToken && !xtfCookie) return
|
|
10
|
+
|
|
11
|
+
let headers = {}
|
|
12
|
+
|
|
13
|
+
if (accessToken) {
|
|
14
|
+
headers = {
|
|
15
|
+
Authorization: `Bearer ${accessToken}`,
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (xtfCookie) {
|
|
20
|
+
headers = {
|
|
21
|
+
'X-TF-ECOMMERCE': xtfCookie,
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return fetch(pdfUrl, {
|
|
26
|
+
headers,
|
|
27
|
+
credentials: 'include',
|
|
28
|
+
})
|
|
29
|
+
.then(async response => {
|
|
30
|
+
const blobValue = await response.blob()
|
|
31
|
+
const fileNameHeader = response.headers.get('content-disposition') || ''
|
|
32
|
+
const fileName = fileNameHeader.split('"')[1]
|
|
33
|
+
return { blobValue, fileName }
|
|
34
|
+
})
|
|
35
|
+
.then(({ blobValue, fileName }) => {
|
|
36
|
+
if (!fileName) {
|
|
37
|
+
throw Error('Something went wrong.')
|
|
38
|
+
return
|
|
39
|
+
}
|
|
40
|
+
const file = new Blob([blobValue], { type: 'application/pdf' })
|
|
41
|
+
const fileURL = URL.createObjectURL(file)
|
|
42
|
+
const link = document.createElement('a')
|
|
43
|
+
link.href = fileURL
|
|
44
|
+
link.setAttribute('download', fileName)
|
|
45
|
+
document.body.appendChild(link)
|
|
46
|
+
link.click()
|
|
47
|
+
document.body.removeChild(link)
|
|
48
|
+
})
|
|
49
|
+
.catch(error => {
|
|
50
|
+
return error
|
|
51
|
+
})
|
|
52
|
+
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { connect, FormikContextType } from 'formik'
|
|
2
|
-
import { Component } from 'react'
|
|
3
|
-
|
|
4
|
-
interface IProps {
|
|
5
|
-
formik: FormikContextType<any>;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
class ErrorFocusInternal extends Component<IProps> {
|
|
9
|
-
public componentDidUpdate(prevProps: IProps) {
|
|
10
|
-
const { isSubmitting, isValidating, errors } = prevProps.formik
|
|
11
|
-
const keys = Object.keys(errors)
|
|
12
|
-
if (keys.length > 0 && isSubmitting && !isValidating) {
|
|
13
|
-
const selector = `[name="${keys[0]}"]`
|
|
14
|
-
const errorElement = document.querySelector(selector) as HTMLElement
|
|
15
|
-
if (errorElement) {
|
|
16
|
-
errorElement.focus()
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
public render = () => null;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const ErrorFocus = connect<{}>(ErrorFocusInternal)
|
|
1
|
+
import { connect, FormikContextType } from 'formik'
|
|
2
|
+
import { Component } from 'react'
|
|
3
|
+
|
|
4
|
+
interface IProps {
|
|
5
|
+
formik: FormikContextType<any>;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
class ErrorFocusInternal extends Component<IProps> {
|
|
9
|
+
public componentDidUpdate(prevProps: IProps) {
|
|
10
|
+
const { isSubmitting, isValidating, errors } = prevProps.formik
|
|
11
|
+
const keys = Object.keys(errors)
|
|
12
|
+
if (keys.length > 0 && isSubmitting && !isValidating) {
|
|
13
|
+
const selector = `[name="${keys[0]}"]`
|
|
14
|
+
const errorElement = document.querySelector(selector) as HTMLElement
|
|
15
|
+
if (errorElement) {
|
|
16
|
+
errorElement.focus()
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public render = () => null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const ErrorFocus = connect<{}>(ErrorFocusInternal)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function getDomain(url: string, subdomain?: string): string {
|
|
2
|
+
let updatedUrl: any = url.replace(/(https?:\/\/)?(www.)?/i, '')
|
|
3
|
+
|
|
4
|
+
if (!subdomain) {
|
|
5
|
+
updatedUrl = updatedUrl.split('.')
|
|
6
|
+
|
|
7
|
+
updatedUrl = updatedUrl.slice(updatedUrl.length - 2).join('.')
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (updatedUrl.indexOf('/') !== -1) {
|
|
11
|
+
return updatedUrl.split('/')[0]
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return updatedUrl
|
|
15
|
+
}
|
package/src/utils/getImage.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export const getImage = (name: string = ''): any => {
|
|
2
|
-
let image: any = ''
|
|
3
|
-
|
|
4
|
-
if (!name.trim().length) {
|
|
5
|
-
return image
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
if (process.env.NODE_ENV === 'production') {
|
|
9
|
-
image = require(`./images/${name}`)
|
|
10
|
-
return image.default
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
return image
|
|
14
|
-
}
|
|
1
|
+
export const getImage = (name: string = ''): any => {
|
|
2
|
+
let image: any = ''
|
|
3
|
+
|
|
4
|
+
if (!name.trim().length) {
|
|
5
|
+
return image
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
if (process.env.NODE_ENV === 'production') {
|
|
9
|
+
image = require(`./images/${name}`)
|
|
10
|
+
return image.default
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return image
|
|
14
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export const getQueryVariable = (variable: string) => {
|
|
2
|
-
if (typeof window !== 'undefined') {
|
|
3
|
-
const query = window.location.search.substring(1)
|
|
4
|
-
const vars = query.split('&')
|
|
5
|
-
for (let i = 0; i < vars.length; i++) {
|
|
6
|
-
const pair = vars[i].split('=')
|
|
7
|
-
if (pair[0] === variable) {
|
|
8
|
-
return pair[1]
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
return false
|
|
13
|
-
}
|
|
1
|
+
export const getQueryVariable = (variable: string) => {
|
|
2
|
+
if (typeof window !== 'undefined') {
|
|
3
|
+
const query = window.location.search.substring(1)
|
|
4
|
+
const vars = query.split('&')
|
|
5
|
+
for (let i = 0; i < vars.length; i++) {
|
|
6
|
+
const pair = vars[i].split('=')
|
|
7
|
+
if (pair[0] === variable) {
|
|
8
|
+
return pair[1]
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return false
|
|
13
|
+
}
|
package/src/utils/index.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export { setConfigs, CONFIGS } from './setConfigs'
|
|
2
|
-
export { getQueryVariable } from './getQueryVariable'
|
|
3
|
-
export { ErrorFocus } from './formikErrorFocus'
|
|
4
|
-
export { downloadPDF } from './downloadPDF'
|
|
5
|
-
export { createCheckoutDataBodyWithDefaultHolder } from './createCheckoutDataBodyWithDefaultHolder'
|
|
1
|
+
export { setConfigs, CONFIGS } from './setConfigs'
|
|
2
|
+
export { getQueryVariable } from './getQueryVariable'
|
|
3
|
+
export { ErrorFocus } from './formikErrorFocus'
|
|
4
|
+
export { downloadPDF } from './downloadPDF'
|
|
5
|
+
export { createCheckoutDataBodyWithDefaultHolder } from './createCheckoutDataBodyWithDefaultHolder'
|
|
6
|
+
export { setCustomCookie, getCookieByName, deleteCookieByName } from './cookies'
|
|
7
|
+
export { getDomain } from './getDomain'
|
package/src/utils/setConfigs.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import _forEach from 'lodash/forEach'
|
|
2
|
-
import { publicRequest, setXSourceOrigin } from '../api'
|
|
3
|
-
|
|
4
|
-
interface IConfigs {
|
|
5
|
-
BASE_URL: string;
|
|
6
|
-
CLIENT_ID: string;
|
|
7
|
-
CLIENT_SECRET: string;
|
|
8
|
-
STRIPE_PUBLISHABLE_KEY: string;
|
|
9
|
-
X_SOURCE_ORIGIN: string;
|
|
10
|
-
|
|
11
|
-
[key: string]: string | number;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const CONFIGS: IConfigs = {} as IConfigs
|
|
15
|
-
|
|
16
|
-
export const setConfigs = (configs: IConfigs) => {
|
|
17
|
-
_forEach(configs, (value, key) => {
|
|
18
|
-
CONFIGS[key] = value
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
publicRequest.setBaseUrl(CONFIGS.BASE_URL)
|
|
22
|
-
|
|
23
|
-
if (CONFIGS.X_SOURCE_ORIGIN) {
|
|
24
|
-
setXSourceOrigin(CONFIGS.X_SOURCE_ORIGIN)
|
|
25
|
-
}
|
|
26
|
-
}
|
|
1
|
+
import _forEach from 'lodash/forEach'
|
|
2
|
+
import { publicRequest, setXSourceOrigin } from '../api'
|
|
3
|
+
|
|
4
|
+
interface IConfigs {
|
|
5
|
+
BASE_URL: string;
|
|
6
|
+
CLIENT_ID: string;
|
|
7
|
+
CLIENT_SECRET: string;
|
|
8
|
+
STRIPE_PUBLISHABLE_KEY: string;
|
|
9
|
+
X_SOURCE_ORIGIN: string;
|
|
10
|
+
|
|
11
|
+
[key: string]: string | number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const CONFIGS: IConfigs = {} as IConfigs
|
|
15
|
+
|
|
16
|
+
export const setConfigs = (configs: IConfigs) => {
|
|
17
|
+
_forEach(configs, (value, key) => {
|
|
18
|
+
CONFIGS[key] = value
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
publicRequest.setBaseUrl(CONFIGS.BASE_URL)
|
|
22
|
+
|
|
23
|
+
if (CONFIGS.X_SOURCE_ORIGIN) {
|
|
24
|
+
setXSourceOrigin(CONFIGS.X_SOURCE_ORIGIN)
|
|
25
|
+
}
|
|
26
|
+
}
|
package/src/utils/showZero.tsx
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import _isNumber from 'lodash/isNumber'
|
|
2
|
-
|
|
3
|
-
export const showZero = (value = 0) => {
|
|
4
|
-
const intNumber = Number(value)
|
|
5
|
-
return _isNumber(intNumber)
|
|
6
|
-
? intNumber >= 0 && intNumber < 10
|
|
7
|
-
? '0' + intNumber
|
|
8
|
-
: intNumber
|
|
9
|
-
: null
|
|
10
|
-
}
|
|
1
|
+
import _isNumber from 'lodash/isNumber'
|
|
2
|
+
|
|
3
|
+
export const showZero = (value = 0) => {
|
|
4
|
+
const intNumber = Number(value)
|
|
5
|
+
return _isNumber(intNumber)
|
|
6
|
+
? intNumber >= 0 && intNumber < 10
|
|
7
|
+
? '0' + intNumber
|
|
8
|
+
: intNumber
|
|
9
|
+
: null
|
|
10
|
+
}
|
package/src/validators/index.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
const emailRegex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
|
|
2
|
-
|
|
3
|
-
export const combineValidators = (...validators: any) => (...value: any) => {
|
|
4
|
-
for (let i = 0; i < validators.length; ++i) {
|
|
5
|
-
const error_message = validators[i](...value)
|
|
6
|
-
if (error_message) return error_message
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const requiredValidator = (value?: string | number, message?: string): string => {
|
|
11
|
-
let errorMessage = ''
|
|
12
|
-
if (!value) {
|
|
13
|
-
errorMessage = message || 'Required'
|
|
14
|
-
}
|
|
15
|
-
return errorMessage
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const emailValidator = (email: string) => {
|
|
19
|
-
return !emailRegex.test(email) ? 'Please enter a valid email address' : ''
|
|
20
|
-
}
|
|
1
|
+
const emailRegex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
|
|
2
|
+
|
|
3
|
+
export const combineValidators = (...validators: any) => (...value: any) => {
|
|
4
|
+
for (let i = 0; i < validators.length; ++i) {
|
|
5
|
+
const error_message = validators[i](...value)
|
|
6
|
+
if (error_message) return error_message
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const requiredValidator = (value?: string | number, message?: string): string => {
|
|
11
|
+
let errorMessage = ''
|
|
12
|
+
if (!value) {
|
|
13
|
+
errorMessage = message || 'Required'
|
|
14
|
+
}
|
|
15
|
+
return errorMessage
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const emailValidator = (email: string) => {
|
|
19
|
+
return !emailRegex.test(email) ? 'Please enter a valid email address' : ''
|
|
20
|
+
}
|