import React, { useState } from "react";
import {
CartBagIcon,
ExpandIcon,
IndicationArrow,
SimulationStatusIcon,
StorageCapacityIcon,
} from "../../icons/SimulationIcons";
import { usePlayButtonStore } from "../../../store/usePlayButtonStore";
interface AssetDetailsCardInterface {
name: string;
status: string;
enableStatue?: boolean;
count?: number;
totalCapacity?: number;
assetDetails?: {
assetName: string;
const: string;
performance: string;
};
}
const GetStatus = (status: string) => {
// "idle" | "running" | "stopped" | "disabled" | "error"
switch (status) {
case "idle":
return (
);
case "running":
return (
);
case "stopped":
return (
);
}
};
const AssetDetailsCard: React.FC = ({
name,
enableStatue = true,
status,
count,
totalCapacity,
assetDetails,
}) => {
const [moreDetails, setMoreDetails] = useState(false);
// hooks
const { isPlaying } = usePlayButtonStore();
return (
{name}
{enableStatue && (
{GetStatus(status)}
)}
{!enableStatue && totalCapacity && (
Storage/Inventory
)}
{totalCapacity && (
{count?.toString()}/{totalCapacity}
{/* progress ui */}
{[...Array(5)].map((_, i) => {
const percentage = (count ?? 0 / totalCapacity) * 100;
const start = i * 20;
const end = (i + 1) * 20;
// fill amount: 0 to 100
let fillPercent = 0;
if (percentage >= end) {
fillPercent = 100;
} else if (percentage <= start) {
fillPercent = 1;
} else {
fillPercent = ((percentage - start) / 20) * 100;
}
return (
);
})}
{Math.round((count ?? 0 / totalCapacity) * 100).toString()}%
)}
{status === "running" && (
)}
);
};
export default AssetDetailsCard;