import { useState, useEffect, useMemo } from 'react'; import { Card, CardHeader, CardTitle, CardContent } from "@/components/ui/card"; import { Badge } from "@/components/ui/badge"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetDescription, SheetFooter } from "@/components/ui/sheet"; import { ScrollArea } from "@/components/ui/scroll-area"; import { Button } from "@/components/ui/button"; import { Search, Rocket, Loader2, Info, ExternalLink, Github, Star } from "lucide-react"; import { toast } from "sonner"; import { apiFetch } from '@/lib/api'; import { useNodes } from '@/context/NodeContext'; export interface TemplateEnv { name: string; label?: string; default?: string; } export interface Template { type?: number; title: string; description: string; logo?: string; image?: string; ports?: string[]; volumes?: any[]; env?: TemplateEnv[]; categories?: string[]; github_url?: string; docs_url?: string; architectures?: string[]; stars?: number; source?: string; } interface AppStoreViewProps { onDeploySuccess: (stackName: string) => void; } export function AppStoreView({ onDeploySuccess }: AppStoreViewProps) { const { activeNode } = useNodes(); const [templates, setTemplates] = useState([]); const [searchQuery, setSearchQuery] = useState(''); const [selectedTemplate, setSelectedTemplate] = useState