Skip to content

Commit

Permalink
Display dnsd errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Janaka-Steph committed Nov 14, 2023
1 parent 2624c03 commit 0993d1b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/modules/settings/components/domain/ManualDomainModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ const ManualDomainModal = ({
setIsManualDomainModalOpen,
}: ManualDomainModalProps) => {
const [domainName, setDomainName] = useState("");
const [isSubmitting, setIsSubmitting] = useState(false);

const onSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
setIsSubmitting(true);
try {
await apiDnsd().post("dns", { domain: domainName });
toast.success(
Expand All @@ -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);
}
};

Expand Down Expand Up @@ -59,7 +65,7 @@ const ManualDomainModal = ({
/>
</div>
<div className="flex justify-end mt-6">
<button type="submit" className="btn-primary">
<button type="submit" className="btn-primary" disabled={isSubmitting}>
Submit
</button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/shared/api/dnsd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/`;
Expand Down

0 comments on commit 0993d1b

Please sign in to comment.