tf-checkout-react 1.0.93 → 1.0.94

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.93",
2
+ "version": "1.0.94",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
package/src/api/index.ts CHANGED
@@ -100,10 +100,7 @@ export const setXSourceOrigin = (sourceOrigin: string) => {
100
100
  }
101
101
 
102
102
  export const setCustomHeader = (response: any) => {
103
- const guestHeaderResponseValue = _get(
104
- response,
105
- 'headers.authorization-guest'
106
- )
103
+ const guestHeaderResponseValue = _get(response, 'headers.authorization-guest')
107
104
  const guestHeaderExistingValue = _get(
108
105
  response,
109
106
  'config.headers[Authorization-Guest]'
@@ -141,10 +138,10 @@ export function getTickets(id: string | number, promoCode: string) {
141
138
  .get(`v1/event/${id}/tickets/`, {
142
139
  headers: promoCode
143
140
  ? {
144
- ...ttfHeaders,
145
- 'Promotion-Event': String(id),
146
- 'Promotion-Code': promoCode,
147
- }
141
+ ...ttfHeaders,
142
+ 'Promotion-Event': String(id),
143
+ 'Promotion-Code': promoCode,
144
+ }
148
145
  : { ...ttfHeaders },
149
146
  })
150
147
  .catch(error => {
@@ -252,3 +249,8 @@ export const addToWaitingList = (id: number, data: any) =>
252
249
 
253
250
  export const getConditions = (eventId: string) =>
254
251
  publicRequest.get(`v1/event/${eventId}/conditions`)
252
+
253
+ export const postReferralVisits = (eventId: string, referralId: string) =>
254
+ publicRequest.post(`/v1/event/${eventId}/referrer/`, {
255
+ referrer: `${referralId}`,
256
+ })
@@ -0,0 +1,33 @@
1
+ import { useEffect } from 'react'
2
+ import { postReferralVisits } from '../../api'
3
+
4
+ interface IReferralLogicProps {
5
+ eventId: string | number;
6
+ }
7
+
8
+ export const ReferralLogic = (props: IReferralLogicProps) => {
9
+ const { eventId } = props
10
+ const isWindowDefined = typeof window !== 'undefined'
11
+
12
+ useEffect(() => {
13
+ if (isWindowDefined) {
14
+ const params: URLSearchParams = new URL(`${window.location}`).searchParams
15
+ const referralId = params.get('ttf_r') || ''
16
+ const isAlreadyCounted = !!localStorage.getItem('referral_key')
17
+
18
+ if (referralId && eventId && !isAlreadyCounted) {
19
+ (async () => {
20
+ try {
21
+ await postReferralVisits(`${eventId}`, referralId)
22
+ localStorage.setItem(
23
+ 'referral_key',
24
+ [eventId, '.', referralId].join('')
25
+ )
26
+ } catch (error) {}
27
+ })()
28
+ }
29
+ }
30
+ }, [])
31
+
32
+ return null
33
+ }
@@ -26,6 +26,7 @@ import { createCheckoutDataBodyWithDefaultHolder, getQueryVariable } from '../..
26
26
  import { ThemeProvider } from '@mui/private-theming'
27
27
  import { createTheme, ThemeOptions } from '@mui/material'
28
28
  import { CSSProperties } from '@mui/styles'
29
+ import { ReferralLogic } from './ReferralLogic'
29
30
 
30
31
  function Loader() {
31
32
  return (
@@ -315,6 +316,7 @@ export const TicketsContainer = ({
315
316
 
316
317
  return (
317
318
  <ThemeProvider theme={themeMui}>
319
+ <ReferralLogic eventId={eventId} />
318
320
  <div className={`get-tickets-page ${theme}`} style={contentStyle}>
319
321
  {isLoading ? (
320
322
  <Loader />