Undefined issues

This commit is contained in:
Elizabeth Cray 2023-07-23 20:38:50 -04:00
parent 454108a959
commit b2e042a36b

View File

@ -93,12 +93,14 @@ function App() {
}; };
const handleSubClick = (topic: string, index: number) => { const handleSubClick = (topic: string, index: number) => {
let text = getTopicChildren(topic)[index]; if (codes){
let filtered = codes.filter((code: Code) => code.type === topic && code.text === text); let text = getTopicChildren(topic)[index];
if (filtered.length == 1) { let filtered = codes.filter((code: Code) => code.type === topic && code.text === text);
let payload: string = generatePayload(filtered[0]); if (filtered.length == 1) {
setSubTopic(""); let payload: string = generatePayload(filtered[0]);
invoke('type_str', {input: payload}); setSubTopic("");
invoke('type_str', {input: payload});
}
} }
}; };
@ -132,14 +134,16 @@ function App() {
} }
const handleTopicClick = (type: string) => { const handleTopicClick = (type: string) => {
let filtered = codes.filter((code: Code) => code.type === type); if (codes) {
if (filtered.length == 1) { let filtered = codes.filter((code: Code) => code.type === type);
let assembledStr: string = generatePayload(filtered[0]); if (filtered.length == 1) {
setSubTopic(""); let assembledStr: string = generatePayload(filtered[0]);
invoke('type_str', {input: assembledStr}); setSubTopic("");
}else{ invoke('type_str', {input: assembledStr});
// Open Submenu for type }else{
setSubTopic(type); // Open Submenu for type
setSubTopic(type);
}
} }
}; };
@ -167,7 +171,6 @@ function App() {
})} })}
</div> </div>
); );
// TODO: This isn't returning as expected, use an object to append to then return the compiled list
}else{ }else{
return (<div></div>); return (<div></div>);
} }