Dwinzo_dev/app/src/components/ui/analysis/ROISummary.tsx

206 lines
6.4 KiB
TypeScript
Raw Normal View History

2025-04-29 12:24:36 +00:00
import React, { useState } from "react";
2025-05-03 04:33:39 +00:00
import {
CostBreakDownIcon,
LightBulpIcon,
ROISummaryIcon,
ROISummaryProductName,
SonarCrownIcon,
} from "../../icons/analysis";
2025-04-29 05:04:21 +00:00
import SemiCircleProgress from "./SemiCircleProgress";
import { ArrowIcon } from "../../icons/ExportCommonIcons";
2025-04-29 05:04:21 +00:00
2025-04-29 12:24:36 +00:00
const ROISummary = ({
roiSummaryData = {
productName: "Product name",
roiPercentage: 133,
paybackPeriod: 50.3,
totalCost: "₹ 1,20,000",
revenueGenerated: "₹ 2,80,000",
netProfit: "₹ 1,60,000",
costBreakdown: [
{
item: "Raw Material A",
unitCost: "₹ 10/unit",
laborCost: "₹ 0",
totalCost: "₹ 1000",
sellingPrice: "₹ 1500",
},
{
item: "Labor",
unitCost: "₹ 10/unit",
laborCost: "₹ 500",
totalCost: "₹ 500",
sellingPrice: "N/A",
},
{
item: "Product 1",
unitCost: "₹ 10/unit",
laborCost: "₹ 200",
totalCost: "₹ 200",
sellingPrice: "₹ 2000",
},
{
item: "Machine",
unitCost: "-",
laborCost: "-",
totalCost: "₹ 20,000",
sellingPrice: "N/A",
},
{
item: "Total",
unitCost: "-",
laborCost: "-",
totalCost: "₹ 1,20,000",
sellingPrice: "-",
},
{
item: "Net Profit",
unitCost: "-",
laborCost: "-",
totalCost: "₹ 1,60,000",
sellingPrice: "-",
},
],
},
}) => {
const [isTableOpen, setIsTableOpen] = useState(false); // State to handle the table open/close
// Function to toggle the breakdown table visibility
const toggleTable = () => {
setIsTableOpen(!isTableOpen);
};
2025-04-29 05:04:21 +00:00
return (
<div className="roiSummary-container analysis-card">
<div className="roiSummary-wrapper analysis-card-wrapper">
<div className="card-header">
<div className="header">
<div className="main-header">ROI Summary</div>
<div className="sub-header">From 24 November, 2025</div>
</div>
<div className="icon-wrapper">
<ROISummaryIcon />
</div>
</div>
<div className="product-info">
2025-05-03 04:33:39 +00:00
<ROISummaryProductName />
2025-04-29 05:04:21 +00:00
<div className="product-label">Product :</div>
2025-04-29 12:24:36 +00:00
<div className="product-name">{roiSummaryData.productName}</div>
2025-04-29 05:04:21 +00:00
</div>
<div className="playBack">
2025-05-03 04:33:39 +00:00
<SonarCrownIcon />
2025-04-29 05:04:21 +00:00
<div className="icon"></div>
<div className="info">
2025-04-29 12:24:36 +00:00
<span>+{roiSummaryData.roiPercentage}%</span> ROI with payback in
just <span>{roiSummaryData.paybackPeriod}</span> months
2025-04-29 05:04:21 +00:00
</div>
</div>
<div className="roi-details">
2025-04-29 12:24:36 +00:00
<div className="progress-wrapper">
<SemiCircleProgress />
<div className="content">
you're on track to hit it by
<div className="key">July 2029</div>
</div>
</div>
2025-04-29 05:04:21 +00:00
<div className="metrics">
<div className="metric-wrapper">
<div className="metric-item">
<span className="metric-label">Total Cost Incurred</span>
2025-04-29 12:24:36 +00:00
<span className="metric-value">{roiSummaryData.totalCost}</span>
2025-04-29 05:04:21 +00:00
</div>
<div className="metric-item">
<span className="metric-label">Revenue Generated</span>
2025-04-29 12:24:36 +00:00
<span className="metric-value">
{roiSummaryData.revenueGenerated}
</span>
2025-04-29 05:04:21 +00:00
</div>
</div>
<div className="metric-item net-profit">
2025-05-03 11:58:46 +00:00
<span className="metric-label">
<span></span> Net Profit
</span>
2025-04-29 12:24:36 +00:00
<span className="metric-value">{roiSummaryData.netProfit}</span>
2025-04-29 05:04:21 +00:00
</div>
</div>
</div>
<div className="cost-breakdown">
2025-04-29 12:24:36 +00:00
<div className="breakdown-header" onClick={toggleTable}>
<div className="section-wrapper">
2025-05-03 04:33:39 +00:00
<CostBreakDownIcon />
2025-04-29 12:24:36 +00:00
<span className="section-title">Cost Breakdown</span>
</div>
<span className={`expand-icon ${isTableOpen ? "open" : ""}`}>
<ArrowIcon />
2025-04-29 12:24:36 +00:00
</span>
2025-04-29 05:04:21 +00:00
</div>
2025-04-29 12:24:36 +00:00
<div
className={`breakdown-table-wrapper ${
isTableOpen ? "open" : "closed"
}`}
style={{
transition: "max-height 0.3s ease-in-out",
overflow: "hidden",
}}
>
<table className="breakdown-table">
<thead>
<tr>
<th>Item</th>
<th>Unit Cost</th>
<th>Labor Cost</th>
<th>Total Cost</th>
<th>Selling Price</th>
2025-04-29 05:04:21 +00:00
</tr>
2025-04-29 12:24:36 +00:00
</thead>
<tbody>
{roiSummaryData.costBreakdown.map((row, index) => (
<tr
key={index}
className={
row.item === "Total"
? "total-row"
: row.item === "Net Profit"
? "net-profit-row"
: ""
}
>
<td>{row.item}</td>
<td>{row.unitCost}</td>
<td>{row.laborCost}</td>
<td>{row.totalCost}</td>
<td>{row.sellingPrice}</td>
</tr>
))}
</tbody>
</table>
</div>
2025-04-29 05:04:21 +00:00
</div>
<div className="tips-section">
<div className="tip-header">
2025-05-03 04:33:39 +00:00
<span className="lightbulb-icon">
<LightBulpIcon />
</span>
2025-04-29 05:04:21 +00:00
<span className="tip-title">How to improve ROI?</span>
</div>
<div className="tip-description">
Increase CNC utilization by <span className="highlight">10%</span>{" "}
to shave <span className="highlight">0.5</span> months of payback
period
2025-05-03 11:58:46 +00:00
<div className="placeHolder-wrapper">
<div className="placeHolder"></div>
<div className="placeHolder"></div>
</div>
2025-04-29 05:04:21 +00:00
</div>
<button className="get-tips-button">
<div className="btn">Get ROI Boost Tips</div>
</button>
</div>
</div>
</div>
);
};
export default ROISummary;