updated comparision

This commit is contained in:
2025-06-12 17:35:42 +05:30
parent c7cc5cf2ca
commit 2fbdf8ab61
33 changed files with 670 additions and 316 deletions

View File

@@ -1,4 +1,4 @@
import React, { useState } from "react";
import React, { useEffect, useState } from "react";
import { AIIcon } from "../../../icons/ExportCommonIcons";
import RegularDropDown from "../../../ui/inputs/RegularDropDown";
import { AnalysisPresetsType } from "../../../../types/analysis";
@@ -19,55 +19,70 @@ const Analysis: React.FC = () => {
// { type: "default", inputs: { label: "Machine uptime", activeOption: "%" } },
],
"Production capacity": [
{ type: "range", inputs: { label: "Shift length", activeOption: "hr" } },
{ type: "default", inputs: { label: "Shifts / day", activeOption: "unit" } },
{ type: "default", inputs: { label: "Working days / year", activeOption: "days" } },
{ type: "default", inputs: { label: "Yield rate", activeOption: "%" } },
{ type: "range", inputs: { label: "Shift length", activeOption: "hr", defaultValue: 1 } },
{ type: "default", inputs: { label: "Shifts / day", activeOption: "unit", defaultValue: 3 } },
{ type: "default", inputs: { label: "Working days / year", activeOption: "days", defaultValue: 300 } },
{ type: "default", inputs: { label: "Yield rate", activeOption: "%", defaultValue: 98 } },
],
ROI: [
{
type: "default",
inputs: { label: "Selling price", activeOption: "INR" },
inputs: { label: "Selling price", activeOption: "INR", defaultValue: 500 },
},
{
type: "default",
inputs: { label: "Material cost", activeOption: "INR" },
inputs: { label: "Material cost", activeOption: "INR", defaultValue: 300 },
},
{
type: "default",
inputs: { label: "Labor Cost", activeOption: "INR" },
inputs: { label: "Labor Cost", activeOption: "INR", defaultValue: 150 },
},
{
type: "default",
inputs: { label: "Maintenance cost", activeOption: "INR" },
inputs: { label: "Labor Count", activeOption: "", defaultValue: 1 },
},
{
type: "default",
inputs: { label: "Electricity cost", activeOption: "INR" },
inputs: { label: "Maintenance cost", activeOption: "INR", defaultValue: 1200 },
},
{
type: "default",
inputs: { label: "Fixed costs", activeOption: "INR" },
inputs: { label: "Electricity cost", activeOption: "INR", defaultValue: 840 },
},
{
type: "default",
inputs: { label: "Initial Investment", activeOption: "INR" },
inputs: { label: "Fixed costs", activeOption: "INR", defaultValue: 1150 },
},
{
type: "default",
inputs: { label: "Salvage value", activeOption: "Hrs" },
inputs: { label: "Initial Investment", activeOption: "INR", defaultValue: 3500000 },
},
{
type: "default",
inputs: { label: "Production period", activeOption: "yrs" },
inputs: { label: "Salvage value", activeOption: "Day", defaultValue: 565 },
},
{
type: "default",
inputs: { label: "Tax rate", activeOption: "%" },
inputs: { label: "Production period", activeOption: "yrs", defaultValue: 5 },
},
{
type: "default",
inputs: { label: "Tax rate", activeOption: "%", defaultValue: 30 },
},
],
};
useEffect(() => {
Object.values(AnalysisPresets).forEach((category) => {
category.forEach((item) => {
const { label, defaultValue } = item.inputs;
if (defaultValue !== undefined) {
updateInputValue(label, defaultValue.toString());
}
});
});
}, []);
const { inputValues, setInputValues, updateInputValue } = useInputValues();
return (

View File

@@ -10,7 +10,8 @@ interface InputRendererProps {
onInputChange: (label: string, value: string) => void;
}
const RenderAnalysisInputs: React.FC<InputRendererProps> = ({ keyName, presets,inputValues, onInputChange }) => {
const RenderAnalysisInputs: React.FC<InputRendererProps> = ({ keyName, presets, inputValues, onInputChange }) => {
return (
<div key={`main-${keyName}`} className="analysis-inputs">
{presets.map((preset, index) => {
@@ -19,7 +20,7 @@ const RenderAnalysisInputs: React.FC<InputRendererProps> = ({ keyName, presets,i
<InputWithDropDown
key={index}
label={preset.inputs.label}
value={inputValues[preset.inputs.label] || ""}
value={preset.inputs.defaultValue?.toString() || inputValues[preset.inputs.label] || ""}
activeOption={preset.inputs.activeOption}
onChange={(newValue) => onInputChange(preset.inputs.label, newValue)}
/>
@@ -32,7 +33,7 @@ const RenderAnalysisInputs: React.FC<InputRendererProps> = ({ keyName, presets,i
label={preset.inputs.label}
min={0}
max={8}
value={5}
value={Number(preset.inputs.defaultValue) || Number(inputValues[preset.inputs.label]) || 5}
/>
);
}

View File

@@ -2,7 +2,7 @@ import React, { useEffect, useRef, useState } from "react";
import { AddIcon, ArrowIcon, RemoveIcon, ResizeHeightIcon, } from "../../../icons/ExportCommonIcons";
import RenameInput from "../../../ui/inputs/RenameInput";
import { handleResize } from "../../../../functions/handleResizePannel";
import { useSelectedAsset } from "../../../../store/simulation/useSimulationStore";
import { useMainProduct, useSelectedAsset } from "../../../../store/simulation/useSimulationStore";
import { useProductStore } from "../../../../store/simulation/useProductStore";
import { generateUUID } from "three/src/math/MathUtils";
import RenderOverlay from "../../../templates/Overlay";
@@ -48,6 +48,7 @@ const Simulations: React.FC = () => {
const [processes, setProcesses] = useState<Event[][]>();
const { setToggleUI } = useToggleStore();
const { projectId } = useParams();
const { setMainProduct } = useMainProduct();
const { comparePopUp, setComparePopUp } = useCompareStore();
const { setIsVersionSaved } = useSaveVersion();
@@ -85,8 +86,13 @@ const Simulations: React.FC = () => {
updatedProducts[newSelectedIndex].productUuid,
updatedProducts[newSelectedIndex].productName
);
setMainProduct(
updatedProducts[newSelectedIndex].productUuid,
updatedProducts[newSelectedIndex].productName
);
} else {
setSelectedProduct("", "");
setMainProduct("", "");
}
}
@@ -102,6 +108,7 @@ const Simulations: React.FC = () => {
renameProductApi({ productName: newName, productUuid, projectId: projectId || '' });
if (selectedProduct.productUuid === productUuid) {
setSelectedProduct(productUuid, newName);
setMainProduct(productUuid, newName);
}
};
@@ -172,9 +179,10 @@ const Simulations: React.FC = () => {
{/* eslint-disable-next-line */}
<div
className="value"
onClick={() =>
onClick={() => {
setSelectedProduct(product.productUuid, product.productName)
}
setMainProduct(product.productUuid, product.productName)
}}
>
<input
type="radio"