@@ -41,17 +41,24 @@ interface ICustomContextInputs {
4141 setCustomContext : ( context : Record < string , string > ) => void ;
4242}
4343const CustomContextInputs : React . FC < ICustomContextInputs > = ( { dataMapping, setCustomContext } ) => {
44- const [ customContext , setCustomContextInputs ] = useState < Record < string , string > > ( ) ;
44+ const [ customContextInputs , setCustomContextInputs ] = useState < Record < string , string > > ( ) ;
4545
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 ] ) ;
4754
4855 useDebounce (
4956 ( ) => {
50- if ( ! customContext ) return ;
51- setCustomContext ( customContext ) ;
57+ if ( ! customContextInputs ) return ;
58+ setCustomContext ( customContextInputs ) ;
5259 } ,
5360 300 ,
54- [ customContext ]
61+ [ customContextInputs ]
5562 ) ;
5663
5764 return requiredVariables . length ? (
@@ -61,12 +68,12 @@ const CustomContextInputs: React.FC<ICustomContextInputs> = ({ dataMapping, setC
6168 </ WithHelpTooltip >
6269 { requiredVariables . map ( ( variable , index ) =>
6370 DisputeRequestParams . includes ( variable ) ? null : (
64- < InputContainer id = { `${ variable } -${ index } ` } >
71+ < InputContainer key = { `${ variable } -${ index } ` } >
6572 < VariableName > { variable } :</ VariableName >
6673 < Field
6774 type = "text"
6875 name = { variable }
69- value = { customContext ?. [ variable ] }
76+ value = { customContextInputs ?. [ variable ] }
7077 onChange = { ( e ) => {
7178 setCustomContextInputs ( ( prev ) => ( { ...prev , [ variable ] : e . target . value } ) ) ;
7279 } }
0 commit comments