Skip to content

Commit ff618c0

Browse files
fix(web-devtools): rabbit-ai-feedback
1 parent 0e1e8e5 commit ff618c0

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

web-devtools/src/app/(main)/dispute-template/CustomContextInputs.tsx

+14-7
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,24 @@ interface ICustomContextInputs {
4141
setCustomContext: (context: Record<string, string>) => void;
4242
}
4343
const 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

Comments
 (0)