import { useEffect, useState } from "react"; import { useMachineCount, useMachineUptime, useMaterialCycle, useProductionCapacityData, useThroughPutData } from "../../../store/builder/store"; import { ThroughputSummaryIcon, } from "../../icons/analysis"; import SkeletonUI from "../../templates/SkeletonUI"; const ProductionCapacity = ({ avgProcessTime = "28.4 Secs/unit", machineUtilization = "78%", throughputValue = 128, timeRange = { startTime: "08:00 AM", endTime: "09:00 AM" }, }) => { const { machineActiveTime } = useMachineUptime(); const { materialCycleTime } = useMaterialCycle(); const { throughputData } = useThroughPutData() const { productionCapacityData } = useProductionCapacityData() const progressPercent = machineActiveTime; const totalBars = 6; const barsToFill = Math.floor((progressPercent / 100) * totalBars); const partialFillPercent = ((progressPercent / 100) * totalBars - barsToFill) * 100; const [isLoading, setIsLoading] = useState(false); useEffect(() => { console.log('throughputData: ', throughputData > 0); if (throughputData > 0) { setIsLoading(false); } else { setIsLoading(true); } }, [throughputData]) return ( <> {!isLoading &&
Throughput Summary
{timeRange.startTime} - {timeRange.endTime}
{!isLoading ? ( <>
{throughputData} Units/hour
{/* Dynamic Progress Bar */}
{[...Array(totalBars)].map((_, i) => (
{i < barsToFill ? (
) : i === barsToFill ? (
) : null}
))}
Avg. Process Time {materialCycleTime} secs/unit
Machine Utilization {machineActiveTime} {/* {machineActiveTime} */}
) : ( )}
} ); }; export default ProductionCapacity;