From 81ad3408fb4a35e71bee14b4f0738f450fca26ff Mon Sep 17 00:00:00 2001 From: Steven Date: Thu, 13 Apr 2023 22:58:09 +0800 Subject: [PATCH] fix: edit connection state --- src/components/CreateConnectionModal.tsx | 15 +++++---------- src/types/connection.ts | 2 +- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/components/CreateConnectionModal.tsx b/src/components/CreateConnectionModal.tsx index 46c4b0c..03a5f64 100644 --- a/src/components/CreateConnectionModal.tsx +++ b/src/components/CreateConnectionModal.tsx @@ -3,7 +3,7 @@ import { ChangeEvent, useEffect, useState } from "react"; import { toast } from "react-hot-toast"; import TextareaAutosize from "react-textarea-autosize"; import { useConnectionStore } from "@/store"; -import { Connection, Engine, ResponseObject } from "@/types"; +import { Connection, Engine, ResponseObject, SSLOptions } from "@/types"; import Select from "./kit/Select"; import TextField from "./kit/TextField"; import Modal from "./kit/Modal"; @@ -66,16 +66,11 @@ const CreateConnectionModal = (props: Props) => { } else { setSSLType("ca-only"); } - } else { - setSSLType("none"); } - setSelectedSSLField("ca"); - setIsRequesting(false); - setShowDeleteConnectionModal(false); }, []); useEffect(() => { - let ssl = undefined; + let ssl: SSLOptions | undefined = undefined; if (sslType === "ca-only") { ssl = { ca: "", @@ -87,10 +82,10 @@ const CreateConnectionModal = (props: Props) => { key: "", }; } - setConnection({ + setConnection((connection) => ({ ...connection, - ssl, - }); + ssl: ssl, + })); setSelectedSSLField("ca"); }, [sslType]); diff --git a/src/types/connection.ts b/src/types/connection.ts index 2500c53..7a24903 100644 --- a/src/types/connection.ts +++ b/src/types/connection.ts @@ -5,7 +5,7 @@ export enum Engine { PostgreSQL = "POSTGRESQL", } -interface SSLOptions { +export interface SSLOptions { ca?: string; cert?: string; key?: string;