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

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.12",
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
+ }
@@ -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>}