"use client"; import { useState, useEffect } from "react"; import { Container } from "@/components/container"; import { Heading } from "@/components/heading"; import { Subheading } from "@/components/subheading"; import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Button } from "@/components/ui/button"; import { Badge } from "@/components/badge"; import { Share2, Save, Calculator, Info, CheckCircle2 } from "lucide-react"; export function RoiCalculator() { const [investment, setInvestment] = useState(10000); const [revenue, setRevenue] = useState(15000); const [roi, setRoi] = useState(0); const [profit, setProfit] = useState(0); const [saved, setSaved] = useState(false); useEffect(() => { const p = revenue - investment; const r = investment > 0 ? (p / investment) * 100 : 0; setProfit(p); setRoi(r); }, [investment, revenue]); const handleSave = () => { setSaved(true); setTimeout(() => setSaved(false), 2000); }; const handleShare = () => { if (navigator.share) { navigator.share({ title: 'ROI Calculation Result', text: `My ROI is ${roi.toFixed(2)}% with a profit of $${profit.toLocaleString()}`, url: window.location.href, }); } else { alert("Sharing not supported on this browser. Link copied to clipboard!"); navigator.clipboard.writeText(window.location.href); } }; return (
ROI Calculator Calculate Your Return on Investment Enter your investment and expected revenue to see your potential profit and ROI percentage instantly.
{/* Inputs */} Input Details Enter your financial figures below
setInvestment(Number(e.target.value))} placeholder="e.g. 10000" />
setRevenue(Number(e.target.value))} placeholder="e.g. 15000" />
{/* Results */} Calculation Results Your financial performance summary

ROI Percentage

= 0 ? 'text-green-600' : 'text-red-600'}`}> {roi.toFixed(2)}%

Net Profit

= 0 ? 'text-neutral-900' : 'text-red-600'}`}> ${profit.toLocaleString()}

Multiplier

{(revenue / (investment || 1)).toFixed(2)}x

{/* Explanation */}
How it works

Return on Investment (ROI) is a performance measure used to evaluate the efficiency or profitability of an investment. It measures the amount of return on an investment, relative to the investment’s cost.

ROI = ((Net Profit) / Cost of Investment) × 100

In this calculator, Net Profit is calculated as Total Revenue - Total Investment. A positive ROI indicates that the investment has generated more money than it cost, while a negative ROI indicates a loss.

); }