Improve loading of Project Details dialog

This commit is contained in:
Alex Gleason committed 2025-12-20 19:12:18 -06:00
1 parent 8c7c2694c4
commit 8af3618793
1 file changed
+41 -21
+41 -21
View File
@@ -39,8 +39,10 @@ import {
} from 'lucide-react';
import JSZip from 'jszip';
import { Separator } from './ui/separator';
import { Skeleton } from './ui/skeleton';
import { DotAI } from '@/lib/DotAI';
import { LabelSelector } from '@/components/labels/LabelSelector';
import { cn } from '@/lib/utils';
interface ProjectDetailsDialogProps {
project: Project;
@@ -55,6 +57,7 @@ export function ProjectDetailsDialog({ project, open, onOpenChange, onProjectDel
const [isRenaming, setIsRenaming] = useState(false);
const [newProjectName, setNewProjectName] = useState(project.id);
const [totalCost, setTotalCost] = useState<number | null>(null);
const [isLoading, setIsLoading] = useState(false);
const [templateInfo, setTemplateInfo] = useState<{ name: string; description: string; url: string } | null>(null);
const { toast } = useToast();
const { fs } = useFS();
@@ -72,6 +75,7 @@ export function ProjectDetailsDialog({ project, open, onOpenChange, onProjectDel
// Load total project cost and template info
useEffect(() => {
const loadProjectData = async () => {
setIsLoading(true);
try {
const dotAI = new DotAI(fs, `${projectsPath}/${project.id}`);
@@ -86,6 +90,8 @@ export function ProjectDetailsDialog({ project, open, onOpenChange, onProjectDel
console.warn('Failed to load project data:', error);
setTotalCost(null);
setTemplateInfo(null);
} finally {
setIsLoading(false);
}
};
@@ -259,30 +265,44 @@ export function ProjectDetailsDialog({ project, open, onOpenChange, onProjectDel
</div>
{/* Total Cost */}
{totalCost !== null && totalCost > 0 && (
<div className="flex items-center gap-2 text-sm">
<DollarSign className="h-4 w-4 text-muted-foreground" />
<span className="text-muted-foreground">Total Cost:</span>
<div className="flex items-center gap-2 text-sm">
<DollarSign className="h-4 w-4 text-muted-foreground" />
<span className="text-muted-foreground">Total Cost:</span>
{typeof totalCost === 'number' ? (
<span className="font-mono">${totalCost.toFixed(2)}</span>
</div>
)}
) : (
isLoading ? (
<Skeleton className="h-4 w-16" />
) : (
<span>N/A</span>
)
)}
</div>
{/* Template Info */}
{templateInfo && (
<div className="flex items-center gap-2 text-sm">
<FileCode className="h-4 w-4 text-muted-foreground" />
<span className="text-muted-foreground">Template:</span>
<a
href={templateInfo.url}
target="_blank"
rel="noopener noreferrer"
className="flex items-center gap-1 text-primary hover:underline"
>
{templateInfo.name}
<ExternalLink className="h-3 w-3" />
</a>
</div>
)}
<div className="flex items-center gap-2 text-sm">
<FileCode className="h-4 w-4 text-muted-foreground" />
<span className="text-muted-foreground">Template:</span>
<a
href={templateInfo?.url}
target="_blank"
rel="noopener noreferrer"
className={cn("flex items-center gap-1", { "text-primary hover:underline": !!templateInfo })}
>
{templateInfo ? (
<>
<span>{templateInfo.name}</span>
<ExternalLink className="h-3 w-3" />
</>
) : (
isLoading ? (
<Skeleton className="h-4 w-24" />
) : (
<span>N/A</span>
)
)}
</a>
</div>
{/* Project Name */}
<div className="space-y-2">