frontend bug fix

This commit is contained in:
Yinyin Liu 2026-03-24 14:38:23 +01:00
parent 0657a5fb82
commit 4bb35c6951
4 changed files with 15 additions and 11 deletions

View File

@ -42,6 +42,7 @@ import {
remapTree,
computeFlatValues,
wouldLoseData,
SODIOHOME_DEVICE_TYPES,
} from './installationSetupUtils';
interface InformationSodistorehomeProps {
@ -93,10 +94,7 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) {
return [value.trim()];
};
const DeviceTypes = [
{ id: 3, name: 'Growatt' },
{ id: 4, name: 'inesco 12K - WR Hybrid' }
];
const DeviceTypes = SODIOHOME_DEVICE_TYPES;
// Preset state — initializes from persisted installationModel, empty for legacy
const [selectedPreset, setSelectedPreset] = useState<string>(
@ -741,7 +739,7 @@ function InformationSodistorehome(props: InformationSodistorehomeProps) {
shrink
sx={{ fontSize: 14, backgroundColor: 'white', px: 0.5 }}
>
Installation Model
<FormattedMessage id="installationModel" defaultMessage="Installation Model" />
</InputLabel>
<Select
value={selectedPreset}

View File

@ -1,3 +1,11 @@
export const SODIOHOME_DEVICE_TYPES = [
{ id: 3, name: 'Growatt' },
{ id: 4, name: 'inesco 12K - WR Hybrid' }
] as const;
export const getDeviceTypeName = (deviceId: number): string =>
SODIOHOME_DEVICE_TYPES.find(d => d.id === deviceId)?.name ?? '';
// [inverter][cluster] = batteryCount
export type PresetConfig = number[][];

View File

@ -19,6 +19,7 @@ import { useLocation, useNavigate } from 'react-router-dom';
import routes from '../../../Resources/routes.json';
import CancelIcon from '@mui/icons-material/Cancel';
import BuildIcon from '@mui/icons-material/Build';
import { getDeviceTypeName } from '../Information/installationSetupUtils';
interface FlatInstallationViewProps {
installations: I_Installation[];
@ -168,7 +169,7 @@ const FlatInstallationView = (props: FlatInstallationViewProps) => {
noWrap
sx={{ marginTop: '10px', fontSize: 'small' }}
>
{installation.device === 3 ? 'Growatt' : installation.device === 4 ? 'inesco 12K - WR Hybrid' : ''}
{getDeviceTypeName(installation.device)}
</Typography>
</TableCell>

View File

@ -17,7 +17,7 @@ import { Close as CloseIcon } from '@mui/icons-material';
import { I_Installation } from 'src/interfaces/InstallationTypes';
import { InstallationsContext } from 'src/contexts/InstallationsContextProvider';
import { FormattedMessage } from 'react-intl';
import { INSTALLATION_PRESETS } from '../Information/installationSetupUtils';
import { INSTALLATION_PRESETS, SODIOHOME_DEVICE_TYPES } from '../Information/installationSetupUtils';
interface SodistorehomeInstallationFormPros {
cancel: () => void;
@ -36,10 +36,7 @@ function SodistorehomeInstallationForm(props: SodistorehomeInstallationFormPros)
});
const requiredFields = ['name', 'vpnIp', 'installationModel'];
const DeviceTypes = [
{ id: 3, name: 'Growatt' },
{ id: 4, name: 'inesco 12K - WR Hybrid' }
];
const DeviceTypes = SODIOHOME_DEVICE_TYPES;
const installationContext = useContext(InstallationsContext);
const { createInstallation, loading, setLoading, error, setError } =
installationContext;