@tellescope/react-components 1.244.1 → 1.244.3
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/lib/cjs/Forms/form_responses.js +1 -1
- package/lib/cjs/Forms/form_responses.js.map +1 -1
- package/lib/cjs/Forms/forms.js +1 -1
- package/lib/cjs/Forms/forms.js.map +1 -1
- package/lib/cjs/Forms/forms.v2.js +1 -1
- package/lib/cjs/Forms/forms.v2.js.map +1 -1
- package/lib/cjs/Forms/hooks.d.ts.map +1 -1
- package/lib/cjs/Forms/hooks.js +6 -2
- package/lib/cjs/Forms/hooks.js.map +1 -1
- package/lib/cjs/Forms/inputs.d.ts +1 -1
- package/lib/cjs/Forms/inputs.d.ts.map +1 -1
- package/lib/cjs/Forms/inputs.js +53 -10
- package/lib/cjs/Forms/inputs.js.map +1 -1
- package/lib/cjs/Forms/inputs.v2.d.ts +1 -3
- package/lib/cjs/Forms/inputs.v2.d.ts.map +1 -1
- package/lib/cjs/Forms/inputs.v2.js +3 -37
- package/lib/cjs/Forms/inputs.v2.js.map +1 -1
- package/lib/esm/Forms/form_responses.js +1 -1
- package/lib/esm/Forms/form_responses.js.map +1 -1
- package/lib/esm/Forms/forms.js +1 -1
- package/lib/esm/Forms/forms.js.map +1 -1
- package/lib/esm/Forms/forms.v2.js +1 -1
- package/lib/esm/Forms/forms.v2.js.map +1 -1
- package/lib/esm/Forms/hooks.d.ts.map +1 -1
- package/lib/esm/Forms/hooks.js +6 -2
- package/lib/esm/Forms/hooks.js.map +1 -1
- package/lib/esm/Forms/inputs.d.ts +1 -1
- package/lib/esm/Forms/inputs.d.ts.map +1 -1
- package/lib/esm/Forms/inputs.js +53 -10
- package/lib/esm/Forms/inputs.js.map +1 -1
- package/lib/esm/Forms/inputs.v2.d.ts +1 -3
- package/lib/esm/Forms/inputs.v2.d.ts.map +1 -1
- package/lib/esm/Forms/inputs.v2.js +2 -36
- package/lib/esm/Forms/inputs.v2.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -9
- package/src/Forms/form_responses.tsx +1 -1
- package/src/Forms/forms.tsx +1 -1
- package/src/Forms/forms.v2.tsx +1 -1
- package/src/Forms/hooks.tsx +4 -0
- package/src/Forms/inputs.tsx +53 -9
- package/src/Forms/inputs.v2.tsx +2 -47
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tellescope/react-components",
|
|
3
|
-
"version": "1.244.
|
|
3
|
+
"version": "1.244.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/cjs/index.js",
|
|
6
6
|
"module": "./lib/esm/index.js",
|
|
@@ -51,13 +51,13 @@
|
|
|
51
51
|
"@reduxjs/toolkit": "1.9.0",
|
|
52
52
|
"@stripe/react-stripe-js": "2.9.0",
|
|
53
53
|
"@stripe/stripe-js": "1.52.1",
|
|
54
|
-
"@tellescope/constants": "1.244.
|
|
55
|
-
"@tellescope/sdk": "1.244.
|
|
56
|
-
"@tellescope/types-client": "1.244.
|
|
57
|
-
"@tellescope/types-models": "1.244.
|
|
58
|
-
"@tellescope/types-utilities": "1.244.
|
|
59
|
-
"@tellescope/utilities": "1.244.
|
|
60
|
-
"@tellescope/validation": "1.244.
|
|
54
|
+
"@tellescope/constants": "1.244.3",
|
|
55
|
+
"@tellescope/sdk": "1.244.3",
|
|
56
|
+
"@tellescope/types-client": "1.244.3",
|
|
57
|
+
"@tellescope/types-models": "1.244.3",
|
|
58
|
+
"@tellescope/types-utilities": "1.244.3",
|
|
59
|
+
"@tellescope/utilities": "1.244.3",
|
|
60
|
+
"@tellescope/validation": "1.244.3",
|
|
61
61
|
"css-to-react-native": "3.0.0",
|
|
62
62
|
"draft-js": "0.11.7",
|
|
63
63
|
"draftjs-to-html": "0.9.1",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
85
85
|
"react-native": "^0.65.0 || ^0.66.0 || ^0.67.0 || ^0.68.0 || ^0.71.0"
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "af55a139b881ba782bb99ed493e8c1ba2a0112e6",
|
|
88
88
|
"publishConfig": {
|
|
89
89
|
"access": "public"
|
|
90
90
|
}
|
|
@@ -49,7 +49,7 @@ export const ResponseAnswer = ({ formResponse, fieldId, isHTML, answer: a, print
|
|
|
49
49
|
)}
|
|
50
50
|
</div>
|
|
51
51
|
)
|
|
52
|
-
: a.value === '_question_group' ? <></>
|
|
52
|
+
: (a.value === '_question_group' || a.type === 'Question Group') ? <></>
|
|
53
53
|
: a.type === 'ranking'
|
|
54
54
|
? <ol style={{ margin: 0 }}>
|
|
55
55
|
{a.value.map((t, i) =>
|
package/src/Forms/forms.tsx
CHANGED
|
@@ -326,7 +326,7 @@ export const QuestionForField = ({
|
|
|
326
326
|
<Stripe enduserId={enduserId} field={field} value={value.answer.value as string} onChange={onFieldChange as ChangeHandler<any>} setCustomerId={setCustomerId} form={form} responses={responses} enduser={enduser} />
|
|
327
327
|
)
|
|
328
328
|
: field.type === 'Chargebee' ? (
|
|
329
|
-
<Chargebee field={field} value={value.answer.value as any} onChange={onFieldChange as ChangeHandler<'Chargebee'>} setCustomerId={setCustomerId} form={form} />
|
|
329
|
+
<Chargebee field={field} value={value.answer.value as any} onChange={onFieldChange as ChangeHandler<'Chargebee'>} setCustomerId={setCustomerId} form={form} responses={responses} />
|
|
330
330
|
)
|
|
331
331
|
: field.type === 'stringLong' ? (
|
|
332
332
|
<StringLong field={field} disabled={value.disabled} value={value.answer.value as string} onChange={onFieldChange as ChangeHandler<'string' | 'stringLong'>} form={form} />
|
package/src/Forms/forms.v2.tsx
CHANGED
|
@@ -336,7 +336,7 @@ export const QuestionForField = ({
|
|
|
336
336
|
<Stripe enduserId={enduserId} field={field} value={value.answer.value as string} onChange={onFieldChange as ChangeHandler<any>} setCustomerId={setCustomerId} form={form} responses={responses} enduser={enduser} />
|
|
337
337
|
)
|
|
338
338
|
: field.type === 'Chargebee' ? (
|
|
339
|
-
<Chargebee field={field} value={value.answer.value as any} onChange={onFieldChange as ChangeHandler<'Chargebee'>} setCustomerId={setCustomerId} form={form} />
|
|
339
|
+
<Chargebee field={field} value={value.answer.value as any} onChange={onFieldChange as ChangeHandler<'Chargebee'>} setCustomerId={setCustomerId} form={form} responses={responses} />
|
|
340
340
|
)
|
|
341
341
|
: field.type === 'stringLong' ? (
|
|
342
342
|
<StringLong field={field} disabled={value.disabled} value={value.answer.value as string} onChange={onFieldChange as ChangeHandler<'string' | 'stringLong'>} form={form} error={!!validationMessage && (!['A response is required', 'A value must be checked', 'A file is required', 'Enter a valid phone number', 'Insurer is required'].includes(validationMessage) || value.touched)} />
|
package/src/Forms/hooks.tsx
CHANGED
|
@@ -701,6 +701,10 @@ export const useTellescopeForm = ({ dontAutoadvance, isPublicForm, form, urlLogi
|
|
|
701
701
|
)
|
|
702
702
|
: f.type === 'Related Contacts'
|
|
703
703
|
? (f.isOptional ? [] : [{ relationships: f?.options?.relatedContactTypes?.length === 1 ? [{ type: f.options.relatedContactTypes[0] as EnduserRelationship['type'], id: ''! } ] : [] }])
|
|
704
|
+
: (f.type === 'date' && f.options?.prefillCurrentDate)
|
|
705
|
+
? new Date()
|
|
706
|
+
: (f.type === 'dateString' && f.options?.prefillCurrentDate)
|
|
707
|
+
? mm_dd_yyyy(new Date())
|
|
704
708
|
: '' as any // null flag that the response was not filled out
|
|
705
709
|
)
|
|
706
710
|
),
|
package/src/Forms/inputs.tsx
CHANGED
|
@@ -5176,22 +5176,30 @@ export const RichTextInput = ({ field, value, onChange }: FormInputProps<'Rich T
|
|
|
5176
5176
|
<WYSIWYG stopEnterPropagation initialHTML={value} onChange={v => onChange(v, field.id)} style={{ width: '100%' }} editorStyle={{ width: '100%' }} />
|
|
5177
5177
|
)
|
|
5178
5178
|
|
|
5179
|
-
export const ChargeebeeInput = ({ field, value, onChange, setCustomerId }: FormInputProps<'Chargebee'> & {
|
|
5179
|
+
export const ChargeebeeInput = ({ field, value, onChange, setCustomerId, responses }: FormInputProps<'Chargebee'> & {
|
|
5180
5180
|
setCustomerId: React.Dispatch<React.SetStateAction<string | undefined>>,
|
|
5181
5181
|
}) => {
|
|
5182
5182
|
const session = useResolvedSession()
|
|
5183
5183
|
const [url, setUrl] = useState('')
|
|
5184
5184
|
const [error, setError] = useState('')
|
|
5185
|
+
const [verifying, setVerifying] = useState(false)
|
|
5185
5186
|
|
|
5186
5187
|
const [loadCount, setLoadCount] = useState(0)
|
|
5187
5188
|
|
|
5189
|
+
const collectOnly = !!field.options?.chargebeeCollectPaymentMethodOnly
|
|
5190
|
+
|
|
5188
5191
|
const fetchRef = useRef(false)
|
|
5189
5192
|
useEffect(() => {
|
|
5190
5193
|
if (fetchRef.current) return
|
|
5191
5194
|
fetchRef.current = true
|
|
5192
|
-
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
+
|
|
5196
|
+
const addressResponse = responses?.find(r => r.answer?.type === 'Address' && r.answer?.value)
|
|
5197
|
+
const billingAddress = addressResponse?.answer?.type === 'Address' && addressResponse?.answer?.value
|
|
5198
|
+
? addressResponse.answer.value as { addressLineOne?: string, addressLineTwo?: string, city?: string, state?: string, zipCode?: string }
|
|
5199
|
+
: undefined
|
|
5200
|
+
|
|
5201
|
+
session.api.form_responses.chargebee_details({ fieldId: field.id, billingAddress })
|
|
5202
|
+
.then(({ url }) => setUrl(url ?? ''))
|
|
5195
5203
|
.catch(setError)
|
|
5196
5204
|
}, [session])
|
|
5197
5205
|
|
|
@@ -5204,22 +5212,58 @@ export const ChargeebeeInput = ({ field, value, onChange, setCustomerId }: FormI
|
|
|
5204
5212
|
onChange({ url }, field.id)
|
|
5205
5213
|
}, [loadCount, url])
|
|
5206
5214
|
|
|
5215
|
+
const handleVerify = async () => {
|
|
5216
|
+
setVerifying(true)
|
|
5217
|
+
setError('')
|
|
5218
|
+
try {
|
|
5219
|
+
const { hasPaymentMethod } = await session.api.form_responses.chargebee_details({ fieldId: field.id, verify: true })
|
|
5220
|
+
if (hasPaymentMethod) {
|
|
5221
|
+
onChange({ url: 'verified' }, field.id)
|
|
5222
|
+
} else {
|
|
5223
|
+
setError('No payment method found. Please add a card and try again.')
|
|
5224
|
+
}
|
|
5225
|
+
} catch (err: any) {
|
|
5226
|
+
setError(err?.message ?? 'Failed to verify payment method')
|
|
5227
|
+
} finally {
|
|
5228
|
+
setVerifying(false)
|
|
5229
|
+
}
|
|
5230
|
+
}
|
|
5231
|
+
|
|
5207
5232
|
if (value || loadCount === 2) {
|
|
5208
5233
|
return (
|
|
5209
5234
|
<Grid container alignItems="center" wrap="nowrap">
|
|
5210
5235
|
<CheckCircleOutline color="success" />
|
|
5211
5236
|
|
|
5212
5237
|
<Typography sx={{ ml: 1, fontSize: 20 }}>
|
|
5213
|
-
|
|
5238
|
+
{collectOnly
|
|
5239
|
+
? 'Your payment method was saved successfully'
|
|
5240
|
+
: 'Your purchase was successful'
|
|
5241
|
+
}
|
|
5214
5242
|
</Typography>
|
|
5215
5243
|
</Grid>
|
|
5216
5244
|
)
|
|
5217
5245
|
}
|
|
5218
|
-
if (error && typeof error === 'string') return <Typography color="error">{error}</Typography>
|
|
5219
5246
|
if (!url) return <LinearProgress />
|
|
5220
5247
|
return (
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
5248
|
+
<>
|
|
5249
|
+
<iframe src={url} title="Checkout" style={{ border: 'none', width: '100%', height: 700 }}
|
|
5250
|
+
onLoad={() => setLoadCount(l => l + 1)}
|
|
5251
|
+
/>
|
|
5252
|
+
{collectOnly && !field.isOptional &&
|
|
5253
|
+
<Grid container direction="column" alignItems="center" spacing={1} sx={{ mt: 1 }}>
|
|
5254
|
+
<Grid item>
|
|
5255
|
+
<LoadingButton variant="contained" onClick={handleVerify} submitting={verifying} submitText="Done" />
|
|
5256
|
+
</Grid>
|
|
5257
|
+
{error && typeof error === 'string' &&
|
|
5258
|
+
<Grid item>
|
|
5259
|
+
<Typography color="error">{error}</Typography>
|
|
5260
|
+
</Grid>
|
|
5261
|
+
}
|
|
5262
|
+
</Grid>
|
|
5263
|
+
}
|
|
5264
|
+
{!collectOnly && error && typeof error === 'string' &&
|
|
5265
|
+
<Typography color="error">{error}</Typography>
|
|
5266
|
+
}
|
|
5267
|
+
</>
|
|
5224
5268
|
)
|
|
5225
5269
|
}
|
package/src/Forms/inputs.v2.tsx
CHANGED
|
@@ -2654,50 +2654,5 @@ export const RichTextInput = ({ field, value, onChange }: FormInputProps<'Rich T
|
|
|
2654
2654
|
<WYSIWYG stopEnterPropagation initialHTML={value} onChange={v => onChange(v, field.id)} style={{ width: '100%' }} editorStyle={{ width: '100%' }} />
|
|
2655
2655
|
)
|
|
2656
2656
|
|
|
2657
|
-
export
|
|
2658
|
-
|
|
2659
|
-
}) => {
|
|
2660
|
-
const session = useResolvedSession()
|
|
2661
|
-
const [url, setUrl] = useState('')
|
|
2662
|
-
const [error, setError] = useState('')
|
|
2663
|
-
|
|
2664
|
-
const [loadCount, setLoadCount] = useState(0)
|
|
2665
|
-
|
|
2666
|
-
const fetchRef = useRef(false)
|
|
2667
|
-
useEffect(() => {
|
|
2668
|
-
if (fetchRef.current) return
|
|
2669
|
-
fetchRef.current = true
|
|
2670
|
-
|
|
2671
|
-
session.api.form_responses.chargebee_details({ fieldId: field.id })
|
|
2672
|
-
.then(({ url }) => setUrl(url))
|
|
2673
|
-
.catch(setError)
|
|
2674
|
-
}, [session])
|
|
2675
|
-
|
|
2676
|
-
const loadAnswerRef = useRef(false)
|
|
2677
|
-
useEffect(() => {
|
|
2678
|
-
if (loadCount !== 2) return
|
|
2679
|
-
if (loadAnswerRef.current) return
|
|
2680
|
-
loadAnswerRef.current = true
|
|
2681
|
-
|
|
2682
|
-
onChange({ url }, field.id)
|
|
2683
|
-
}, [loadCount, url])
|
|
2684
|
-
|
|
2685
|
-
if (value || loadCount === 2) {
|
|
2686
|
-
return (
|
|
2687
|
-
<Grid container alignItems="center" wrap="nowrap">
|
|
2688
|
-
<CheckCircleOutline color="success" />
|
|
2689
|
-
|
|
2690
|
-
<Typography sx={{ ml: 1, fontSize: 20 }}>
|
|
2691
|
-
Your purchase was successful
|
|
2692
|
-
</Typography>
|
|
2693
|
-
</Grid>
|
|
2694
|
-
)
|
|
2695
|
-
}
|
|
2696
|
-
if (error && typeof error === 'string') return <Typography color="error">{error}</Typography>
|
|
2697
|
-
if (!url) return <LinearProgress />
|
|
2698
|
-
return (
|
|
2699
|
-
<iframe src={url} title="Checkout" style={{ border: 'none', width: '100%', height: 700 }}
|
|
2700
|
-
onLoad={() => setLoadCount(l => l + 1)}
|
|
2701
|
-
/>
|
|
2702
|
-
)
|
|
2703
|
-
}
|
|
2657
|
+
// Re-export from V1 to follow DRY principles
|
|
2658
|
+
export { ChargeebeeInput } from './inputs'
|