import React, { useState, useEffect } from 'react';
import {
TrendingUp, Users, DollarSign, Target, Calendar,
ArrowUpRight, ArrowDownRight, Plus, Filter,
BarChart3, PieChart, Zap, Award, Bell
} from 'lucide-react';
import {
BarChart, Bar, XAxis, YAxis, CartesianGrid,
Tooltip, ResponsiveContainer, LineChart, Line,
PieChart as RechartsPie, Pie, Cell
} from 'recharts';
interface Deal {
id: string;
company: string;
contact: string;
value: number;
stage: 'Lead' | 'Discovery' | 'Proposal' | 'Negotiation' | 'Closed Won' | 'Closed Lost';
probability: number;
closeDate: string;
lastUpdated: string;
}
interface PipelineStage {
name: string;
count: number;
value: number;
color: string;
}
const STAGE_COLORS = {
'Lead': '#64748b',
'Discovery': '#3b82f6',
'Proposal': '#8b5cf6',
'Negotiation': '#f59e0b',
'Closed Won': '#10b981',
'Closed Lost': '#ef4444'
};
const INITIAL_DEALS: Deal[] = [
{ id: 'd1', company: 'Acme Dynamics', contact: 'Sarah Chen', value: 124000, stage: 'Negotiation', probability: 85, closeDate: '2026-03-12', lastUpdated: '2h ago' },
{ id: 'd2', company: 'Nexus Logistics', contact: 'Marcus Rivera', value: 89000, stage: 'Proposal', probability: 65, closeDate: '2026-03-28', lastUpdated: 'Yesterday' },
{ id: 'd3', company: 'Helios Health', contact: 'Priya Patel', value: 245000, stage: 'Discovery', probability: 40, closeDate: '2026-04-05', lastUpdated: '4d ago' },
{ id: 'd4', company: 'Vanguard Retail', contact: 'Liam Moreau', value: 67000, stage: 'Lead', probability: 20, closeDate: '2026-05-10', lastUpdated: '1w ago' },
{ id: 'd5', company: 'Pulse Analytics', contact: 'Elena Vargas', value: 185000, stage: 'Closed Won', probability: 100, closeDate: '2026-02-18', lastUpdated: 'Feb 20' },
];
const MONTHLY_REVENUE = [
{ month: 'Oct', revenue: 184000, target: 210000 },
{ month: 'Nov', revenue: 231000, target: 225000 },
{ month: 'Dec', revenue: 198000, target: 240000 },
{ month: 'Jan', revenue: 267000, target: 260000 },
{ month: 'Feb', revenue: 312000, target: 290000 },
];
const PIPELINE_BY_STAGE: PipelineStage[] = [
{ name: 'Lead', count: 18, value: 1240000, color: '#64748b' },
{ name: 'Discovery', count: 12, value: 2890000, color: '#3b82f6' },
{ name: 'Proposal', count: 9, value: 1840000, color: '#8b5cf6' },
{ name: 'Negotiation', count: 7, value: 3120000, color: '#f59e0b' },
{ name: 'Closed Won', count: 14, value: 4520000, color: '#10b981' },
];
export default function App() {
const [deals, setDeals] = useState<Deal[]>(INITIAL_DEALS);
const [selectedStage, setSelectedStage] = useState<string>('All');
const [searchTerm, setSearchTerm] = useState('');
const [showNewDealModal, setShowNewDealModal] = useState(false);
const [newDeal, setNewDeal] = useState({
company: '',
contact: '',
value: '',
stage: 'Lead' as Deal['stage'],
probability: 30,
closeDate: '2026-04-15'
});
// Calculate KPI metrics
const totalPipeline = deals.reduce((sum, deal) => sum + deal.value, 0);
const wonDeals = deals.filter(d => d.stage === 'Closed Won');
const totalWon = wonDeals.reduce((sum, deal) => sum + deal.value, 0);
const avgWinRate = Math.round((wonDeals.length / deals.length) * 100) || 42;
const forecastedRevenue = Math.round(totalPipeline * 0.67);
const filteredDeals = deals
.filter(deal => {
const matchesSearch = deal.company.toLowerCase().includes(searchTerm.toLowerCase()) ||
deal.contact.toLowerCase().includes(searchTerm.toLowerCase());
const matchesStage = selectedStage === 'All' || deal.stage === selectedStage;
return matchesSearch && matchesStage;
})
.sort((a, b) => b.value - a.value);
const handleAddDeal = () => {
if (!newDeal.company || !newDeal.contact) return;
const deal: Deal = {
id: 'deal-' + Date.now(),
company: newDeal.company,
contact: newDeal.contact,
value: parseInt(newDeal.value) || 45000,
stage: newDeal.stage,
probability: newDeal.probability,
closeDate: newDeal.closeDate,
lastUpdated: 'Just now'
};
setDeals([deal, ...deals]);
setShowNewDealModal(false);
setNewDeal({
company: '', contact: '', value: '', stage: 'Lead', probability: 30, closeDate: '2026-04-15'
});
};
const updateDealStage = (id: string, newStage: Deal['stage']) => {
setDeals(prev => prev.map(deal => {
if (deal.id === id) {
const probability = newStage === 'Closed Won' ? 100 :
newStage === 'Closed Lost' ? 0 :
newStage === 'Negotiation' ? 75 :
newStage === 'Proposal' ? 55 : 35;
return { ...deal, stage: newStage, probability, lastUpdated: 'Just now' };
}
return deal;
}));
};
const getStageColor = (stage: string) => {
return STAGE_COLORS[stage as keyof typeof STAGE_COLORS] || '#64748b';
};
return (
<div className="min-h-screen bg-zinc-950 text-zinc-200">
{/* Top Navigation */}
<nav className="border-b border-zinc-800 bg-zinc-950/80 backdrop-blur-lg fixed w-full z-50">
<div className="max-w-screen-2xl mx-auto px-8 py-5 flex items-center justify-between">
<div className="flex items-center gap-x-4">
<div className="flex items-center gap-x-3">
<div className="w-9 h-9 bg-gradient-to-br from-violet-500 to-fuchsia-500 rounded-2xl flex items-center justify-center">
<BarChart3 className="w-5 h-5 text-white" />
</div>
<div>
<div className="font-semibold text-2xl tracking-tighter text-white">pipeline<span className="text-violet-400">forge</span></div>
<div className="text-[10px] text-zinc-500 -mt-1 font-mono">B2B REVENUE OS</div>
</div>
</div>
</div>
<div className="flex items-center gap-x-8 text-sm">
<div className="flex items-center gap-x-8 text-zinc-400">
<a href="#" className="hover:text-white transition-colors font-medium flex items-center gap-x-1.5">
<BarChart3 className="w-4 h-4" /> Pipeline
</a>
<a href="#" className="hover:text-white transition-colors font-medium">Forecast</a>
<a href="#" className="hover:text-white transition-colors font-medium">Deals</a>
<a href="#" className="hover:text-white transition-colors font-medium">Insights</a>
</div>
<div className="flex items-center gap-x-4">
<div className="flex items-center bg-zinc-900 border border-zinc-800 rounded-3xl px-4 py-1.5 text-xs gap-x-2 cursor-pointer">
<div className="w-2 h-2 bg-emerald-400 rounded-full animate-pulse"></div>
<span className="font-mono text-emerald-400">Q1 2026</span>
</div>
<div className="bg-zinc-900 text-white text-xs font-medium px-5 py-2.5 rounded-3xl flex items-center gap-x-2 hover:bg-white hover:text-zinc-900 transition-all cursor-pointer">
<Plus className="w-4 h-4" />
<span>New Deal</span>
</div>
<div className="w-9 h-9 bg-zinc-800 rounded-2xl flex items-center justify-center relative cursor-pointer">
<Bell className="w-4 h-4" />
<div className="absolute -top-0.5 -right-0.5 w-4 h-4 bg-rose-500 text-[9px] font-mono rounded-full flex items-center justify-center">3</div>
</div>
<div className="flex items-center gap-x-3 pl-6 border-l border-zinc-800">
<div className="text-right">
<div className="text-sm font-semibold">Alex Rivera</div>
<div className="text-[10px] text-zinc-500 -mt-0.5">Head of Sales • Acme</div>
</div>
<div className="w-9 h-9 bg-orange-300 rounded-2xl overflow-hidden">
<img src="https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?auto=format&fit=crop&w=100&q=80" alt="Alex" />
</div>
</div>
</div>
</div>
</div>
</nav>
<div className="pt-20 max-w-screen-2xl mx-auto px-8">
{/* KPI Header */}
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 pb-8">
<div className="glass border border-zinc-800 rounded-3xl p-6">
<div className="flex justify-between">
<div>
<div className="uppercase text-xs tracking-[0.5px] text-zinc-500 font-medium">Total Pipeline</div>
<div className="text-4xl font-semibold text-white mt-3 tracking-tighter">
${(totalPipeline / 1000).toFixed(0)}k
</div>
</div>
<div className="w-11 h-11 bg-emerald-500/10 rounded-2xl flex items-center justify-center">
<Target className="w-6 h-6 text-emerald-400" />
</div>
</div>
<div className="mt-6 text-emerald-400 text-sm flex items-center gap-x-1">
<ArrowUpRight className="w-4 h-4" /> +18% from last month
</div>
</div>
<div className="glass border border-zinc-800 rounded-3xl p-6">
<div className="flex justify-between">
<div>
<div className="uppercase text-xs tracking-[0.5px] text-zinc-500 font-medium">MRR Booked</div>
<div className="text-4xl font-semibold text-white mt-3 tracking-tighter">
${(totalWon / 1000).toFixed(0)}k
</div>
</div>
<div className="w-11 h-11 bg-violet-500/10 rounded-2xl flex items-center justify-center">
<DollarSign className="w-6 h-6 text-violet-400" />
</div>
</div>
<div className="mt-6 text-emerald-400 text-sm flex items-center gap-x-1">
<ArrowUpRight className="w-4 h-4" /> Win rate {avgWinRate}%
</div>
</div>
<div className="glass border border-zinc-800 rounded-3xl p-6">
<div className="flex justify-between">
<div>
<div className="uppercase text-xs tracking-[0.5px] text-zinc-500 font-medium">Forecasted Q1</div>
<div className="text-4xl font-semibold text-white mt-3 tracking-tighter">
${(forecastedRevenue / 1000).toFixed(0)}k
</div>
</div>
<div className="w-11 h-11 bg-amber-500/10 rounded-2xl flex items-center justify-center">
<TrendingUp className="w-6 h-6 text-amber-400" />
</div>
</div>
<div className="mt-6 text-amber-400 text-sm flex items-center gap-x-1">
67% of pipeline expected to close
</div>
</div>
<div className="glass border border-zinc-800 rounded-3xl p-6 relative overflow-hidden">
<div className="flex justify-between">
<div>
<div className="uppercase text-xs tracking-[0.5px] text-zinc-500 font-medium">Active Deals</div>
<div className="text-4xl font-semibold text-white mt-3 tracking-tighter">{deals.length}</div>
</div>
<div className="w-11 h-11 bg-sky-500/10 rounded-2xl flex items-center justify-center">
<Users className="w-6 h-6 text-sky-400" />
</div>
</div>
<div className="absolute -bottom-6 -right-6 text-[120px] font-black text-zinc-800/60 select-none">42</div>
</div>
</div>
<div className="grid grid-cols-12 gap-4">
{/* Pipeline Overview */}
<div className="col-span-12 lg:col-span-7 glass border border-zinc-800 rounded-3xl p-7">
<div className="flex items-center justify-between mb-6">
<div>
<div className="font-semibold text-xl text-white">Pipeline by Stage</div>
<div className="text-zinc-400 text-sm">Current active opportunities • Updated moments ago</div>
</div>
<div className="flex items-center gap-x-2 text-xs bg-zinc-900 px-4 h-9 rounded-3xl border border-zinc-700">
<Filter className="w-3.5 h-3.5" />
<select
value={selectedStage}
onChange={(e) => setSelectedStage(e.target.value)}
className="bg-transparent focus:outline-none text-zinc-300 cursor-pointer"
>
<option value="All">All Stages</option>
{Object.keys(STAGE_COLORS).map(stage => (
<option key={stage} value={stage}>{stage}</option>
))}
</select>
</div>
</div>
<div className="grid grid-cols-5 gap-3">
{PIPELINE_BY_STAGE.map((stage, index) => (
<div
key={index}
onClick={() => setSelectedStage(stage.name)}
className={`pipeline-card rounded-3xl p-5 border cursor-pointer transition-all ${selectedStage === stage.name || selectedStage === 'All' ? 'border-white/30 bg-white/5' : 'border-transparent hover:border-white/10'}`}
>
<div className="flex justify-between items-start">
<div>
<div className="text-xs uppercase font-mono tracking-widest text-zinc-500">{stage.name}</div>
<div className="text-5xl font-semibold text-white mt-3 tracking-tighter">{stage.count}</div>
</div>
<div className="w-7 h-7 rounded-2xl flex items-center justify-center" style={{ backgroundColor: stage.color + '30' }}>
<div className="w-3 h-3 rounded-full" style={{ backgroundColor: stage.color }} />
</div>
</div>
<div className="mt-8 text-xl font-semibold text-white">
${(stage.value / 1000000).toFixed(1)}M
</div>
<div className="text-xs text-zinc-500">Avg deal size $142k</div>
</div>
))}
</div>
</div>
{/* Monthly Revenue Trend */}
<div className="col-span-12 lg:col-span-5 glass border border-zinc-800 rounded-3xl p-7">
<div className="flex justify-between items-center mb-6">
<div className="font-semibold text-lg">Revenue Trend</div>
<div className="text-xs px-4 py-2 bg-zinc-900 rounded-3xl border border-zinc-700 flex items-center gap-x-2">
<span className="text-emerald-400">↑ 24%</span>
<span className="text-zinc-500">YoY</span>
</div>
</div>
<ResponsiveContainer width="100%" height={220}>
<LineChart data={MONTHLY_REVENUE}>
<CartesianGrid strokeDasharray="2 2" stroke="#27272a" />
<XAxis dataKey="month" stroke="#3f3f46" fontSize={11} />
<YAxis stroke="#3f3f46" fontSize={11} />
<Tooltip
contentStyle={{
backgroundColor: '#18181b',
border: '1px solid #3f3f46',
borderRadius: '12px'
}}
/>
<Line
type="natural"
dataKey="revenue"
stroke="#a5b4fc"
strokeWidth={3}
dot={{ fill: '#6366f1', r: 4 }}
/>
<Line
type="natural"
dataKey="target"
stroke="#4b5563"
strokeWidth={2}
strokeDasharray="3 2"
/>
</LineChart>
</ResponsiveContainer>
</div>
{/* Active Deals Table */}
<div className="col-span-12 glass border border-zinc-800 rounded-3xl overflow-hidden">
<div className="px-8 py-6 border-b border-zinc-800 flex items-center justify-between bg-zinc-900">
<div className="flex items-center gap-x-4">
<div className="font-semibold text-xl">Active Pipeline</div>
<div className="text-xs bg-zinc-800 px-3 py-1 rounded-3xl text-zinc-400 font-mono">{filteredDeals.length} deals • ${Math.round(totalPipeline/1000)}k</div>
</div>
<div className="flex items-center gap-x-3">
<input
type="text"
placeholder="Search company or contact..."
value={searchTerm}
onChange={(e) => setSearchTerm(e.target.value)}
className="bg-zinc-900 border border-zinc-700 focus:border-violet-500 rounded-3xl px-5 py-2.5 text-sm w-72 focus:outline-none transition"
/>
<button
onClick={() => setShowNewDealModal(true)}
className="flex items-center gap-x-2 bg-white text-zinc-950 hover:bg-amber-300 transition font-semibold px-6 py-2.5 rounded-3xl text-sm"
>
<Plus className="w-4 h-4" /> New Opportunity
</button>
</div>
</div>
<div className="overflow-x-auto">
<table className="w-full">
<thead>
<tr className="border-b border-zinc-800 text-xs font-mono text-zinc-400">
<th className="py-5 px-8 text-left font-normal">COMPANY</th>
<th className="py-5 px-8 text-left font-normal">CONTACT</th>
<th className="py-5 px-8 text-left font-normal">STAGE</th>
<th className="py-5 px-8 text-right font-normal">VALUE</th>
<th className="py-5 px-8 text-center font-normal">PROBABILITY</th>
<th className="py-5 px-8 text-left font-normal">CLOSE DATE</th>
<th className="py-5 px-8 text-left font-normal">UPDATED</th>
<th></th>
</tr>
</thead>
<tbody className="divide-y divide-zinc-800 text-sm">
{filteredDeals.map((deal) => (
<tr key={deal.id} className="group hover:bg-zinc-900/70 transition">
<td className="px-8 py-6 font-medium text-white">{deal.company}</td>
<td className="px-8 py-6 text-zinc-400">{deal.contact}</td>
<td className="px-8 py-6">
<div
onClick={() => {
const stages: Deal['stage'][] = ['Lead','Discovery','Proposal','Negotiation','Closed Won'];
const currentIdx = stages.indexOf(deal.stage);
const nextStage = stages[(currentIdx + 1) % stages.length];
updateDealStage(deal.id, nextStage);
}}
className="inline-flex items-center gap-x-2 px-4 py-1 rounded-3xl text-xs font-medium cursor-pointer hover:scale-105 active:scale-95 transition border"
style={{
color: getStageColor(deal.stage),
borderColor: getStageColor(deal.stage) + '40',
backgroundColor: getStageColor(deal.stage) + '15'
}}
>
{deal.stage}
</div>
</td>
<td className="px-8 py-6 text-right font-mono font-semibold text-emerald-300">
${(deal.value / 1000).toFixed(0)}k
</td>
<td className="px-8 py-6">
<div className="flex items-center justify-center gap-x-3">
<div className="h-2 w-20 bg-zinc-800 rounded-full overflow-hidden">
<div
className="h-full bg-white rounded-r-full"
style={{ width: `${deal.probability}%` }}
/>
</div>
<span className="font-mono text-xs w-8 text-right">{deal.probability}%</span>
</div>
</td>
<td className="px-8 py-6 text-zinc-400 font-light">{deal.closeDate}</td>
<td className="px-8 py-6 text-xs text-zinc-500 font-light">{deal.lastUpdated}</td>
<td className="px-8 py-6 text-right">
<button className="text-xs bg-zinc-800 hover:bg-zinc-700 px-5 py-2 rounded-3xl transition">View</button>
</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
</div>
</div>
{/* New Deal Modal */}
{showNewDealModal && (
<div className="fixed inset-0 bg-black/80 flex items-center justify-center z-[100]">
<div className="glass border border-zinc-700 rounded-3xl w-full max-w-md p-8">
<div className="flex justify-between items-center mb-6">
<div className="text-xl font-semibold">Create New Deal</div>
<button onClick={() => setShowNewDealModal(false)} className="text-zinc-400 hover:text-white">✕</button>
</div>
<div className="space-y-6">
<div>
<label className="block text-xs font-mono text-zinc-400 mb-2">COMPANY NAME</label>
<input
type="text"
value={newDeal.company}
onChange={(e) => setNewDeal({...newDeal, company: e.target.value})}
className="bg-zinc-900 border border-zinc-700 focus:border-white w-full rounded-2xl px-5 py-4 outline-none text-white placeholder:text-zinc-500"
placeholder="Aether Systems"
/>
</div>
<div>
<label className="block text-xs font-mono text-zinc-400 mb-2">PRIMARY CONTACT</label>
<input
type="text"
value={newDeal.contact}
onChange={(e) => setNewDeal({...newDeal, contact: e.target.value})}
className="bg-zinc-900 border border-zinc-700 focus:border-white w-full rounded-2xl px-5 py-4 outline-none text-white placeholder:text-zinc-500"
placeholder="Jordan Hale"
/>
</div>
<div className="grid grid-cols-2 gap-4">
<div>
<label className="block text-xs font-mono text-zinc-400 mb-2">DEAL VALUE</label>
<div className="relative">
<div className="absolute left-5 top-4 text-zinc-400">$</div>
<input
type="number"
value={newDeal.value}
onChange={(e) => setNewDeal({...newDeal, value: e.target.value})}
className="bg-zinc-900 border border-zinc-700 focus:border-white w-full rounded-2xl px-8 py-4 outline-none text-white"
placeholder="125000"
/>
</div>
</div>
<div>
<label className="block text-xs font-mono text-zinc-400 mb-2">STAGE</label>
<select
value={newDeal.stage}
onChange={(e) => setNewDeal({...newDeal, stage: e.target.value as Deal['stage']})}
className="bg-zinc-900 border border-zinc-700 focus:border-white w-full rounded-2xl px-5 py-4 outline-none text-white"
>
<option value="Lead">Lead</option>
<option value="Discovery">Discovery</option>
<option value="Proposal">Proposal</option>
<option value="Negotiation">Negotiation</option>
</select>
</div>
</div>
<div>
<label className="block text-xs font-mono text-zinc-400 mb-2">EST. CLOSE DATE</label>
<input
type="date"
value={newDeal.closeDate}
onChange={(e) => setNewDeal({...newDeal, closeDate: e.target.value})}
className="bg-zinc-900 border border-zinc-700 focus:border-white w-full rounded-2xl px-5 py-4 outline-none text-white"
/>
</div>
<div className="pt-4">
<button
onClick={handleAddDeal}
className="bg-white hover:bg-amber-200 transition text-zinc-950 w-full py-4 rounded-3xl font-semibold flex items-center justify-center gap-x-2"
>
<Zap className="w-4 h-4" /> CREATE DEAL & ADD TO PIPELINE
</button>
</div>
</div>
</div>
</div>
)}
<div className="h-16"></div>
</div>
);
}
Files built: index.html, src/index.css