diff --git a/src/frontend/src/modals/dictAreaModal/index.tsx b/src/frontend/src/modals/dictAreaModal/index.tsx index e6e9a2e9f..4feb533a9 100644 --- a/src/frontend/src/modals/dictAreaModal/index.tsx +++ b/src/frontend/src/modals/dictAreaModal/index.tsx @@ -48,8 +48,45 @@ export default function DictAreaModal({ navigator.clipboard.writeText(JSON.stringify(copy)); }; + const handleChangeType = (type: "array" | "object") => { + setComponentValue((value) => { + if (type === "array") { + if (value && Object.keys(value).length > 0) { + return [value]; + } + return []; + } + if (value && Array.isArray(value) && value.length > 0) { + return value[0]; + } + return {}; + }); + }; + + const IteractiveReader = () => { + return ( + + Customize your dictionary, adding or editing key-value pairs as needed. + Supports adding new{" "} + handleChangeType("object")} + className="cursor-pointer underline" + > + objects { } + {" "} + or{" "} + handleChangeType("array")} + className="cursor-pointer underline" + > + arrays []. + + + ); + }; + const renderHeader = () => ( - + {onChange ? "Edit Dictionary" : "View Dictionary"}