Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

1.4 KB
Raw Blame
import { PlatformAnalyticsReport } from '@activepieces/shared';
import { t } from 'i18next';
import { Clock } from 'lucide-react';

import { formatUtils } from '@/lib/format-utils';

import { AnalyticsAreaChart } from './analytics-area-chart';

type TimeSavedChartProps = {
  report?: PlatformAnalyticsReport;
};

export function TimeSavedChart({ report }: TimeSavedChartProps) {
  const chartData =
    report?.runs
      .map((data) => ({
        date: data.day,
        minutesSaved:
          (report?.flows.find((flow) => flow.flowId === data.flowId)
            ?.timeSavedPerRun ?? 0) * data.runs,
      }))
      .sort(
        (a, b) => new Date(a.date).getTime() - new Date(b.date).getTime(),
      ) ?? [];

  return (
    <AnalyticsAreaChart
      title={t('Time Saved Over Time')}
      subtitle={t('Track how much time your automations are saving')}
      tooltipLabel={t('Time Saved')}
      dataKey="minutesSaved"
      color="var(--swatch-8-mark)"
      gradientId="fillTimeSaved"
      chartData={chartData}
      isLoading={!report}
      emptyIcon={<Clock className="h-10 w-10 text-gray-9" />}
      emptyText={t(
        'No time saved yet. Data will appear here once your flows start running.',
      )}
      downloadFilename="time-saved"
      yAxisFormatter={(v) => formatUtils.formatToHoursAndMinutes(v)}
      tooltipFormatter={(v) => formatUtils.formatToHoursAndMinutes(v)}
    />
  );
}