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
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
import { PlatformAnalyticsReport } from '@activepieces/shared';
import { t } from 'i18next';
import { Clock } from 'lucide-react';
import { formatUtils } from '@/lib/format-utils';
import { impactRunsUtils } from '../lib/impact-runs-utils';
import { MetricCard, MetricCardSkeleton } from './metric-card';
type TimeSavedMetricProps = {
report?: PlatformAnalyticsReport;
isLoading: boolean;
};
export const TimeSavedMetric = ({
report,
isLoading,
}: TimeSavedMetricProps) => {
const flows = report?.flows ?? [];
const flowsWithTimeSaved = flows.filter(
(flow) =>
flow.timeSavedPerRun !== null &&
flow.timeSavedPerRun !== undefined &&
flow.timeSavedPerRun !== 0,
);
const atLeastOneTimeSavedSet = flowsWithTimeSaved.length > 0;
const runsByFlow = impactRunsUtils.sumRunsByFlow(report?.runs ?? []);
const totalSeconds = atLeastOneTimeSavedSet
? flowsWithTimeSaved.reduce((acc, flow) => {
const totalRuns = runsByFlow.get(flow.flowId) ?? 0;
return acc + (flow.timeSavedPerRun ?? 0) * totalRuns;
}, 0)
: 0;
const totalMinutes = Math.round(totalSeconds / 60);
const equivalentWorkdays = Math.round(totalSeconds / 3600 / 8);
if (isLoading) {
return <MetricCardSkeleton />;
}
if (!atLeastOneTimeSavedSet) {
return (
<MetricCard
icon={Clock}
title={t('Time Saved')}
value="N/A"
description={t(
'Estimated hours saved through automation in the last 3 months. Each automated task saves valuable employee time that can be redirected to high-impact work.',
)}
subtitle={t('{days} workdays saved', {
days: 'N/A',
})}
iconColor="text-swatch-8-mark"
iconBgColor="bg-swatch-8-surface"
/>
);
}
return (
<MetricCard
icon={Clock}
title={t('Time Saved')}
value={`${formatUtils.formatNumber(totalMinutes)} mins`}
description={t('Total time saved by automation')}
subtitle={t('{days} workdays saved', {
days: equivalentWorkdays.toLocaleString(),
})}
iconColor="text-success-11"
iconBgColor="bg-success-3"
/>
);
};