Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | 49x 67x 67x 67x 67x 67x 268x 67x 2x 2x 2x 2x 2x 2x 2x 67x | import React, { useState } from "react";
import { useSearchParams } from "react-router-dom";
import SelectInput from "@/ahuora-design-system/inputs/SelectInput";
import { useCoreSchemapropertysetUpdateHxTypeCreateMutation } from "@/api/apiStore.gen";
import {
heat_exchanger_lc,
heat_exchanger_ntu,
heatExchanger,
plate_heat_exchanger,
} from "@/data/objects.json";
import { useCurrentObject } from "@/hooks/flowsheetObjects";
import { ContentTypes } from "../../LeftSideBar/LeftSideBarTabDefinitions";
const objMap = {
heatExchanger: heatExchanger.displayType,
heat_exchanger_ntu: heat_exchanger_ntu.displayType,
heat_exchanger_lc: heat_exchanger_lc.displayType,
plate_heat_exchanger: plate_heat_exchanger.displayType,
};
export function HXSettings() {
const currentSimulationObject = useCurrentObject();
const [changeHXType] = useCoreSchemapropertysetUpdateHxTypeCreateMutation();
//Declaring array and veriables for selecting turbine:
const configNameArray = Object.entries(objMap);
const [selectedType, setSelectedType] = React.useState(
currentSimulationObject.objectType,
);
const [searchParams, setSearchParams] = useSearchParams();
// Format configArray for SelectInput
const selectData = configNameArray.map((obj, index) => ({
value: obj[0],
label: obj[1],
}));
//Create handle for selecting turbine type:
const handleSelectChange = async (value: string) => {
setSelectedType(value);
const result = await changeHXType({
updateHxRequest: {
hx_type: value,
simulation_object: currentSimulationObject.id,
},
});
const newSearchParams = new URLSearchParams(searchParams);
const id = result.data;
newSearchParams.set("object", id.toString());
newSearchParams.set("content", ContentTypes.objectDetails);
setSearchParams(newSearchParams);
};
//Display formatting:
return (
<SelectInput
title="Change Model Type"
value={selectedType}
data={selectData}
handleChange={handleSelectChange}
className={!selectedType ? "border-rose-700" : " "}
/>
);
}
|