import React, { useMemo } from 'react'; import { ArrowUpRight, LayoutGrid } from 'lucide-react'; import { useWorkflows, type Workflow } from '../../contexts/WorkflowsContext'; import { useApplyWorkflow } from '../../hooks/useApplyWorkflow'; interface WorkflowsHomeProps { onBrowseAll: () => void; } const MAX_CARDS = 4; /** Empty-state grid of pinned / most-used workflows with a "Browse all" link. */ const WorkflowsHome: React.FC = ({ onBrowseAll }) => { const { workflows } = useWorkflows(); const applyWorkflow = useApplyWorkflow(); // Order: pinned first, then most-used, then recent (Array.sort is stable, so // ties keep the underlying built-ins-then-user ordering). const shown = useMemo(() => { return [...workflows] .sort((a, b) => Number(b.pinned) - Number(a.pinned) || (b.useCount ?? 0) - (a.useCount ?? 0)) .slice(0, MAX_CARDS); }, [workflows]); return (
Workflows
{shown.map((workflow) => ( ))}
); }; export default React.memo(WorkflowsHome);