tf-checkout-react 1.2.23 → 1.2.26
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/dist/api/index.d.ts +1 -8
- package/dist/components/orderDetailsContainer/index.d.ts +8 -1
- package/dist/components/orderDetailsContainer/ticketsTable.d.ts +11 -1
- package/dist/tf-checkout-react.cjs.development.js +158 -123
- 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 +158 -123
- package/dist/tf-checkout-react.esm.js.map +1 -1
- package/dist/utils/setConfigs.d.ts +12 -1
- package/package.json +1 -1
- package/src/api/index.ts +2 -21
- package/src/components/billing-info-container/index.tsx +9 -10
- package/src/components/myTicketsContainer/row.tsx +20 -21
- package/src/components/orderDetailsContainer/index.tsx +30 -9
- package/src/components/orderDetailsContainer/ticketsTable.tsx +96 -82
- package/src/components/ticketsContainer/index.tsx +0 -16
- package/src/utils/setConfigs.ts +23 -4
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
export declare const ttfHeaders: {
|
|
3
|
+
[key: string]: any;
|
|
4
|
+
};
|
|
5
|
+
interface IPublicRequest extends AxiosInstance {
|
|
6
|
+
setGuestToken: (token: string) => void;
|
|
7
|
+
setAccessToken: (token: string) => void;
|
|
8
|
+
setBaseUrl: (baseUrl: string) => void;
|
|
9
|
+
}
|
|
10
|
+
export interface IConfigs {
|
|
2
11
|
BASE_URL: string;
|
|
3
12
|
CLIENT_ID: string;
|
|
4
13
|
CLIENT_SECRET: string;
|
|
@@ -7,5 +16,7 @@ interface IConfigs {
|
|
|
7
16
|
[key: string]: string | number;
|
|
8
17
|
}
|
|
9
18
|
export declare const CONFIGS: IConfigs;
|
|
19
|
+
export declare const publicRequest: IPublicRequest;
|
|
20
|
+
export declare const setXSourceOrigin: (sourceOrigin: string) => void;
|
|
10
21
|
export declare const setConfigs: (configs: IConfigs) => void;
|
|
11
22
|
export {};
|
package/package.json
CHANGED
package/src/api/index.ts
CHANGED
|
@@ -1,31 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { AxiosRequestConfig, AxiosResponse } from 'axios'
|
|
2
2
|
import _get from 'lodash/get'
|
|
3
3
|
|
|
4
4
|
import { CONFIGS, getCookieByName, setCustomCookie } from '../utils'
|
|
5
|
+
import { publicRequest, ttfHeaders } from '../utils/setConfigs'
|
|
5
6
|
|
|
6
7
|
const isWindowDefined = typeof window !== 'undefined'
|
|
7
8
|
const isDocumentDefined = typeof document !== 'undefined'
|
|
8
9
|
|
|
9
|
-
const ttfHeaders: { [key: string]: any } = {
|
|
10
|
-
Accept: 'application/vnd.api+json',
|
|
11
|
-
'Content-Type': 'application/vnd.api+json',
|
|
12
|
-
}
|
|
13
|
-
|
|
14
10
|
if (isWindowDefined && localStorage.getItem('auth_guest_token')) {
|
|
15
11
|
ttfHeaders['Authorization-Guest'] = localStorage.getItem('auth_guest_token')
|
|
16
12
|
}
|
|
17
13
|
|
|
18
|
-
interface IPublicRequest extends AxiosInstance {
|
|
19
|
-
setGuestToken: (token: string) => void;
|
|
20
|
-
setAccessToken: (token: string) => void;
|
|
21
|
-
setBaseUrl: (baseUrl: string) => void;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const publicRequest: IPublicRequest = axios.create({
|
|
25
|
-
baseURL: CONFIGS.BASE_URL || `https://www.ticketfairy.com/api`,
|
|
26
|
-
headers: ttfHeaders,
|
|
27
|
-
}) as IPublicRequest
|
|
28
|
-
|
|
29
14
|
publicRequest.interceptors.response.use(
|
|
30
15
|
response => {
|
|
31
16
|
const authGuestToken = _get(response, 'headers.authorization-guest')
|
|
@@ -131,10 +116,6 @@ publicRequest.setBaseUrl = (baseUrl: string) =>
|
|
|
131
116
|
publicRequest.setAccessToken = token =>
|
|
132
117
|
(publicRequest.defaults.headers.common.Authorization = token)
|
|
133
118
|
|
|
134
|
-
export const setXSourceOrigin = (sourceOrigin: string) => {
|
|
135
|
-
ttfHeaders['X-Source-Origin'] = sourceOrigin
|
|
136
|
-
}
|
|
137
|
-
|
|
138
119
|
export const setCustomHeader = (response: any) => {
|
|
139
120
|
const guestHeaderResponseValue = _get(response, 'headers.authorization-guest')
|
|
140
121
|
const guestHeaderExistingValue = _get(
|
|
@@ -508,24 +508,23 @@ export const BillingInfoContainer = React.memo(
|
|
|
508
508
|
onSubmit={async (values, formikHelpers) => {
|
|
509
509
|
try {
|
|
510
510
|
if (isLoggedIn) {
|
|
511
|
-
|
|
511
|
+
const checkoutBody = collectCheckoutBody(values, userData)
|
|
512
|
+
const res = await postOnCheckout(checkoutBody, access_token)
|
|
513
|
+
removeReferralKey()
|
|
514
|
+
// After checkout is successful recover updated profile and store it on local storage if needed
|
|
515
|
+
if (isWindowDefined) {
|
|
512
516
|
const updatedUserData = await getProfileData(access_token)
|
|
513
517
|
const profileSpecifiedData = _get(
|
|
514
|
-
|
|
515
|
-
|
|
518
|
+
updatedUserData,
|
|
519
|
+
'data.data'
|
|
516
520
|
)
|
|
517
521
|
const profileDataObj = setLoggedUserData(profileSpecifiedData)
|
|
518
|
-
|
|
519
|
-
window.localStorage.setItem(
|
|
522
|
+
window.localStorage.setItem(
|
|
520
523
|
'user_data',
|
|
521
524
|
JSON.stringify(profileDataObj)
|
|
522
|
-
|
|
523
|
-
}
|
|
525
|
+
)
|
|
524
526
|
}
|
|
525
527
|
|
|
526
|
-
const checkoutBody = collectCheckoutBody(values, userData)
|
|
527
|
-
const res = await postOnCheckout(checkoutBody, access_token)
|
|
528
|
-
removeReferralKey()
|
|
529
528
|
handleSubmit(
|
|
530
529
|
values,
|
|
531
530
|
formikHelpers as FormikHelpers<any>,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import TableRow from '@mui/material/TableRow'
|
|
3
1
|
import TableCell from '@mui/material/TableCell'
|
|
2
|
+
import TableRow from '@mui/material/TableRow'
|
|
3
|
+
import React from 'react'
|
|
4
|
+
|
|
4
5
|
import tableConfig from './tableConfig'
|
|
5
6
|
|
|
6
7
|
export interface RowItems {
|
|
@@ -17,25 +18,23 @@ interface RowPropsTypes {
|
|
|
17
18
|
handleDetailsInfo: (id: string) => void;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
const Row = ({ row, handleDetailsInfo }: RowPropsTypes) =>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
{column(row)}
|
|
26
|
-
</TableCell>
|
|
27
|
-
))}
|
|
28
|
-
<TableCell component="th" scope="row">
|
|
29
|
-
<button
|
|
30
|
-
type='button'
|
|
31
|
-
className="order-details-button"
|
|
32
|
-
onClick={() => handleDetailsInfo(row.id)}
|
|
33
|
-
>
|
|
34
|
-
Details
|
|
35
|
-
</button>
|
|
21
|
+
const Row = ({ row, handleDetailsInfo }: RowPropsTypes) => (
|
|
22
|
+
<TableRow sx={{ '& > *': { borderBottom: 'unset' } }}>
|
|
23
|
+
{tableConfig().body.map((column: any, index: number) => (
|
|
24
|
+
<TableCell component="th" scope="row" key={index}>
|
|
25
|
+
{column(row)}
|
|
36
26
|
</TableCell>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
27
|
+
))}
|
|
28
|
+
<TableCell component="th" scope="row">
|
|
29
|
+
<button
|
|
30
|
+
type="button"
|
|
31
|
+
className="order-details-button"
|
|
32
|
+
onClick={() => handleDetailsInfo(row.id)}
|
|
33
|
+
>
|
|
34
|
+
Details
|
|
35
|
+
</button>
|
|
36
|
+
</TableCell>
|
|
37
|
+
</TableRow>
|
|
38
|
+
)
|
|
40
39
|
|
|
41
40
|
export default Row
|
|
@@ -11,6 +11,7 @@ import TableRow from '@mui/material/TableRow'
|
|
|
11
11
|
import _find from 'lodash/find'
|
|
12
12
|
import _get from 'lodash/get'
|
|
13
13
|
import _has from 'lodash/has'
|
|
14
|
+
import _identity from 'lodash/identity'
|
|
14
15
|
import _map from 'lodash/map'
|
|
15
16
|
import moment from 'moment-timezone'
|
|
16
17
|
import React, { useEffect, useState } from 'react'
|
|
@@ -18,7 +19,7 @@ import React, { useEffect, useState } from 'react'
|
|
|
18
19
|
import { getOrderDetails, removeFromResale, resaleTicket } from '../../api'
|
|
19
20
|
import ConfirmModal from '../confirmModal'
|
|
20
21
|
import { InitialValuesTypes, TicketResaleModal } from '../ticketResaleModal'
|
|
21
|
-
import TicketsTable, { ITicketTypes } from './ticketsTable'
|
|
22
|
+
import TicketsTable, { IActionColumns, ITicketTypes } from './ticketsTable'
|
|
22
23
|
|
|
23
24
|
interface TicketTypes {
|
|
24
25
|
currency: string;
|
|
@@ -39,6 +40,12 @@ interface OrderDetailsTypes {
|
|
|
39
40
|
onResaleTicketSuccess: () => void;
|
|
40
41
|
onResaleTicketError: (err: any) => void;
|
|
41
42
|
personalLinkIcon?: string;
|
|
43
|
+
displayColumnNameInRow?: boolean;
|
|
44
|
+
ticketsTableColumns?: Array<{
|
|
45
|
+
id?: string | number;
|
|
46
|
+
key: keyof ITicketTypes & keyof IActionColumns;
|
|
47
|
+
label: string | number | null | undefined;
|
|
48
|
+
}>;
|
|
42
49
|
}
|
|
43
50
|
|
|
44
51
|
const getTotal = (data: any) => {
|
|
@@ -49,14 +56,16 @@ const getTotal = (data: any) => {
|
|
|
49
56
|
|
|
50
57
|
export const OrderDetailsContainer = ({
|
|
51
58
|
columns = [],
|
|
52
|
-
onGetOrdersSuccess =
|
|
53
|
-
onGetOrdersError =
|
|
54
|
-
onRemoveFromResaleSuccess =
|
|
55
|
-
onRemoveFromResaleError =
|
|
56
|
-
onResaleTicketSuccess =
|
|
57
|
-
onResaleTicketError =
|
|
59
|
+
onGetOrdersSuccess = _identity,
|
|
60
|
+
onGetOrdersError = _identity,
|
|
61
|
+
onRemoveFromResaleSuccess = _identity,
|
|
62
|
+
onRemoveFromResaleError = _identity,
|
|
63
|
+
onResaleTicketSuccess = _identity,
|
|
64
|
+
onResaleTicketError = _identity,
|
|
58
65
|
onReturnButtonClick,
|
|
59
66
|
personalLinkIcon = '',
|
|
67
|
+
displayColumnNameInRow = false,
|
|
68
|
+
ticketsTableColumns,
|
|
60
69
|
}: OrderDetailsTypes) => {
|
|
61
70
|
const [data, setData] = useState<any>({})
|
|
62
71
|
const [loading, setLoading] = useState(true)
|
|
@@ -259,8 +268,7 @@ export const OrderDetailsContainer = ({
|
|
|
259
268
|
(ticket: TicketTypes, index: number) => (
|
|
260
269
|
<TableRow key={index}>
|
|
261
270
|
<TableCell>
|
|
262
|
-
<b>Ticket Type
|
|
263
|
-
{ticket.name}
|
|
271
|
+
<b>Ticket Type:</b> {ticket.name}
|
|
264
272
|
</TableCell>
|
|
265
273
|
<TableCell>{ticket.currency + ticket.price}</TableCell>
|
|
266
274
|
<TableCell>{ticket.quantity}</TableCell>
|
|
@@ -293,8 +301,21 @@ export const OrderDetailsContainer = ({
|
|
|
293
301
|
</div>
|
|
294
302
|
<TicketsTable
|
|
295
303
|
tickets={data.tickets}
|
|
304
|
+
columns={
|
|
305
|
+
ticketsTableColumns?.length
|
|
306
|
+
? ticketsTableColumns
|
|
307
|
+
: [
|
|
308
|
+
{ key: 'hash' as never, label: 'Ticket ID' },
|
|
309
|
+
{ key: 'ticket_type' as never, label: 'Ticket Type' },
|
|
310
|
+
{ key: 'holder_name' as never, label: 'Ticket Holder' },
|
|
311
|
+
{ key: 'status' as never, label: 'Status' },
|
|
312
|
+
{ key: 'download' as never, label: '' },
|
|
313
|
+
{ key: 'sell_ticket' as never, label: '' },
|
|
314
|
+
]
|
|
315
|
+
}
|
|
296
316
|
handleSellTicket={handleSellTicket}
|
|
297
317
|
handleRemoveFromResale={handleRemoveFromResale}
|
|
318
|
+
displayColumnNameInRow={displayColumnNameInRow}
|
|
298
319
|
/>
|
|
299
320
|
<div className="return-button-container">
|
|
300
321
|
<button
|
|
@@ -6,6 +6,7 @@ import TableContainer from '@mui/material/TableContainer'
|
|
|
6
6
|
import TableHead from '@mui/material/TableHead'
|
|
7
7
|
import TableRow from '@mui/material/TableRow'
|
|
8
8
|
import _identity from 'lodash/identity'
|
|
9
|
+
import _map from 'lodash/map'
|
|
9
10
|
import React, { Fragment, useState } from 'react'
|
|
10
11
|
|
|
11
12
|
import { downloadPDF } from '../../utils'
|
|
@@ -31,21 +32,105 @@ export interface ITicketTypes {
|
|
|
31
32
|
ticket_type_is_active?: boolean;
|
|
32
33
|
}
|
|
33
34
|
|
|
35
|
+
export interface IActionColumns {
|
|
36
|
+
download?: boolean;
|
|
37
|
+
sell_ticket?: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
34
40
|
interface TicketsTableTypes {
|
|
35
41
|
tickets: ITicketTypes[];
|
|
42
|
+
columns: Array<{
|
|
43
|
+
id?: string | number;
|
|
44
|
+
key: keyof ITicketTypes & keyof IActionColumns;
|
|
45
|
+
label: string | number | null | undefined;
|
|
46
|
+
}>;
|
|
36
47
|
handleSellTicket: (ticket: ITicketTypes) => void;
|
|
37
48
|
handleRemoveFromResale: (ticket: ITicketTypes) => void;
|
|
38
49
|
|
|
39
50
|
icon?: string;
|
|
51
|
+
displayColumnNameInRow?: boolean;
|
|
40
52
|
}
|
|
41
53
|
|
|
42
54
|
const TicketsTable = ({
|
|
43
55
|
tickets = [],
|
|
56
|
+
columns = [],
|
|
44
57
|
handleSellTicket = _identity,
|
|
45
58
|
handleRemoveFromResale = _identity,
|
|
46
59
|
icon = '',
|
|
60
|
+
displayColumnNameInRow = false,
|
|
47
61
|
}: TicketsTableTypes) => {
|
|
48
62
|
const [pdfError, setPdfError] = useState<string | null>(null)
|
|
63
|
+
|
|
64
|
+
const getRow = (ticket: ITicketTypes) =>
|
|
65
|
+
_map(columns, (column, columnIndex) => {
|
|
66
|
+
if (column.key === 'download') {
|
|
67
|
+
if (ticket.pdf_link && ticket.status === 'Sold') return null
|
|
68
|
+
return (
|
|
69
|
+
<TableCell key={columnIndex}>
|
|
70
|
+
{Boolean(icon) && <img src={icon} alt="nodata" />}
|
|
71
|
+
<span
|
|
72
|
+
aria-hidden={true}
|
|
73
|
+
className="action-button"
|
|
74
|
+
onClick={async () => {
|
|
75
|
+
try {
|
|
76
|
+
const pdfDownloadError = await downloadPDF(ticket.pdf_link)
|
|
77
|
+
if (pdfDownloadError) {
|
|
78
|
+
setPdfError(pdfDownloadError?.message)
|
|
79
|
+
}
|
|
80
|
+
} catch (err) {
|
|
81
|
+
if (err && typeof err === 'string') {
|
|
82
|
+
setPdfError(err)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}}
|
|
86
|
+
>
|
|
87
|
+
Download
|
|
88
|
+
</span>
|
|
89
|
+
</TableCell>
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (column.key === 'sell_ticket') {
|
|
94
|
+
return (
|
|
95
|
+
<TableCell key={columnIndex}>
|
|
96
|
+
{ticket.is_sellable && (
|
|
97
|
+
<span
|
|
98
|
+
aria-hidden={true}
|
|
99
|
+
className="action-button"
|
|
100
|
+
onClick={() => handleSellTicket(ticket)}
|
|
101
|
+
>
|
|
102
|
+
Sell Ticket
|
|
103
|
+
</span>
|
|
104
|
+
)}
|
|
105
|
+
{ticket.is_on_sale && (
|
|
106
|
+
<span
|
|
107
|
+
aria-hidden={true}
|
|
108
|
+
className="action-button"
|
|
109
|
+
onClick={() => handleRemoveFromResale(ticket)}
|
|
110
|
+
>
|
|
111
|
+
Remove from Resale
|
|
112
|
+
</span>
|
|
113
|
+
)}
|
|
114
|
+
</TableCell>
|
|
115
|
+
)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return displayColumnNameInRow ? (
|
|
119
|
+
<TableCell key={columnIndex}>
|
|
120
|
+
<div className="cell-block">
|
|
121
|
+
<span>{column.label}</span>
|
|
122
|
+
<span>{ticket[column.key]}</span>
|
|
123
|
+
</div>
|
|
124
|
+
</TableCell>
|
|
125
|
+
) : (
|
|
126
|
+
<TableCell key={columnIndex}>
|
|
127
|
+
<div className="cell-block">
|
|
128
|
+
<span>{ticket[column.key]}</span>
|
|
129
|
+
</div>
|
|
130
|
+
</TableCell>
|
|
131
|
+
)
|
|
132
|
+
})
|
|
133
|
+
|
|
49
134
|
return (
|
|
50
135
|
<div className="tickets-box">
|
|
51
136
|
<SnackbarAlert
|
|
@@ -57,90 +142,19 @@ const TicketsTable = ({
|
|
|
57
142
|
<h4 className="sub-title">Your Tickets</h4>
|
|
58
143
|
<TableContainer component={Paper}>
|
|
59
144
|
<Table aria-label="collapsible table">
|
|
60
|
-
|
|
61
|
-
<
|
|
62
|
-
<
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
</TableHead>
|
|
145
|
+
{displayColumnNameInRow ? null : (
|
|
146
|
+
<TableHead>
|
|
147
|
+
<TableRow>
|
|
148
|
+
{_map(columns, item => (
|
|
149
|
+
<TableCell key={item.key}>{item.label || ''}</TableCell>
|
|
150
|
+
))}
|
|
151
|
+
</TableRow>
|
|
152
|
+
</TableHead>
|
|
153
|
+
)}
|
|
70
154
|
<TableBody>
|
|
71
155
|
{tickets.map((ticket: ITicketTypes, index: number) => (
|
|
72
156
|
<Fragment key={index}>
|
|
73
|
-
<TableRow>
|
|
74
|
-
<TableCell>
|
|
75
|
-
<div className="cell-block">
|
|
76
|
-
<span>Ticket ID</span>
|
|
77
|
-
<span>{ticket.hash}</span>
|
|
78
|
-
</div>
|
|
79
|
-
</TableCell>
|
|
80
|
-
<TableCell>
|
|
81
|
-
<div className="cell-block">
|
|
82
|
-
<span>Ticket Type</span>
|
|
83
|
-
<span>{ticket.ticket_type}</span>
|
|
84
|
-
</div>
|
|
85
|
-
</TableCell>
|
|
86
|
-
<TableCell>
|
|
87
|
-
<div className="cell-block">
|
|
88
|
-
<span>Ticket Holder</span>
|
|
89
|
-
<span>{ticket.holder_name}</span>
|
|
90
|
-
</div>
|
|
91
|
-
</TableCell>
|
|
92
|
-
<TableCell>
|
|
93
|
-
<div className="cell-block">
|
|
94
|
-
<span>Status</span>
|
|
95
|
-
<span>{ticket.status}</span>
|
|
96
|
-
</div>
|
|
97
|
-
</TableCell>
|
|
98
|
-
{ticket.pdf_link && ticket.status !== "Sold" ? (
|
|
99
|
-
<TableCell>
|
|
100
|
-
{Boolean(icon) && <img src={icon} alt="nodata" />}
|
|
101
|
-
<span
|
|
102
|
-
aria-hidden={true}
|
|
103
|
-
className="action-button"
|
|
104
|
-
onClick={async () => {
|
|
105
|
-
try {
|
|
106
|
-
const pdfDownloadError = await downloadPDF(
|
|
107
|
-
ticket.pdf_link
|
|
108
|
-
)
|
|
109
|
-
if (pdfDownloadError) {
|
|
110
|
-
setPdfError(pdfDownloadError?.message)
|
|
111
|
-
}
|
|
112
|
-
} catch (err) {
|
|
113
|
-
if (err && typeof err === 'string') {
|
|
114
|
-
setPdfError(err)
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}}
|
|
118
|
-
>
|
|
119
|
-
Download
|
|
120
|
-
</span>
|
|
121
|
-
</TableCell>
|
|
122
|
-
) : null}
|
|
123
|
-
<TableCell>
|
|
124
|
-
{ticket.is_sellable && (
|
|
125
|
-
<span
|
|
126
|
-
aria-hidden={true}
|
|
127
|
-
className="action-button"
|
|
128
|
-
onClick={() => handleSellTicket(ticket)}
|
|
129
|
-
>
|
|
130
|
-
Sell Ticket
|
|
131
|
-
</span>
|
|
132
|
-
)}
|
|
133
|
-
{ticket.is_on_sale && (
|
|
134
|
-
<span
|
|
135
|
-
aria-hidden={true}
|
|
136
|
-
className="action-button"
|
|
137
|
-
onClick={() => handleRemoveFromResale(ticket)}
|
|
138
|
-
>
|
|
139
|
-
Remove from Resale
|
|
140
|
-
</span>
|
|
141
|
-
)}
|
|
142
|
-
</TableCell>
|
|
143
|
-
</TableRow>
|
|
157
|
+
<TableRow>{getRow(ticket)}</TableRow>
|
|
144
158
|
{!!ticket.add_ons?.length && (
|
|
145
159
|
<TableRow>
|
|
146
160
|
<TableCell colSpan={6}>
|
|
@@ -174,4 +188,4 @@ const TicketsTable = ({
|
|
|
174
188
|
)
|
|
175
189
|
}
|
|
176
190
|
|
|
177
|
-
export default TicketsTable
|
|
191
|
+
export default TicketsTable
|
|
@@ -177,22 +177,6 @@ export const TicketsContainer = ({
|
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
-
useEffect(() => {
|
|
181
|
-
try {
|
|
182
|
-
if (typeof window !== 'undefined') {
|
|
183
|
-
const userData = window.localStorage.getItem('user_data')
|
|
184
|
-
? JSON.parse(window.localStorage.getItem('user_data') || '{}')
|
|
185
|
-
: {}
|
|
186
|
-
if (userData.country === '') {
|
|
187
|
-
handleLogout()
|
|
188
|
-
window.open(
|
|
189
|
-
'https://www.ticketfairy.com/account/change_information?need_country=true'
|
|
190
|
-
)
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
} catch (e) {}
|
|
194
|
-
}, [])
|
|
195
|
-
|
|
196
180
|
const handleExternalLogin = () => {
|
|
197
181
|
setIsLogged(true)
|
|
198
182
|
}
|
package/src/utils/setConfigs.ts
CHANGED
|
@@ -1,18 +1,37 @@
|
|
|
1
|
+
import axios, { AxiosInstance } from 'axios';
|
|
1
2
|
import _forEach from 'lodash/forEach'
|
|
2
|
-
import { publicRequest, setXSourceOrigin } from '../api'
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
export const ttfHeaders: { [key: string]: any } = {
|
|
5
|
+
Accept: 'application/vnd.api+json',
|
|
6
|
+
'Content-Type': 'application/vnd.api+json',
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface IPublicRequest extends AxiosInstance {
|
|
10
|
+
setGuestToken: (token: string) => void;
|
|
11
|
+
setAccessToken: (token: string) => void;
|
|
12
|
+
setBaseUrl: (baseUrl: string) => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface IConfigs {
|
|
5
16
|
BASE_URL: string;
|
|
6
17
|
CLIENT_ID: string;
|
|
7
18
|
CLIENT_SECRET: string;
|
|
8
19
|
STRIPE_PUBLISHABLE_KEY: string;
|
|
9
20
|
X_SOURCE_ORIGIN: string;
|
|
10
|
-
|
|
11
21
|
[key: string]: string | number;
|
|
12
22
|
}
|
|
13
23
|
|
|
14
24
|
export const CONFIGS: IConfigs = {} as IConfigs
|
|
15
25
|
|
|
26
|
+
export const publicRequest: IPublicRequest = axios.create({
|
|
27
|
+
baseURL: CONFIGS.BASE_URL || `https://www.ticketfairy.com/api`,
|
|
28
|
+
headers: ttfHeaders,
|
|
29
|
+
}) as IPublicRequest
|
|
30
|
+
|
|
31
|
+
export const setXSourceOrigin = (sourceOrigin: string) => {
|
|
32
|
+
ttfHeaders['X-Source-Origin'] = sourceOrigin
|
|
33
|
+
}
|
|
34
|
+
|
|
16
35
|
export const setConfigs = (configs: IConfigs) => {
|
|
17
36
|
_forEach(configs, (value, key) => {
|
|
18
37
|
CONFIGS[key] = value
|
|
@@ -23,4 +42,4 @@ export const setConfigs = (configs: IConfigs) => {
|
|
|
23
42
|
if (CONFIGS.X_SOURCE_ORIGIN) {
|
|
24
43
|
setXSourceOrigin(CONFIGS.X_SOURCE_ORIGIN)
|
|
25
44
|
}
|
|
26
|
-
}
|
|
45
|
+
}
|