import React, { useState, useEffect } from 'react'; import { Link } from 'react-router-dom'; import api from '../services/api'; import { PlusIcon, ArrowPathIcon } from '@heroicons/react/24/outline'; const Dashboard = () => { const [recentWorkflows, setRecentWorkflows] = useState([]); const [stats, setStats] = useState({ totalWorkflows: 0, executionsToday: 0, activeWebhooks: 0 }); const [loading, setLoading] = useState(true); useEffect(() => { const fetchDashboardData = async () => { try { // Fetch workflows const workflowsResponse = await api.get('/api/workflows'); const workflows = workflowsResponse.data.workflows || []; // Sort by updated_at and take the 5 most recent const sortedWorkflows = [...workflows].sort( (a, b) => new Date(b.updated_at) - new Date(a.updated_at) ).slice(0, 5); setRecentWorkflows(sortedWorkflows); // Set stats setStats({ totalWorkflows: workflows.length, executionsToday: 0, // This would come from a separate API endpoint activeWebhooks: workflows.reduce((count, workflow) => { // Count webhook nodes in each workflow const webhookNodes = workflow.nodes.filter(node => node.type === 'webhook'); return count + webhookNodes.length; }, 0) }); } catch (error) { console.error('Error fetching dashboard data:', error); } finally { setLoading(false); } }; fetchDashboardData(); }, []); return (
You don't have any workflows yet.
Create your first workflow