mirror of
https://github.com/arc53/DocsGPT.git
synced 2025-11-30 09:03:15 +00:00
fix: open new tool after its added
This commit is contained in:
@@ -58,9 +58,27 @@ export default function Tools() {
|
||||
getUserTools();
|
||||
};
|
||||
|
||||
const handleToolAdded = (toolId: string) => {
|
||||
userService
|
||||
.getUserTools()
|
||||
.then((res) => res.json())
|
||||
.then((data) => {
|
||||
const newTool = data.tools.find(
|
||||
(tool: UserToolType) => tool.id === toolId,
|
||||
);
|
||||
if (newTool) {
|
||||
setSelectedTool(newTool);
|
||||
} else {
|
||||
console.error('Newly added tool not found');
|
||||
}
|
||||
})
|
||||
.catch((error) => console.error('Error fetching tools:', error));
|
||||
};
|
||||
|
||||
React.useEffect(() => {
|
||||
getUserTools();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div>
|
||||
{selectedTool ? (
|
||||
@@ -185,6 +203,7 @@ export default function Tools() {
|
||||
modalState={addToolModalState}
|
||||
setModalState={setAddToolModalState}
|
||||
getUserTools={getUserTools}
|
||||
onToolAdded={handleToolAdded}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user