Fix tab selection logic in IOModal component
This commit is contained in:
parent
de5314fc2e
commit
7a1b1828e9
1 changed files with 9 additions and 9 deletions
|
|
@ -51,25 +51,25 @@ export default function IOModal({
|
||||||
);
|
);
|
||||||
const haveChat = chatInput || chatOutput;
|
const haveChat = chatInput || chatOutput;
|
||||||
const [selectedTab, setSelectedTab] = useState(
|
const [selectedTab, setSelectedTab] = useState(
|
||||||
inputs.length > 0 ? 1 : outputs.length > 0 ? 2 : 0
|
outputs.length > 0 ? 2 : inputs.length > 0 ? 1 : 0
|
||||||
);
|
);
|
||||||
|
|
||||||
function startView(){
|
function startView() {
|
||||||
if(!chatInput && !chatOutput){
|
if (!chatInput && !chatOutput) {
|
||||||
if(outputs.length > 0){
|
if (outputs.length > 0) {
|
||||||
return outputs[0];
|
return outputs[0];
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
return inputs[0];
|
return inputs[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const [selectedViewField, setSelectedViewField] = useState<
|
const [selectedViewField, setSelectedViewField] = useState<
|
||||||
{ type: string; id: string }|undefined
|
{ type: string; id: string } | undefined
|
||||||
>(startView());
|
>(startView());
|
||||||
|
|
||||||
const buildFlow = useFlowStore((state) => state.buildFlow);
|
const buildFlow = useFlowStore((state) => state.buildFlow);
|
||||||
|
|
@ -116,7 +116,7 @@ export default function IOModal({
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setSelectedViewField(startView());
|
setSelectedViewField(startView());
|
||||||
setSelectedTab(inputs.length > 0 ? 1 : outputs.length > 0 ? 2 : 0);
|
setSelectedTab(outputs.length > 0 ? 2 : inputs.length > 0 ? 1 : 0);
|
||||||
}, [inputs.length, outputs.length]);
|
}, [inputs.length, outputs.length]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -316,7 +316,7 @@ export default function IOModal({
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div className="font-xl flex items-center justify-center gap-3 font-semibold">
|
<div className="font-xl flex items-center justify-center gap-3 font-semibold">
|
||||||
{( haveChat &&<button onClick={() => setSelectedViewField(undefined)}>
|
{(haveChat && <button onClick={() => setSelectedViewField(undefined)}>
|
||||||
<IconComponent
|
<IconComponent
|
||||||
name={"ArrowLeft"}
|
name={"ArrowLeft"}
|
||||||
className="h-6 w-6"
|
className="h-6 w-6"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue