Skip to content

Commit

Permalink
Fix connection deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
anthony2261 committed Apr 1, 2024
1 parent 9f2936e commit 4396296
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions text2sql-frontend/src/components/Connection/ConnectionEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,18 @@ export const ConnectionEditor = () => {
fetchConnection();
}, [params.connectionId]);

function handleDelete() {
(async () => {
try {
await api.deleteConnection(params.connectionId!);
fetchConnections();
fetchConversations();
navigate(Routes.Root);
} catch (exception) {
enqueueSnackbar({
variant: "error",
message: "Error deleting connection",
});
}
})();
async function handleDelete() {
try {
await api.deleteConnection(params.connectionId!);
fetchConnections();
fetchConversations();
navigate(Routes.Root);
} catch (exception) {
enqueueSnackbar({
variant: "error",
message: "Error deleting connection",
});
}
}
function handleSubmit() {
if (!unsavedChanges) {
Expand Down Expand Up @@ -214,13 +212,15 @@ export const ConnectionEditor = () => {

<form className="sm:col-span-6 flex items-center justify-end gap-x-6">
<button
type="button"
onClick={handleDelete}
className="rounded-md bg-gray-700 hover:bg-red-700 px-3 py-2 text-sm font-medium text-red-500 hover:text-white border border-gray-600 hover:border-red-600 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gray-600 transition-colors duration-150"
>
Delete this connection
</button>
<button
type="button"
onClick={handleBack}
className="rounded-md bg-gray-600 px-3 py-2 text-sm font-medium text-white border border-gray-500 hover:bg-gray-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gray-600 transition-colors duration-150"
>
Cancel
Expand Down

0 comments on commit 4396296

Please sign in to comment.