@@ -41,17 +41,24 @@ interface ICustomContextInputs {
41
41
setCustomContext : ( context : Record < string , string > ) => void ;
42
42
}
43
43
const CustomContextInputs : React . FC < ICustomContextInputs > = ( { dataMapping, setCustomContext } ) => {
44
- const [ customContext , setCustomContextInputs ] = useState < Record < string , string > > ( ) ;
44
+ const [ customContextInputs , setCustomContextInputs ] = useState < Record < string , string > > ( ) ;
45
45
46
- const requiredVariables = useMemo ( ( ) => retrieveVariables ( dataMapping ) , [ dataMapping ] ) ;
46
+ const requiredVariables = useMemo ( ( ) => {
47
+ try {
48
+ return retrieveVariables ( dataMapping ) ;
49
+ } catch ( error ) {
50
+ console . error ( "Failed to parse dataMapping:" , error ) ;
51
+ return [ ] ;
52
+ }
53
+ } , [ dataMapping ] ) ;
47
54
48
55
useDebounce (
49
56
( ) => {
50
- if ( ! customContext ) return ;
51
- setCustomContext ( customContext ) ;
57
+ if ( ! customContextInputs ) return ;
58
+ setCustomContext ( customContextInputs ) ;
52
59
} ,
53
60
300 ,
54
- [ customContext ]
61
+ [ customContextInputs ]
55
62
) ;
56
63
57
64
return requiredVariables . length ? (
@@ -61,12 +68,12 @@ const CustomContextInputs: React.FC<ICustomContextInputs> = ({ dataMapping, setC
61
68
</ WithHelpTooltip >
62
69
{ requiredVariables . map ( ( variable , index ) =>
63
70
DisputeRequestParams . includes ( variable ) ? null : (
64
- < InputContainer id = { `${ variable } -${ index } ` } >
71
+ < InputContainer key = { `${ variable } -${ index } ` } >
65
72
< VariableName > { variable } :</ VariableName >
66
73
< Field
67
74
type = "text"
68
75
name = { variable }
69
- value = { customContext ?. [ variable ] }
76
+ value = { customContextInputs ?. [ variable ] }
70
77
onChange = { ( e ) => {
71
78
setCustomContextInputs ( ( prev ) => ( { ...prev , [ variable ] : e . target . value } ) ) ;
72
79
} }
0 commit comments