From c75bf7eb3eb48e74d38629635d68282f6709ca74 Mon Sep 17 00:00:00 2001 From: alphaeusmote <41258468-alphaeusmote@users.noreply.replit.com> Date: Fri, 11 Apr 2025 03:05:48 +0000 Subject: [PATCH] Fix DNS record management issues by improving update functionality, preventing duplicate records, and adding enable/disable toggles. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 9111ef36-26c8-4085-84ca-a35dc1fec1b5 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7083d608-d6d3-4a6a-9a27-6286c5109627/5a8a622f-7ee7-4310-8349-d5977bbd2bbb.jpg --- .../src/components/domain/domain-details.tsx | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/client/src/components/domain/domain-details.tsx b/client/src/components/domain/domain-details.tsx index f774f31..cc38652 100644 --- a/client/src/components/domain/domain-details.tsx +++ b/client/src/components/domain/domain-details.tsx @@ -188,7 +188,14 @@ export function DomainDetails({ domain, onBack }: DomainDetailsProps) { providerId: domain.providerId }; + console.log("Updating record:", id, "with data:", updatedData); const res = await apiRequest("PUT", `/api/dns-records/${id}`, updatedData); + + if (!res.ok) { + const errorData = await res.json(); + throw new Error(errorData.message || "Failed to update record"); + } + return await res.json(); }, onSuccess: () => { @@ -201,9 +208,10 @@ export function DomainDetails({ domain, onBack }: DomainDetailsProps) { }); }, onError: (error) => { + console.error("Update record error:", error); toast({ title: "Failed to update record", - description: error.message, + description: error instanceof Error ? error.message : "Unknown error occurred", variant: "destructive", }); }, @@ -345,7 +353,6 @@ export function DomainDetails({ domain, onBack }: DomainDetailsProps) { Type Content TTL - Provider Last Update Status Actions @@ -394,7 +401,6 @@ export function DomainDetails({ domain, onBack }: DomainDetailsProps) { {record.ttl}s - {getProviderName(record.providerId)} {record.lastUpdated ? formatDistanceToNow(new Date(record.lastUpdated), { addSuffix: true }) @@ -409,6 +415,20 @@ export function DomainDetails({ domain, onBack }: DomainDetailsProps) { + + + + handleToggleActive(record, checked)} + className="mx-2" + /> + + + {record.isActive ? "Disable" : "Enable"} record + + +
{record.isActive ? "Disable" : "Enable"} record