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
This commit is contained in:
alphaeusmote
2025-04-10 11:53:22 +00:00
parent 31beb4e420
commit be64a9b1c3
2 changed files with 19 additions and 1 deletions
@@ -44,8 +44,13 @@ export function DomainTable({ onManageDomain, onDeleteDomain, onAddDomain }: Dom
}); });
const getProviderName = (providerId: string | null | undefined) => { 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 // Handle completely empty providerId cases
if (!providerId || providerId === "") { if (providerId === null || providerId === undefined || providerId === "") {
console.log("Provider is empty/null");
return "None"; return "None";
} }
@@ -54,8 +59,10 @@ export function DomainTable({ onManageDomain, onDeleteDomain, onAddDomain }: Dom
const provider = providers.find(p => p.id === providerId); const provider = providers.find(p => p.id === providerId);
if (provider) { if (provider) {
console.log("Found provider:", provider.name);
return provider.name; return provider.name;
} else { } else {
console.log("Provider not found for ID:", providerId);
// If we have a providerId but can't find the provider (might be deleted) // If we have a providerId but can't find the provider (might be deleted)
return "Unknown Provider"; return "Unknown Provider";
} }
+11
View File
@@ -82,6 +82,7 @@ export default function DomainsPage() {
resolver: zodResolver(domainFormSchema), resolver: zodResolver(domainFormSchema),
defaultValues: { defaultValues: {
name: "", name: "",
providerId: undefined, // Explicitly set undefined to avoid empty string
isActive: true, isActive: true,
}, },
}); });
@@ -89,11 +90,21 @@ export default function DomainsPage() {
// Add domain mutation // Add domain mutation
const addDomainMutation = useMutation({ const addDomainMutation = useMutation({
mutationFn: async (data: z.infer<typeof domainFormSchema>) => { mutationFn: async (data: z.infer<typeof domainFormSchema>) => {
// Prepare domain data with organizationId
const domainData: InsertDomain = { const domainData: InsertDomain = {
...data, ...data,
organizationId: currentOrganization?.id || "", 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); const res = await apiRequest("POST", "/api/domains", domainData);
return await res.json(); return await res.json();
}, },