tf-checkout-react-native 2.0.0-beta.17 → 2.0.0-beta.18
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 +7 -0
- package/dist/index.d.mts +78 -9
- package/dist/index.d.ts +78 -9
- package/dist/index.js +2640 -2129
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2336 -1818
- package/dist/index.mjs.map +1 -1
- package/package.json +19 -1
- package/src/sections/Accommodation.tsx +3 -2
- package/src/sections/AddOns.tsx +4 -3
- package/src/sections/Bundles.tsx +4 -3
- package/src/sections/Payment.tsx +19 -8
- package/src/sections/Tickets.tsx +26 -99
- package/src/sections/WaiverSigning.tsx +2 -2
- package/src/ui/RichText.tsx +187 -0
- package/src/ui/WaitingListForm.tsx +139 -0
- package/src/ui/index.ts +1 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Alert, Linking, StyleSheet, View } from 'react-native'
|
|
3
|
+
import {
|
|
4
|
+
createTranslator,
|
|
5
|
+
hooks,
|
|
6
|
+
waitingListQuantityCap,
|
|
7
|
+
type EventWaitingList,
|
|
8
|
+
type WaitingListEntry,
|
|
9
|
+
type WaitingListPrefill,
|
|
10
|
+
} from 'tf-checkout-shared'
|
|
11
|
+
import { Field, Input } from './Field'
|
|
12
|
+
import { Button, ErrorText, MutedText, SectionHeader } from './primitives'
|
|
13
|
+
import { Select } from './Select'
|
|
14
|
+
|
|
15
|
+
export const WaitingListForm = ({
|
|
16
|
+
eventId,
|
|
17
|
+
definition,
|
|
18
|
+
onJoin,
|
|
19
|
+
prefill,
|
|
20
|
+
}: {
|
|
21
|
+
eventId: string
|
|
22
|
+
definition?: EventWaitingList
|
|
23
|
+
onJoin: (entry: WaitingListEntry) => Promise<void>
|
|
24
|
+
prefill?: WaitingListPrefill
|
|
25
|
+
}) => {
|
|
26
|
+
const tr = createTranslator()
|
|
27
|
+
const flow = hooks.useWaitingListForm(eventId, definition, onJoin, prefill)
|
|
28
|
+
if (definition?.state === 'closed')
|
|
29
|
+
return <MutedText>{tr('tickets.waitingListClosed')}</MutedText>
|
|
30
|
+
if (definition?.state === 'unsupported' && definition.eventUrl)
|
|
31
|
+
return (
|
|
32
|
+
<Button
|
|
33
|
+
variant="ghost"
|
|
34
|
+
onPress={() =>
|
|
35
|
+
void Linking.openURL(definition.eventUrl).catch(() =>
|
|
36
|
+
Alert.alert('Couldn’t open link', 'Please try again.')
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
>
|
|
40
|
+
{tr('tickets.waitingListWebsite')}
|
|
41
|
+
</Button>
|
|
42
|
+
)
|
|
43
|
+
if (definition?.state !== 'open') return null
|
|
44
|
+
if (flow.done) return <MutedText>{tr('tickets.waitingListJoined')}</MutedText>
|
|
45
|
+
const cap = waitingListQuantityCap(definition, flow.draft.ticketTypeId)
|
|
46
|
+
return (
|
|
47
|
+
<View style={styles.form}>
|
|
48
|
+
<SectionHeader title={tr('tickets.joinWaitingList')} />
|
|
49
|
+
<Field label={tr('tickets.firstName')}>
|
|
50
|
+
<Input
|
|
51
|
+
accessibilityLabel={tr('tickets.firstName')}
|
|
52
|
+
autoComplete="given-name"
|
|
53
|
+
textContentType="givenName"
|
|
54
|
+
autoCapitalize="words"
|
|
55
|
+
value={flow.draft.firstName}
|
|
56
|
+
editable={!flow.busy}
|
|
57
|
+
onChangeText={(firstName) => flow.update({ firstName })}
|
|
58
|
+
/>
|
|
59
|
+
</Field>
|
|
60
|
+
<Field label={tr('tickets.lastName')}>
|
|
61
|
+
<Input
|
|
62
|
+
accessibilityLabel={tr('tickets.lastName')}
|
|
63
|
+
autoComplete="family-name"
|
|
64
|
+
textContentType="familyName"
|
|
65
|
+
autoCapitalize="words"
|
|
66
|
+
value={flow.draft.lastName}
|
|
67
|
+
editable={!flow.busy}
|
|
68
|
+
onChangeText={(lastName) => flow.update({ lastName })}
|
|
69
|
+
/>
|
|
70
|
+
</Field>
|
|
71
|
+
<Field label={tr('tickets.email')}>
|
|
72
|
+
<Input
|
|
73
|
+
accessibilityLabel={tr('tickets.email')}
|
|
74
|
+
autoComplete="email"
|
|
75
|
+
textContentType="emailAddress"
|
|
76
|
+
value={flow.draft.email}
|
|
77
|
+
keyboardType="email-address"
|
|
78
|
+
autoCapitalize="none"
|
|
79
|
+
editable={!flow.busy}
|
|
80
|
+
onChangeText={(email) => flow.update({ email })}
|
|
81
|
+
/>
|
|
82
|
+
</Field>
|
|
83
|
+
{!definition.autoSelectTicketId && definition.ticketTypes.length > 0 ? (
|
|
84
|
+
<Field label={tr('tickets.waitingListTicket')}>
|
|
85
|
+
<Select
|
|
86
|
+
value={flow.draft.ticketTypeId}
|
|
87
|
+
disabled={flow.busy}
|
|
88
|
+
onChange={(ticketTypeId) => flow.update({ ticketTypeId, quantity: '' })}
|
|
89
|
+
options={[
|
|
90
|
+
...(definition.allowAnyTicket
|
|
91
|
+
? [{ value: '', label: tr('tickets.waitingListAny') }]
|
|
92
|
+
: []),
|
|
93
|
+
...definition.ticketTypes.map((choice) => ({
|
|
94
|
+
value: choice.id,
|
|
95
|
+
label: choice.name,
|
|
96
|
+
})),
|
|
97
|
+
]}
|
|
98
|
+
/>
|
|
99
|
+
</Field>
|
|
100
|
+
) : null}
|
|
101
|
+
{definition.showQuantity && definition.fixedQuantity === undefined ? (
|
|
102
|
+
<Field
|
|
103
|
+
label={tr('tickets.waitingListQuantity')}
|
|
104
|
+
error={
|
|
105
|
+
flow.quantityInvalid
|
|
106
|
+
? tr(
|
|
107
|
+
cap === 0
|
|
108
|
+
? 'tickets.waitingListNoQuantity'
|
|
109
|
+
: 'tickets.waitingListInvalidQuantity',
|
|
110
|
+
{ max: cap }
|
|
111
|
+
)
|
|
112
|
+
: undefined
|
|
113
|
+
}
|
|
114
|
+
>
|
|
115
|
+
<Input
|
|
116
|
+
accessibilityLabel={tr('tickets.waitingListQuantity')}
|
|
117
|
+
keyboardType="number-pad"
|
|
118
|
+
value={flow.draft.quantity}
|
|
119
|
+
placeholder={tr('tickets.waitingListQuantityHint')}
|
|
120
|
+
editable={!flow.busy}
|
|
121
|
+
invalid={flow.quantityInvalid}
|
|
122
|
+
onChangeText={(quantity) => flow.update({ quantity })}
|
|
123
|
+
/>
|
|
124
|
+
</Field>
|
|
125
|
+
) : null}
|
|
126
|
+
<Button
|
|
127
|
+
variant="ghost"
|
|
128
|
+
loading={flow.busy}
|
|
129
|
+
disabled={!flow.canSubmit}
|
|
130
|
+
onPress={() => void flow.submit()}
|
|
131
|
+
>
|
|
132
|
+
{tr('tickets.joinWaitingList')}
|
|
133
|
+
</Button>
|
|
134
|
+
{flow.error ? <ErrorText>{flow.error}</ErrorText> : null}
|
|
135
|
+
</View>
|
|
136
|
+
)
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const styles = StyleSheet.create({ form: { gap: 8 } })
|
package/src/ui/index.ts
CHANGED