tf-checkout-react 1.6.6-beta.11 → 1.6.6-beta.13

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.11",
2
+ "version": "1.6.6-beta.13",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -110,4 +110,4 @@
110
110
  "tf-seat-map-view": "9.4.7-beta.33",
111
111
  "yup": "^0.32.11"
112
112
  }
113
- }
113
+ }
package/src/api/index.ts CHANGED
@@ -155,7 +155,7 @@ export const getCheckoutPageConfigs = async (): Promise<ResponseConfigs> => {
155
155
 
156
156
 
157
157
  export const getCustomFields = async (eventId: string) => {
158
- const response = await publicRequest.get(`/v1/event/${eventId}/custom_fields`)
158
+ const response = await publicRequest.get(`/v1/event/${eventId}/fields`)
159
159
  const customFields = _get(response, 'data.data.attributes', [])
160
160
  const adaptedResponse = customFieldsDataAdapter(customFields)
161
161
  return adaptedResponse
@@ -1,12 +1,16 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
1
2
  import './style.css'
2
3
 
4
+ import { ThemeOptions } from "@mui/material"
3
5
  import Paper from '@mui/material/Paper'
6
+ import { createTheme, ThemeProvider } from "@mui/material/styles"
4
7
  import Table from '@mui/material/Table'
5
8
  import TableBody from '@mui/material/TableBody'
6
9
  import TableCell from '@mui/material/TableCell'
7
10
  import TableContainer from '@mui/material/TableContainer'
8
11
  import TableHead from '@mui/material/TableHead'
9
12
  import TableRow from '@mui/material/TableRow'
13
+ import { CSSProperties } from "@mui/styles"
10
14
  import _find from 'lodash/find'
11
15
  import _get from 'lodash/get'
12
16
  import _has from 'lodash/has'
@@ -31,9 +35,6 @@ import { InitialValuesTypes, TicketResaleModal } from '../ticketResaleModal'
31
35
  import { CustomFieldsForm } from './CustomFieldsForm'
32
36
  import TicketsTable, { IActionColumns, ITicketTypes } from './ticketsTable'
33
37
  import { isFieldUpdatable, renderCustomFieldValue } from './utils'
34
- import {ThemeOptions} from "@mui/material";
35
- import {CSSProperties} from "@mui/styles";
36
- import {createTheme, ThemeProvider} from "@mui/material/styles";
37
38
 
38
39
  interface TicketTypes {
39
40
  currency: string;
@@ -505,12 +506,12 @@ export const OrderDetailsContainer = ({
505
506
  ticketsTableColumns?.length
506
507
  ? ticketsTableColumns
507
508
  : [
508
- {key: 'hash' as never, label: 'Ticket ID'},
509
- {key: 'ticket_type' as never, label: 'Ticket Type'},
510
- {key: 'holder_name' as never, label: 'Ticket Holder'},
511
- {key: 'status' as never, label: 'Status'},
512
- {key: 'download' as never, label: ''},
513
- {key: 'sell_ticket' as never, label: ''},
509
+ { key: 'hash' as never, label: 'Ticket ID' },
510
+ { key: 'ticket_type' as never, label: 'Ticket Type' },
511
+ { key: 'holder_name' as never, label: 'Ticket Holder' },
512
+ { key: 'status' as never, label: 'Status' },
513
+ { key: 'download' as never, label: '' },
514
+ { key: 'sell_ticket' as never, label: '' },
514
515
  ]
515
516
  }
516
517
  handleSellTicket={handleSellTicket}
@@ -0,0 +1,35 @@
1
+ import React from "react"
2
+
3
+ const InfoIcon = () => (
4
+ <svg
5
+ xmlns="http://www.w3.org/2000/svg"
6
+ width="17"
7
+ height="17"
8
+ viewBox="0 0 17 17"
9
+ fill="none"
10
+ >
11
+ <circle
12
+ cx="8.5"
13
+ cy="8.5"
14
+ r="8"
15
+ stroke="black"
16
+ strokeWidth="1"
17
+ />
18
+ <rect
19
+ x="7.5"
20
+ y="4"
21
+ width="2"
22
+ height="2"
23
+ fill="black"
24
+ />
25
+ <rect
26
+ x="7.5"
27
+ y="7"
28
+ width="2"
29
+ height="5"
30
+ fill="black"
31
+ />
32
+ </svg>
33
+ )
34
+
35
+ export default InfoIcon
@@ -2,10 +2,17 @@ import './style.css'
2
2
 
3
3
  import _get from 'lodash/get'
4
4
  import _sortBy from 'lodash/sortBy'
5
- import React, { ReactNode } from 'react'
5
+ import React, { ReactNode, useState } from 'react'
6
6
 
7
+ import InfoIcon from './InfoIcon'
7
8
  import { TicketRow } from './TicketRow'
8
9
 
10
+ function decodeHTML(html: string): string {
11
+ const textArea = document.createElement("textarea")
12
+ textArea.innerHTML = html
13
+ return textArea.value
14
+ }
15
+
9
16
  interface ITicketsSectionProps {
10
17
  event: any;
11
18
  ticketsList: any;
@@ -20,6 +27,7 @@ interface ITicketsSectionProps {
20
27
  showGroupNameBlock?: boolean;
21
28
  currencySybmol?: string;
22
29
  isSeatMapAllowed?: boolean;
30
+ descriptionTrigger?: "click" | "hover";
23
31
  }
24
32
 
25
33
  export const TicketsSection = ({
@@ -36,13 +44,21 @@ export const TicketsSection = ({
36
44
  currencySybmol,
37
45
  isSeatMapAllowed,
38
46
  tableTickets,
47
+ descriptionTrigger = 'click',
39
48
  }: ITicketsSectionProps) => {
40
- const symbol = _get(event, "currency.symbol")
49
+ const symbol = _get(event, 'currency.symbol')
41
50
  const sortedTicketsList = sortBySoldOut
42
51
  ? _sortBy(_sortBy(ticketsList, 'sortOrder'), 'soldOut')
43
52
  : _sortBy(ticketsList, 'sortOrder')
44
53
  const showGroup = !!sortedTicketsList.find(ticket => ticket.groupName)
45
- const priceSymbol = currencySybmol ? currencySybmol : symbol
54
+ const priceSymbol = currencySybmol || symbol
55
+
56
+ const [visibleDescription, setVisibleDescription] = useState<string | null>(null)
57
+
58
+ const handleDescriptionToggle = (ticketId: string) => {
59
+ setVisibleDescription(current => (current === ticketId ? null : ticketId))
60
+ }
61
+
46
62
  return (
47
63
  <>
48
64
  {!hideTicketsHeader && ticketsHeaderComponent}
@@ -62,11 +78,7 @@ export const TicketsSection = ({
62
78
  }
63
79
 
64
80
  const ticketIsFree = +ticket.price === 0
65
- const ticketPriceElem = isSoldOut
66
- ? 'SOLD OUT'
67
- : ticketIsFree
68
- ? 'FREE'
69
- : ticketPrice
81
+ const ticketPriceElem = isSoldOut ? 'SOLD OUT' : ticketIsFree ? 'FREE' : ticketPrice
70
82
  const isNewGroupTicket = ticket?.groupName !== arr[i - 1]?.groupName
71
83
 
72
84
  return (
@@ -79,7 +91,36 @@ export const TicketsSection = ({
79
91
  <div className={`event-detail__tier ${isSoldOut ? 'disabled' : ''}`}>
80
92
  <div className="event-detail__tier-name">
81
93
  {ticket.displayName || ticket.name}
94
+ {ticket.descriptionRich && (
95
+ <span
96
+ aria-hidden
97
+ className="info-icon"
98
+ onClick={
99
+ descriptionTrigger === 'click'
100
+ ? () => handleDescriptionToggle(ticket.id)
101
+ : undefined
102
+ }
103
+ onMouseEnter={
104
+ descriptionTrigger === 'hover'
105
+ ? () => setVisibleDescription(ticket.id)
106
+ : undefined
107
+ }
108
+ onMouseLeave={
109
+ descriptionTrigger === 'hover'
110
+ ? () => setVisibleDescription(null)
111
+ : undefined
112
+ }
113
+ style={{ marginLeft: 8, cursor: 'pointer', display: "flex" }}
114
+ >
115
+ <InfoIcon />
116
+ </span>
117
+ )}
82
118
  </div>
119
+ {visibleDescription === ticket.id && (
120
+ <div className="ticket-description">
121
+ <div dangerouslySetInnerHTML={{ __html: decodeHTML(ticket.descriptionRich) }} />
122
+ </div>
123
+ )}
83
124
  <div className="event-tickets-container">
84
125
  <div className="event-detail__tier-price">
85
126
  {ticketIsDiscounted && <p className="old-price">{ticketOldPrice}</p>}
@@ -124,8 +165,8 @@ export const TicketsSection = ({
124
165
  const ticketPriceElem = isSoldOut
125
166
  ? 'SOLD OUT'
126
167
  : ticketIsFree
127
- ? 'FREE'
128
- : ticketPrice
168
+ ? 'FREE'
169
+ : ticketPrice
129
170
  const isNewGroupTicket = ticket?.groupName !== arr[i - 1]?.groupName
130
171
 
131
172
  return (
@@ -139,7 +180,36 @@ export const TicketsSection = ({
139
180
  <div className={`event-detail__tier ${isSoldOut ? 'disabled' : ''}`}>
140
181
  <div className="event-detail__tier-name">
141
182
  {ticket.displayName || ticket.name}
183
+ {ticket.descriptionRich && (
184
+ <span
185
+ aria-hidden
186
+ className="info-icon"
187
+ onClick={
188
+ descriptionTrigger === 'click'
189
+ ? () => handleDescriptionToggle(ticket.id)
190
+ : undefined
191
+ }
192
+ onMouseEnter={
193
+ descriptionTrigger === 'hover'
194
+ ? () => setVisibleDescription(ticket.id)
195
+ : undefined
196
+ }
197
+ onMouseLeave={
198
+ descriptionTrigger === 'hover'
199
+ ? () => setVisibleDescription(null)
200
+ : undefined
201
+ }
202
+ style={{ marginLeft: 8, cursor: 'pointer', display: "flex" }}
203
+ >
204
+ <InfoIcon />
205
+ </span>
206
+ )}
142
207
  </div>
208
+ {visibleDescription === ticket.id && (
209
+ <div className="ticket-description">
210
+ <div dangerouslySetInnerHTML={{ __html: decodeHTML(ticket.descriptionRich) }} />
211
+ </div>
212
+ )}
143
213
  <div className="event-tickets-container">
144
214
  <div className="event-detail__tier-price">
145
215
  {ticketIsDiscounted && <p className="old-price">{ticketOldPrice}</p>}
@@ -30,7 +30,7 @@ const withCustomFields = (Children: any) => (props: any) => {
30
30
 
31
31
  const getFields = async () => {
32
32
  try {
33
- const eventId = getQueryVariable('event_id') || ''
33
+ const eventId = getQueryVariable('event_id') || getQueryVariable("eventId") || ''
34
34
  const customFields = await getCustomFields(eventId)
35
35
 
36
36
  const orderFieldsKeys = getFieldsKeys(_get(customFields, 'orderFields', []))