import React, { useEffect, useState } from "react"; import { CostBreakDownIcon, LightBulpIcon, ROISummaryIcon, ROISummaryProductName, SonarCrownIcon, } from "../../icons/analysis"; import SemiCircleProgress from "./SemiCircleProgress"; import { ArrowIcon } from "../../icons/ExportCommonIcons"; import SkeletonUI from "../../templates/SkeletonUI"; import { useROISummaryData } from "../../../store/builder/store"; const ROISummary = ({ roiSummaryData = { productName: "Product 1", roiPercentage: 133, paybackPeriod: 53, totalCost: "1,20,000", revenueGenerated: "2,80,000", netProfit: "1,60,000", netLoss: null, 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); }; function getCurrentDate() { const now = new Date(); const day = now.getDate().toString().padStart(2, "0"); const month = now.toLocaleString("en-GB", { month: "long" }); const year = now.getFullYear(); return `${day} ${month}, ${year}`; } const [isLoading, setIsLoading] = useState(false); const { roiSummary } = useROISummaryData(); useEffect(() => { if (roiSummary.productName) { // If productName is set, assume data is loaded setTimeout(() => { setIsLoading(false); }, 3000); // setIsLoading(false); } else { // If productName is empty, assume still loading setIsLoading(true); } }, [roiSummary]); return ( <> {!isLoading &&
ROI Summary
From {getCurrentDate()}
{!isLoading ? ( <>
Product :
{roiSummary.productName}
{roiSummary.roiPercentage}% ROI with payback in just {roiSummary.paybackPeriod} months
you're on track to hit it by
July 2029
Total Cost Incurred {roiSummary.totalCost}
Revenue Generated {roiSummary.revenueGenerated}
0 ? "profit" : "loss"}`} >
Net Profit
{roiSummary.netProfit > 0 ? roiSummary.netProfit : roiSummary.netLoss}
Cost Breakdown
{roiSummaryData.costBreakdown.map((row, index) => ( ))}
Item Unit Cost Labor Cost Total Cost Selling Price
{row.item} {row.unitCost} {row.laborCost} {row.totalCost} {row.sellingPrice}
{/*
How to improve ROI?
Increase CNC utilization by{" "} 10% to shave{" "} 0.5 months of payback period
*/} ) : ( //
No Data
)}
} ); }; export default ROISummary;