From be64a9b1c35fa3dfd4fc4f9bec3a847891dd54cc Mon Sep 17 00:00:00 2001 From: alphaeusmote <41258468-alphaeusmote@users.noreply.replit.com> Date: Thu, 10 Apr 2025 11:53:22 +0000 Subject: [PATCH] Checkpoint 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/79fe97ba-9acb-4084-b598-67aa27403958.jpg --- client/src/components/domain/domain-table.tsx | 9 ++++++++- client/src/pages/domains.tsx | 11 +++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/client/src/components/domain/domain-table.tsx b/client/src/components/domain/domain-table.tsx index e9ac1fb..287cec1 100644 --- a/client/src/components/domain/domain-table.tsx +++ b/client/src/components/domain/domain-table.tsx @@ -44,8 +44,13 @@ export function DomainTable({ onManageDomain, onDeleteDomain, onAddDomain }: Dom }); const getProviderName = (providerId: string | null | undefined) => { + // Add enhanced debugging to help track down the issue + console.log("Provider lookup - ID provided:", providerId, typeof providerId); + console.log("Available providers:", providers.map(p => ({ id: p.id, name: p.name }))); + // Handle completely empty providerId cases - if (!providerId || providerId === "") { + if (providerId === null || providerId === undefined || providerId === "") { + console.log("Provider is empty/null"); return "None"; } @@ -54,8 +59,10 @@ export function DomainTable({ onManageDomain, onDeleteDomain, onAddDomain }: Dom const provider = providers.find(p => p.id === providerId); if (provider) { + console.log("Found provider:", provider.name); return provider.name; } else { + console.log("Provider not found for ID:", providerId); // If we have a providerId but can't find the provider (might be deleted) return "Unknown Provider"; } diff --git a/client/src/pages/domains.tsx b/client/src/pages/domains.tsx index b0f2cb5..ac27a0e 100644 --- a/client/src/pages/domains.tsx +++ b/client/src/pages/domains.tsx @@ -82,6 +82,7 @@ export default function DomainsPage() { resolver: zodResolver(domainFormSchema), defaultValues: { name: "", + providerId: undefined, // Explicitly set undefined to avoid empty string isActive: true, }, }); @@ -89,11 +90,21 @@ export default function DomainsPage() { // Add domain mutation const addDomainMutation = useMutation({ mutationFn: async (data: z.infer) => { + // Prepare domain data with organizationId const domainData: InsertDomain = { ...data, organizationId: currentOrganization?.id || "", }; + // Add special handling for providerId + // If providerId is an empty string or undefined, remove it completely + // This ensures we don't send empty string which causes backend validation issues + if (!domainData.providerId || domainData.providerId === "") { + delete domainData.providerId; // Remove instead of setting to null to avoid type issues + } + + console.log("Submitting domain with provider:", domainData.providerId); + const res = await apiRequest("POST", "/api/domains", domainData); return await res.json(); },