-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add tools table for creating and deleting tools #284
Conversation
await ToolReferenceService.createToolReference({ | ||
toolReference: { ...data, toolType: "tool" }, | ||
}); | ||
reset(); | ||
onSuccess(); | ||
} catch (error) { | ||
console.error("Failed to create tool reference:", error); | ||
} finally { | ||
setIsSubmitting(false); | ||
} | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const { execute: onSubmit, isLoading } = useAsync(
async (data: CreateToolReference) => {
await ToolReferenceService.createToolReference({
toolReference: { ...data, toolType: "tool" },
});
reset();
onSuccess();
},
{
onError: (error) =>
console.error("Failed to create tool reference:", error),
}
);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦🏻 So much better, thanks Ryan.
<Dialog open={isDeleteDialogOpen} onOpenChange={setIsDeleteDialogOpen}> | ||
<DialogTrigger asChild> | ||
<Button variant="ghost" size="sm"> | ||
<Trash2Icon className="h-4 w-4" /> | ||
</Button> | ||
</DialogTrigger> | ||
<DialogContent> | ||
<DialogHeader> | ||
<DialogTitle>Are you sure?</DialogTitle> | ||
<DialogDescription> | ||
This action cannot be undone. This will permanently | ||
delete the tool reference. | ||
</DialogDescription> | ||
</DialogHeader> | ||
<DialogFooter> | ||
<Button | ||
variant="outline" | ||
onClick={() => setIsDeleteDialogOpen(false)} | ||
> | ||
Cancel | ||
</Button> | ||
<Button | ||
variant="destructive" | ||
onClick={() => { | ||
onDelete(); | ||
setIsDeleteDialogOpen(false); | ||
}} | ||
> | ||
Delete | ||
</Button> | ||
</DialogFooter> | ||
</DialogContent> | ||
</Dialog> | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created a helper component called ConfirmationDialog
that will handle this quite nicely
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, yep does this exactly.
const { data: tools, mutate } = useSWR( | ||
ToolReferenceService.getToolReferences.key("tool"), | ||
() => ToolReferenceService.getToolReferences("tool") | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: preload in a clientLoader
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of small things but other than that looks great!
2c60d6f
to
06e036d
Compare
@ryanhopperlowe Mind giving this another look? |
06e036d
to
f4e4978
Compare
Signed-off-by: tylerslaton <[email protected]>
f4e4978
to
a9cc9db
Compare
All set here! |
Screen.Recording.2024-10-23.at.11.43.25.AM.mov