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(); },