From 0993d1b496969eaa876f95196330d72692002ebd Mon Sep 17 00:00:00 2001 From: Janaka-Steph Date: Tue, 14 Nov 2023 17:04:14 +0000 Subject: [PATCH] Display dnsd errors --- .../settings/components/domain/ManualDomainModal.tsx | 10 ++++++++-- src/shared/api/dnsd.ts | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/modules/settings/components/domain/ManualDomainModal.tsx b/src/modules/settings/components/domain/ManualDomainModal.tsx index 9bfc4411..1d60fb11 100644 --- a/src/modules/settings/components/domain/ManualDomainModal.tsx +++ b/src/modules/settings/components/domain/ManualDomainModal.tsx @@ -18,9 +18,11 @@ const ManualDomainModal = ({ setIsManualDomainModalOpen, }: ManualDomainModalProps) => { const [domainName, setDomainName] = useState(""); + const [isSubmitting, setIsSubmitting] = useState(false); const onSubmit = async (e: React.FormEvent) => { e.preventDefault(); + setIsSubmitting(true); try { await apiDnsd().post("dns", { domain: domainName }); toast.success( @@ -29,9 +31,13 @@ const ManualDomainModal = ({ } catch (error) { if (error instanceof AxiosError && error.code === "ERR_NETWORK") { console.error("Cannot connect to dns service"); + toast.error("Cannot connect to dns service", { toastId: "dns-service-error" }); } else { - console.log("Response Data:", (error as any).response.data.error); + console.error("Response Data:", (error as any).response.data.error); + toast.error((error as any).response.data.error, { toastId: "dns-service-error" }); } + } finally { + setIsSubmitting(false); } }; @@ -59,7 +65,7 @@ const ManualDomainModal = ({ />
-
diff --git a/src/shared/api/dnsd.ts b/src/shared/api/dnsd.ts index b0960975..348c48a0 100644 --- a/src/shared/api/dnsd.ts +++ b/src/shared/api/dnsd.ts @@ -6,7 +6,7 @@ import useSettingStore from "../store/setting"; const apiDnsd = () => { const isIP = useSettingStore.getState().isIP; const headers = { "Content-Type": "application/json" }; - let baseURL; + let baseURL = useSettingStore.getState().backendUrl; if (isProxyEnabled()) { if (isIP) { baseURL = `${useSettingStore.getState().backendUrl}dnsd/`;