@originallyus/feedback-rn-sdk 4.0.0-beta.2 → 4.0.0-beta.4
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/typescript/AIAFeedback.d.ts +1 -1
- package/lib/typescript/AIAFeedback.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +16 -16
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/service/feedbackService.d.ts +1 -1
- package/lib/typescript/service/feedbackService.d.ts.map +1 -1
- package/lib/typescript/utils/networking.d.ts +2 -2
- package/lib/typescript/utils/networking.d.ts.map +1 -1
- package/package.json +5 -3
- package/src/AIAContentUsefulness.tsx +0 -296
- package/src/AIAFeedback.tsx +0 -354
- package/src/AIAFeedbackForm.tsx +0 -267
- package/src/AIAFeedbackSplash.tsx +0 -49
- package/src/AIAFeedbackStyles.ts +0 -311
- package/src/AIAFeedbackSuccess.tsx +0 -67
- package/src/assets/CheckIcon.tsx +0 -18
- package/src/assets/CloseIcon.tsx +0 -18
- package/src/assets/ErrorIcon.tsx +0 -18
- package/src/assets/PlusIcon.tsx +0 -18
- package/src/assets/StarIcon.tsx +0 -18
- package/src/component/Button.tsx +0 -68
- package/src/component/ButtonSubmit.tsx +0 -335
- package/src/component/Input.tsx +0 -288
- package/src/component/MultiSelectButtons.tsx +0 -272
- package/src/component/README.md +0 -215
- package/src/component/READMEVI.md +0 -192
- package/src/component/Rating.tsx +0 -248
- package/src/component/RatingNumber.tsx +0 -421
- package/src/component/Textarea.tsx +0 -282
- package/src/component/YesNoButtons.tsx +0 -236
- package/src/index.tsx +0 -33
- package/src/service/feedbackService.ts +0 -108
- package/src/utils/common.ts +0 -241
- package/src/utils/constants.ts +0 -60
- package/src/utils/index.ts +0 -167
- package/src/utils/networking.ts +0 -134
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AIAFeedback.d.ts","sourceRoot":"","sources":["../../src/AIAFeedback.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAC,KAAK,WAAW,EAAW,
|
|
1
|
+
{"version":3,"file":"AIAFeedback.d.ts","sourceRoot":"","sources":["../../src/AIAFeedback.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAC,KAAK,WAAW,EAAW,0BAAyB;AAG5D,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACpD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAA;CAC7B;AAED,MAAM,WAAW,cAAc;IAC9B,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE;QAAC,UAAU,CAAC,EAAE,OAAO,CAAC;QAAC,WAAW,CAAC,EAAE,GAAG,CAAA;KAAC,KAAK,IAAI,CAAA;IAC1F,IAAI,EAAE,MAAM,IAAI,CAAA;CAChB;AAED,QAAA,MAAM,WAAW,0HAqUf,CAAA;AAEF,eAAe,WAAW,CAAA"}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
export { Button } from
|
|
2
|
-
export type { ButtonProps } from
|
|
3
|
-
export { default as RatingNumber } from
|
|
4
|
-
export type { RatingNumberProps, RatingNumberSize } from
|
|
5
|
-
export { default as Rating } from
|
|
6
|
-
export type { RatingProps } from
|
|
7
|
-
export { default as Textarea } from
|
|
8
|
-
export type { TextareaProps } from
|
|
9
|
-
export { default as Input } from
|
|
10
|
-
export type { InputProps } from
|
|
11
|
-
export { default as ButtonSubmit } from
|
|
12
|
-
export type { ButtonSubmitProps, ButtonSubmitVariant } from
|
|
13
|
-
export { default as YesNoButtons } from
|
|
14
|
-
export type { YesNoButtonsProps, YesNoValue, YesNoSelectedVariant } from
|
|
15
|
-
export { default as MultiSelectButtons } from
|
|
16
|
-
export type { MultiSelectButtonsProps, MultiSelectOption, MultiSelectSelectedVariant, } from
|
|
1
|
+
export { Button } from "./component/Button";
|
|
2
|
+
export type { ButtonProps } from "./component/Button";
|
|
3
|
+
export { default as RatingNumber } from "./component/RatingNumber";
|
|
4
|
+
export type { RatingNumberProps, RatingNumberSize } from "./component/RatingNumber";
|
|
5
|
+
export { default as Rating } from "./component/Rating";
|
|
6
|
+
export type { RatingProps } from "./component/Rating";
|
|
7
|
+
export { default as Textarea } from "./component/Textarea";
|
|
8
|
+
export type { TextareaProps } from "./component/Textarea";
|
|
9
|
+
export { default as Input } from "./component/Input";
|
|
10
|
+
export type { InputProps } from "./component/Input";
|
|
11
|
+
export { default as ButtonSubmit } from "./component/ButtonSubmit";
|
|
12
|
+
export type { ButtonSubmitProps, ButtonSubmitVariant } from "./component/ButtonSubmit";
|
|
13
|
+
export { default as YesNoButtons } from "./component/YesNoButtons";
|
|
14
|
+
export type { YesNoButtonsProps, YesNoValue, YesNoSelectedVariant } from "./component/YesNoButtons";
|
|
15
|
+
export { default as MultiSelectButtons } from "./component/MultiSelectButtons";
|
|
16
|
+
export type { MultiSelectButtonsProps, MultiSelectOption, MultiSelectSelectedVariant, } from "./component/MultiSelectButtons";
|
|
17
17
|
export { default as AIAFeedback } from './AIAFeedback';
|
|
18
18
|
export type { AIAFeedbackProps, AIAFeedbackRef } from './AIAFeedback';
|
|
19
19
|
export { default as AIAContentUsefulness } from './AIAContentUsefulness';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,2BAAyB;AACxC,YAAY,EAAC,WAAW,EAAC,2BAAyB;AAElD,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,iCAA+B;AAC/D,YAAY,EAAC,iBAAiB,EAAE,gBAAgB,EAAC,iCAA+B;AAEhF,OAAO,EAAC,OAAO,IAAI,MAAM,EAAC,2BAAyB;AACnD,YAAY,EAAC,WAAW,EAAC,2BAAyB;AAElD,OAAO,EAAC,OAAO,IAAI,QAAQ,EAAC,6BAA2B;AACvD,YAAY,EAAC,aAAa,EAAC,6BAA2B;AAEtD,OAAO,EAAC,OAAO,IAAI,KAAK,EAAC,0BAAwB;AACjD,YAAY,EAAC,UAAU,EAAC,0BAAwB;AAEhD,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,iCAA+B;AAC/D,YAAY,EAAC,iBAAiB,EAAE,mBAAmB,EAAC,iCAA+B;AAEnF,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,iCAA+B;AAC/D,YAAY,EAAC,iBAAiB,EAAE,UAAU,EAAE,oBAAoB,EAAC,iCAA+B;AAEhG,OAAO,EAAC,OAAO,IAAI,kBAAkB,EAAC,uCAAqC;AAC3E,YAAY,EACX,uBAAuB,EACvB,iBAAiB,EACjB,0BAA0B,GAC1B,uCAAqC;AAEtC,OAAO,EAAC,OAAO,IAAI,WAAW,EAAC,MAAM,eAAe,CAAA;AACpD,YAAY,EAAC,gBAAgB,EAAE,cAAc,EAAC,MAAM,eAAe,CAAA;AAEnE,OAAO,EAAC,OAAO,IAAI,oBAAoB,EAAC,MAAM,wBAAwB,CAAA;AACtE,YAAY,EAAC,yBAAyB,EAAC,MAAM,wBAAwB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feedbackService.d.ts","sourceRoot":"","sources":["../../../src/service/feedbackService.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,WAAW,EAAC,
|
|
1
|
+
{"version":3,"file":"feedbackService.d.ts","sourceRoot":"","sources":["../../../src/service/feedbackService.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,WAAW,EAAC,2BAAyB;AAElD,MAAM,WAAW,cAAc;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,OAAO,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,GAAG,CAAA;IACb,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,MAAM,CAAA;IACd,gBAAgB,EAAE,MAAM,CAAA;IACxB,SAAS,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,mBAAmB;IACnC,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,OAAO,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,GAAG,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,WAAW;IAC3B,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,WAAW,CAAC,EAAE,GAAG,CAAA;CACjB;AAED,KAAK,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,KAAK,OAAO,CAAA;AAIpE,eAAO,MAAM,eAAe;uBACR,YAAY;qBAQd,MAAM,YAAY,WAAW,KAAG,OAAO;2BAQjC,WAAW,YAAY,CAAC,QAAQ,EAAE,GAAG,KAAK,IAAI;2BAexC,cAAc,WAAW,WAAW,KAAG,OAAO,CAAC,GAAG,CAAC;qCAsBzC,mBAAmB,WAAW,WAAW,KAAG,OAAO,CAAC,GAAG,CAAC;CAqB/F,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"networking.d.ts","sourceRoot":"","sources":["../../../src/utils/networking.ts"],"names":[],"mappings":"AACA,
|
|
1
|
+
{"version":3,"file":"networking.d.ts","sourceRoot":"","sources":["../../../src/utils/networking.ts"],"names":[],"mappings":"AACA,YAAgB;AAChB,OAAO,EAAW,KAAK,WAAW,EAAC,oBAAyB;AAG5D,MAAM,WAAW,iBAAiB;IACjC,YAAY,EAAE,OAAO,CAAA;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,GAAG,CAAA;IACV,SAAS,EAAE,CAAC,QAAQ,EAAE,GAAG,KAAK,IAAI,CAAA;IAClC,OAAO,CAAC,EAAE,WAAW,CAAA;CACrB;AAID,QAAA,MAAM,WAAW,GAAU,mDAAiD,iBAAiB,8BAoH5F,CAAA;AAED,OAAO,EAAC,WAAW,EAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@originallyus/feedback-rn-sdk",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.4",
|
|
4
4
|
"description": "A cross-platform Feedback component for React Native.",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/index.d.ts",
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
"./package.json": "./package.json"
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
|
-
"src",
|
|
17
16
|
"lib",
|
|
18
17
|
"android",
|
|
19
18
|
"ios",
|
|
@@ -34,6 +33,7 @@
|
|
|
34
33
|
"scripts": {
|
|
35
34
|
"example": "yarn workspace @originallyus/feedback-rn-sdk-example start",
|
|
36
35
|
"clean": "del-cli lib",
|
|
36
|
+
"postinstall": "ts-patch install",
|
|
37
37
|
"prepare": "bob build",
|
|
38
38
|
"typecheck": "tsc",
|
|
39
39
|
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
@@ -92,7 +92,9 @@
|
|
|
92
92
|
"react-native-svg": "^15.15.3",
|
|
93
93
|
"react-test-renderer": "19.1.0",
|
|
94
94
|
"release-it": "^19.0.4",
|
|
95
|
-
"
|
|
95
|
+
"ts-patch": "^3.3.0",
|
|
96
|
+
"typescript": "^5.9.2",
|
|
97
|
+
"typescript-transform-paths": "^3.5.6"
|
|
96
98
|
},
|
|
97
99
|
"peerDependencies": {
|
|
98
100
|
"expo-haptics": "*",
|
|
@@ -1,296 +0,0 @@
|
|
|
1
|
-
import React, {useState, useEffect, useCallback} from 'react'
|
|
2
|
-
import {View, Text, StyleSheet, ActivityIndicator, type StyleProp, type ViewStyle} from 'react-native'
|
|
3
|
-
import {feedbackService} from '@service/feedbackService'
|
|
4
|
-
import type {SubmitSelectionData, SubmitFormData} from '@service/feedbackService'
|
|
5
|
-
import type {InitOptions} from './utils/constants'
|
|
6
|
-
import {PRIMARY_COLOR, TEXT_DARK, BORDER_DEFAULT} from './utils/constants'
|
|
7
|
-
import YesNoButtons from './component/YesNoButtons'
|
|
8
|
-
import Rating from './component/Rating'
|
|
9
|
-
import MultiSelectButtons from './component/MultiSelectButtons'
|
|
10
|
-
import Textarea from './component/Textarea'
|
|
11
|
-
import ButtonSubmit from './component/ButtonSubmit'
|
|
12
|
-
|
|
13
|
-
export interface AIAContentUsefulnessProps {
|
|
14
|
-
slug: string
|
|
15
|
-
options: InitOptions
|
|
16
|
-
style?: StyleProp<ViewStyle>
|
|
17
|
-
initialVisible?: boolean
|
|
18
|
-
onSuccess?: (response: any) => void
|
|
19
|
-
onError?: (error: Error) => void
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
type Step = 'PROMPT' | 'LOADING' | 'FORM' | 'SUCCESS'
|
|
23
|
-
|
|
24
|
-
const AIAContentUsefulness: React.FC<AIAContentUsefulnessProps> = ({
|
|
25
|
-
slug,
|
|
26
|
-
options,
|
|
27
|
-
style,
|
|
28
|
-
initialVisible = false,
|
|
29
|
-
onSuccess,
|
|
30
|
-
onError,
|
|
31
|
-
}) => {
|
|
32
|
-
const [visible, setVisible] = useState(initialVisible)
|
|
33
|
-
const [step, setStep] = useState<Step>('PROMPT')
|
|
34
|
-
const [formData, setFormData] = useState<any>(null)
|
|
35
|
-
const [loading, setLoading] = useState(true)
|
|
36
|
-
const [submitting, setSubmitting] = useState(false)
|
|
37
|
-
const [containerWidth, setContainerWidth] = useState(0)
|
|
38
|
-
|
|
39
|
-
// Form values
|
|
40
|
-
const [rating, setRating] = useState(0)
|
|
41
|
-
const [selectedOptions, setSelectedOptions] = useState<string[]>([])
|
|
42
|
-
const [freeText, setFreeText] = useState('')
|
|
43
|
-
|
|
44
|
-
const loadForm = useCallback(() => {
|
|
45
|
-
setLoading(true)
|
|
46
|
-
feedbackService.requestForm({...options, formSlug: slug}, res => {
|
|
47
|
-
setLoading(false)
|
|
48
|
-
if (res && !res.error) {
|
|
49
|
-
setFormData(res)
|
|
50
|
-
} else {
|
|
51
|
-
onError?.(new Error(res?.error || 'Failed to load form'))
|
|
52
|
-
}
|
|
53
|
-
})
|
|
54
|
-
}, [slug, options, onError])
|
|
55
|
-
|
|
56
|
-
useEffect(() => {
|
|
57
|
-
if (visible) {
|
|
58
|
-
loadForm()
|
|
59
|
-
}
|
|
60
|
-
}, [visible, loadForm])
|
|
61
|
-
|
|
62
|
-
useEffect(() => {
|
|
63
|
-
const unsubscribe = feedbackService.onShow((triggerSlug, showOptions) => {
|
|
64
|
-
if (triggerSlug === slug && !showOptions?.forceModal) {
|
|
65
|
-
setVisible(true)
|
|
66
|
-
return true // Handled
|
|
67
|
-
}
|
|
68
|
-
return false
|
|
69
|
-
})
|
|
70
|
-
return unsubscribe
|
|
71
|
-
}, [slug])
|
|
72
|
-
|
|
73
|
-
const onPromptSelect = async (value: 'yes' | 'no') => {
|
|
74
|
-
setStep('LOADING')
|
|
75
|
-
try {
|
|
76
|
-
const selectionData: SubmitSelectionData = {
|
|
77
|
-
slug,
|
|
78
|
-
debug: options.debug || false,
|
|
79
|
-
event_tag: options.eventTag || '',
|
|
80
|
-
metadata: options.metadata || {},
|
|
81
|
-
rating: value === 'yes' ? 2 : 1,
|
|
82
|
-
request_id: formData?.id || '',
|
|
83
|
-
}
|
|
84
|
-
const res = await feedbackService.submitSelection(selectionData, options)
|
|
85
|
-
if (res && !res.error) {
|
|
86
|
-
// Hide itself and trigger modal for the rest of the flow
|
|
87
|
-
setVisible(false)
|
|
88
|
-
feedbackService.emitShow(slug, {forceModal: true, initialData: res})
|
|
89
|
-
} else {
|
|
90
|
-
setStep('PROMPT')
|
|
91
|
-
onError?.(new Error(res?.error || 'Failed to submit selection'))
|
|
92
|
-
}
|
|
93
|
-
} catch (err) {
|
|
94
|
-
setStep('PROMPT')
|
|
95
|
-
onError?.(err as Error)
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const onSubmitDetails = async () => {
|
|
100
|
-
setSubmitting(true)
|
|
101
|
-
try {
|
|
102
|
-
const submitData: SubmitFormData = {
|
|
103
|
-
slug: formData.slug || slug,
|
|
104
|
-
debug: options.debug || false,
|
|
105
|
-
event_tag: options.eventTag || '',
|
|
106
|
-
metadata: options.metadata || {},
|
|
107
|
-
request_id: formData.id || '',
|
|
108
|
-
rating: rating,
|
|
109
|
-
selected_options: selectedOptions.join(','),
|
|
110
|
-
free_text: freeText,
|
|
111
|
-
}
|
|
112
|
-
const res = await feedbackService.submitForm(submitData, options)
|
|
113
|
-
if (res && !res.error) {
|
|
114
|
-
setStep('SUCCESS')
|
|
115
|
-
onSuccess?.(res)
|
|
116
|
-
} else {
|
|
117
|
-
onError?.(new Error(res?.error || 'Failed to submit feedback'))
|
|
118
|
-
}
|
|
119
|
-
} catch (err) {
|
|
120
|
-
onError?.(err as Error)
|
|
121
|
-
} finally {
|
|
122
|
-
setSubmitting(false)
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
const getThemeColor = (key: string, fallback: string) => {
|
|
127
|
-
return formData?.theme?.[key] || fallback
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
const textAlign = formData?.alignment === 'left' ? 'left' : 'center'
|
|
131
|
-
const align: any = formData?.alignment === 'left' ? 'flex-start' : 'center'
|
|
132
|
-
|
|
133
|
-
if (!visible) return null
|
|
134
|
-
|
|
135
|
-
if (loading) {
|
|
136
|
-
return (
|
|
137
|
-
<View style={[styles.container, style, styles.center]}>
|
|
138
|
-
<ActivityIndicator color={PRIMARY_COLOR} />
|
|
139
|
-
</View>
|
|
140
|
-
)
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
if (!formData) return null
|
|
144
|
-
|
|
145
|
-
const renderPrompt = () => (
|
|
146
|
-
<YesNoButtons
|
|
147
|
-
question={formData.question}
|
|
148
|
-
value={null}
|
|
149
|
-
yesLabel={formData.positive_feedback_button || 'Yes'}
|
|
150
|
-
noLabel={formData.negative_feedback_button || 'No'}
|
|
151
|
-
onSelect={onPromptSelect}
|
|
152
|
-
appWidth={containerWidth || 300}
|
|
153
|
-
selectedVariant="secondary"
|
|
154
|
-
questionStyle={{color: getThemeColor('question_color', TEXT_DARK), textAlign}}
|
|
155
|
-
/>
|
|
156
|
-
)
|
|
157
|
-
|
|
158
|
-
const renderForm = () => (
|
|
159
|
-
<View style={{alignItems: align}}>
|
|
160
|
-
<Text style={[styles.title, {color: getThemeColor('title_color', TEXT_DARK), textAlign}]}>
|
|
161
|
-
{formData.title}
|
|
162
|
-
</Text>
|
|
163
|
-
{formData.question && (
|
|
164
|
-
<Text style={[styles.question, {color: getThemeColor('question_color', TEXT_DARK), textAlign}]}>
|
|
165
|
-
{formData.question}
|
|
166
|
-
</Text>
|
|
167
|
-
)}
|
|
168
|
-
|
|
169
|
-
{formData.show_rating_star === 1 && (
|
|
170
|
-
<View style={styles.mv16}>
|
|
171
|
-
<Rating
|
|
172
|
-
value={rating}
|
|
173
|
-
onRate={setRating}
|
|
174
|
-
selectedStarColor={getThemeColor('selected_star_color', PRIMARY_COLOR)}
|
|
175
|
-
/>
|
|
176
|
-
</View>
|
|
177
|
-
)}
|
|
178
|
-
|
|
179
|
-
{formData.options && formData.options.length > 0 && (
|
|
180
|
-
<MultiSelectButtons
|
|
181
|
-
question={formData.instruction || ''}
|
|
182
|
-
options={formData.options.map((o: any) => ({
|
|
183
|
-
label: o.text || o.title || '',
|
|
184
|
-
value: o.value || o.slug || '',
|
|
185
|
-
}))}
|
|
186
|
-
value={selectedOptions}
|
|
187
|
-
onSelect={setSelectedOptions}
|
|
188
|
-
appWidth={containerWidth || 300}
|
|
189
|
-
style={styles.mv16}
|
|
190
|
-
/>
|
|
191
|
-
)}
|
|
192
|
-
|
|
193
|
-
{(formData.type === 'comment' || formData.show_comment) && (
|
|
194
|
-
<Textarea
|
|
195
|
-
value={freeText}
|
|
196
|
-
onChangeText={setFreeText}
|
|
197
|
-
placeholder={formData.comment_placeholder}
|
|
198
|
-
label={formData.secondary_question || 'Please specify'}
|
|
199
|
-
appWidth={containerWidth || 300}
|
|
200
|
-
/>
|
|
201
|
-
)}
|
|
202
|
-
|
|
203
|
-
<ButtonSubmit
|
|
204
|
-
title={formData.submit_button_text || 'Submit'}
|
|
205
|
-
onPress={onSubmitDetails}
|
|
206
|
-
loading={submitting}
|
|
207
|
-
appWidth={containerWidth || 300}
|
|
208
|
-
backgroundColor={getThemeColor('button_bg_color', PRIMARY_COLOR)}
|
|
209
|
-
/>
|
|
210
|
-
</View>
|
|
211
|
-
)
|
|
212
|
-
|
|
213
|
-
const renderSuccess = () => (
|
|
214
|
-
<View style={styles.center}>
|
|
215
|
-
<Text style={[styles.successTitle, {textAlign}]}>{formData.success_title || 'Submitted'}</Text>
|
|
216
|
-
{formData.success_message && (
|
|
217
|
-
<Text style={[styles.successMsg, {textAlign}]}>{formData.success_message}</Text>
|
|
218
|
-
)}
|
|
219
|
-
</View>
|
|
220
|
-
)
|
|
221
|
-
|
|
222
|
-
if (!visible) return null
|
|
223
|
-
|
|
224
|
-
return (
|
|
225
|
-
<View
|
|
226
|
-
style={[styles.container, style]}
|
|
227
|
-
onLayout={event => {
|
|
228
|
-
const {width} = event.nativeEvent.layout
|
|
229
|
-
setContainerWidth(width)
|
|
230
|
-
}}
|
|
231
|
-
>
|
|
232
|
-
<View style={styles.expandedContent}>
|
|
233
|
-
{loading ? (
|
|
234
|
-
<View style={styles.center}>
|
|
235
|
-
<ActivityIndicator color={PRIMARY_COLOR} />
|
|
236
|
-
</View>
|
|
237
|
-
) : !formData ? null : (
|
|
238
|
-
<>
|
|
239
|
-
{step === 'PROMPT' && renderPrompt()}
|
|
240
|
-
{step === 'LOADING' && (
|
|
241
|
-
<View style={styles.center}>
|
|
242
|
-
<ActivityIndicator color={PRIMARY_COLOR} />
|
|
243
|
-
</View>
|
|
244
|
-
)}
|
|
245
|
-
{step === 'FORM' && renderForm()}
|
|
246
|
-
{step === 'SUCCESS' && renderSuccess()}
|
|
247
|
-
</>
|
|
248
|
-
)}
|
|
249
|
-
</View>
|
|
250
|
-
</View>
|
|
251
|
-
)
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
const styles = StyleSheet.create({
|
|
255
|
-
container: {
|
|
256
|
-
padding: 16,
|
|
257
|
-
backgroundColor: '#FFF',
|
|
258
|
-
borderRadius: 8,
|
|
259
|
-
borderWidth: 1,
|
|
260
|
-
borderColor: BORDER_DEFAULT,
|
|
261
|
-
marginVertical: 10,
|
|
262
|
-
},
|
|
263
|
-
expandedContent: {
|
|
264
|
-
marginTop: 0,
|
|
265
|
-
},
|
|
266
|
-
center: {
|
|
267
|
-
padding: 20,
|
|
268
|
-
alignItems: 'center',
|
|
269
|
-
justifyContent: 'center',
|
|
270
|
-
},
|
|
271
|
-
title: {
|
|
272
|
-
fontSize: 18,
|
|
273
|
-
fontWeight: '700',
|
|
274
|
-
marginBottom: 8,
|
|
275
|
-
},
|
|
276
|
-
question: {
|
|
277
|
-
fontSize: 14,
|
|
278
|
-
marginBottom: 16,
|
|
279
|
-
},
|
|
280
|
-
successTitle: {
|
|
281
|
-
fontSize: 18,
|
|
282
|
-
fontWeight: '700',
|
|
283
|
-
color: PRIMARY_COLOR,
|
|
284
|
-
},
|
|
285
|
-
successMsg: {
|
|
286
|
-
fontSize: 14,
|
|
287
|
-
marginTop: 8,
|
|
288
|
-
color: TEXT_DARK,
|
|
289
|
-
},
|
|
290
|
-
mv16: {
|
|
291
|
-
marginVertical: 16,
|
|
292
|
-
width: '100%',
|
|
293
|
-
},
|
|
294
|
-
})
|
|
295
|
-
|
|
296
|
-
export default AIAContentUsefulness
|