fix(formModal): fix nullish coalescing operator usage to handle nullable properties in tabsStateFlowId.formKeysData
This commit is contained in:
parent
9b0ff166c9
commit
af218867eb
1 changed files with 13 additions and 9 deletions
|
|
@ -70,10 +70,11 @@ export default function FormModal({
|
||||||
const tabsStateFlowIdFormKeysData = tabsStateFlowId.formKeysData;
|
const tabsStateFlowIdFormKeysData = tabsStateFlowId.formKeysData;
|
||||||
const [chatKey, setChatKey] = useState(() => {
|
const [chatKey, setChatKey] = useState(() => {
|
||||||
if (tabsState[flow.id]?.formKeysData?.input_keys) {
|
if (tabsState[flow.id]?.formKeysData?.input_keys) {
|
||||||
return Object.keys(tabsState[flow.id].formKeysData.input_keys).find(
|
return Object.keys(tabsState[flow.id].formKeysData.input_keys!).find(
|
||||||
(key) =>
|
(key) =>
|
||||||
!tabsState[flow.id].formKeysData.handle_keys.some((j) => j === key) &&
|
!tabsState[flow.id].formKeysData.handle_keys!.some(
|
||||||
tabsState[flow.id].formKeysData.input_keys[key] === ""
|
(j) => j === key
|
||||||
|
) && tabsState[flow.id].formKeysData.input_keys![key] === ""
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// TODO: return a sensible default
|
// TODO: return a sensible default
|
||||||
|
|
@ -430,7 +431,7 @@ export default function FormModal({
|
||||||
|
|
||||||
{tabsState[id.current]?.formKeysData?.input_keys
|
{tabsState[id.current]?.formKeysData?.input_keys
|
||||||
? Object.keys(
|
? Object.keys(
|
||||||
tabsState[id.current].formKeysData.input_keys
|
tabsState[id.current].formKeysData.input_keys!
|
||||||
).map((key, index) => (
|
).map((key, index) => (
|
||||||
<div className="file-component-accordion-div" key={index}>
|
<div className="file-component-accordion-div" key={index}>
|
||||||
<AccordionComponent
|
<AccordionComponent
|
||||||
|
|
@ -454,7 +455,7 @@ export default function FormModal({
|
||||||
size="small"
|
size="small"
|
||||||
disabled={tabsState[
|
disabled={tabsState[
|
||||||
id.current
|
id.current
|
||||||
].formKeysData.handle_keys.some(
|
].formKeysData.handle_keys!.some(
|
||||||
(t) => t === key
|
(t) => t === key
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
@ -465,7 +466,7 @@ export default function FormModal({
|
||||||
keyValue={key}
|
keyValue={key}
|
||||||
>
|
>
|
||||||
<div className="file-component-tab-column">
|
<div className="file-component-tab-column">
|
||||||
{tabsState[id.current].formKeysData.handle_keys.some(
|
{tabsState[id.current].formKeysData.handle_keys!.some(
|
||||||
(t) => t === key
|
(t) => t === key
|
||||||
) && (
|
) && (
|
||||||
<div className="font-normal text-muted-foreground ">
|
<div className="font-normal text-muted-foreground ">
|
||||||
|
|
@ -475,7 +476,9 @@ export default function FormModal({
|
||||||
<Textarea
|
<Textarea
|
||||||
className="custom-scroll"
|
className="custom-scroll"
|
||||||
value={
|
value={
|
||||||
tabsState[id.current].formKeysData.input_keys[key]
|
tabsState[id.current].formKeysData.input_keys![
|
||||||
|
key
|
||||||
|
]
|
||||||
}
|
}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
|
|
@ -483,7 +486,8 @@ export default function FormModal({
|
||||||
let newTabsState = _.cloneDeep(old);
|
let newTabsState = _.cloneDeep(old);
|
||||||
newTabsState[
|
newTabsState[
|
||||||
id.current
|
id.current
|
||||||
].formKeysData.input_keys[key] = e.target.value;
|
].formKeysData.input_keys![key] =
|
||||||
|
e.target.value;
|
||||||
return newTabsState;
|
return newTabsState;
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
|
|
@ -495,7 +499,7 @@ export default function FormModal({
|
||||||
</div>
|
</div>
|
||||||
))
|
))
|
||||||
: null}
|
: null}
|
||||||
{tabsState[id.current].formKeysData.memory_keys.map(
|
{tabsState[id.current].formKeysData.memory_keys!.map(
|
||||||
(key, index) => (
|
(key, index) => (
|
||||||
<div className="file-component-accordion-div" key={index}>
|
<div className="file-component-accordion-div" key={index}>
|
||||||
<AccordionComponent
|
<AccordionComponent
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue