@tellescope/react-components 1.126.0 → 1.127.0

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@tellescope/react-components",
3
- "version": "1.126.0",
3
+ "version": "1.127.0",
4
4
  "description": "",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/esm/index.js",
@@ -47,12 +47,12 @@
47
47
  "@reduxjs/toolkit": "^1.6.2",
48
48
  "@stripe/react-stripe-js": "^2.1.0",
49
49
  "@stripe/stripe-js": "^1.52.1",
50
- "@tellescope/constants": "^1.126.0",
51
- "@tellescope/sdk": "^1.126.0",
52
- "@tellescope/types-client": "^1.126.0",
53
- "@tellescope/types-models": "^1.126.0",
50
+ "@tellescope/constants": "^1.127.0",
51
+ "@tellescope/sdk": "^1.127.0",
52
+ "@tellescope/types-client": "^1.127.0",
53
+ "@tellescope/types-models": "^1.127.0",
54
54
  "@tellescope/types-utilities": "^1.69.3",
55
- "@tellescope/utilities": "^1.126.0",
55
+ "@tellescope/utilities": "^1.127.0",
56
56
  "@typescript-eslint/eslint-plugin": "^4.33.0",
57
57
  "@typescript-eslint/parser": "^4.33.0",
58
58
  "css-to-react-native": "^3.0.0",
@@ -79,7 +79,7 @@
79
79
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
80
80
  "react-native": "^0.65.0 || ^0.66.0 || ^0.67.0 || ^0.68.0 || ^0.71.0"
81
81
  },
82
- "gitHead": "67edd6e59ea9f9f3cbb6fced05965a0ccea5f59f",
82
+ "gitHead": "1393e45b767e134b53ec044a6206254094e1b76d",
83
83
  "publishConfig": {
84
84
  "access": "public"
85
85
  }
@@ -23,13 +23,15 @@ export const AddressDisplay = ({ value } : { value: Required<FormResponseAnswerA
23
23
  </Grid>
24
24
  )
25
25
 
26
- export const ResponseAnswer = ({ isHTML, answer: a, printing, onImageClick } : {
26
+ export const ResponseAnswer = ({ formResponse, fieldId, isHTML, answer: a, printing, onImageClick } : {
27
27
  answer: FormResponseValueAnswer,
28
+ formResponse: FormResponse,
29
+ fieldId: string,
28
30
  printing?: boolean,
29
31
  onImageClick?: (args: { src: string }) => void,
30
32
  isHTML?: boolean,
31
33
  }) => (
32
- (isHTML && typeof a.value === 'string')
34
+ (isHTML && typeof a.value === 'string')
33
35
  ? <div dangerouslySetInnerHTML={{ __html: remove_script_tags(a.value) }} />
34
36
  : a.value
35
37
  ? (
@@ -139,8 +141,21 @@ export const ResponseAnswer = ({ isHTML, answer: a, printing, onImageClick } : {
139
141
  </Grid>
140
142
  ))}
141
143
  </Grid>
142
-
143
144
  )
145
+ : (a.type === 'Emotii') ? (() => {
146
+ if (!a.value) return null
147
+ const scoring = formResponse?.emotii?.find(s => s.id === fieldId)
148
+ if (!scoring) return null
149
+
150
+ return (
151
+ <>
152
+ {[{ label: 'Average', ...scoring.scores.total }, ...scoring.scores.byAnswer].map((s, i) => (
153
+ <Typography>{s.label}: {s.score}</Typography>
154
+ ))}
155
+ </>
156
+ )
157
+
158
+ })()
144
159
  : (
145
160
  <Typography style={answerStyles}>
146
161
  {form_response_value_to_string(a.value)}
@@ -297,7 +312,7 @@ export const FormResponseView = ({ enduser, onClose, hideHeader, response, id, p
297
312
  && (
298
313
  (r.answerIsHTML && typeof r.answer.value === 'string')
299
314
  ? <div dangerouslySetInnerHTML={{ __html: remove_script_tags(r.answer.value) }} />
300
- : <ResponseAnswer answer={r.answer} printing={printing} />
315
+ : <ResponseAnswer fieldId={r.fieldId} formResponse={response} answer={r.answer} printing={printing} />
301
316
  )
302
317
  }
303
318
  </div>
@@ -318,7 +333,7 @@ export const FormResponseView = ({ enduser, onClose, hideHeader, response, id, p
318
333
  }
319
334
 
320
335
  {!showAnswerInline &&
321
- <ResponseAnswer answer={r.answer} />
336
+ <ResponseAnswer answer={r.answer} formResponse={response} fieldId={r.fieldId} />
322
337
  }
323
338
  </div>
324
339
  )
@@ -240,7 +240,7 @@ export const QuestionForField = ({
240
240
  <Address field={field} disabled={value.disabled} value={value.answer.value as any} onChange={onFieldChange as ChangeHandler<any>} form={form} />
241
241
  )
242
242
  : field.type === 'Emotii' ? (
243
- <Emotii field={field} disabled={value.disabled} value={value.answer.value as any} onChange={onFieldChange as ChangeHandler<any>} form={form} />
243
+ <Emotii enduser={enduser} enduserId={enduserId} field={field} disabled={value.disabled} value={value.answer.value as any} onChange={onFieldChange as ChangeHandler<any>} form={form} />
244
244
  )
245
245
  : field.type === 'Height' ? (
246
246
  <Height field={field} disabled={value.disabled} value={value.answer.value as any} onChange={onFieldChange as ChangeHandler<any>} form={form} />
@@ -2744,17 +2744,23 @@ export const EmotiiInput = ({ goToNextField, goToPreviousField, field, value, on
2744
2744
  const [data, setData] = useState<{ surveyRequestId: string, surveyUrl: string }>()
2745
2745
  const [loadCount, setLoadCount] = useState(0)
2746
2746
 
2747
+ console.log(props.enduserId, props.enduser)
2748
+
2749
+ const fetchRef = useRef(false)
2747
2750
  useEffect(() => {
2748
2751
  if (value) return
2752
+ if (fetchRef.current) return
2753
+ fetchRef.current = true
2749
2754
 
2750
2755
  session.api.integrations
2751
2756
  .proxy_read({
2752
2757
  integration: EMOTII_TITLE,
2753
2758
  type: 'get_survey',
2759
+ id: props?.enduserId, // defaults to session id when not defined
2754
2760
  query: requestIdRef.current,
2755
2761
  })
2756
2762
  .then(r => setData(r.data))
2757
- }, [session, value])
2763
+ }, [session, value, props?.enduserId])
2758
2764
 
2759
2765
  const loadAnswerRef = useRef(false)
2760
2766
  useEffect(() => {