Skip to content

Commit a2b040a

Browse files
committed
use predefined properties
Signed-off-by: basseche <[email protected]>
1 parent 830d580 commit a2b040a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/components/dialogs/limits/limits-properties-side-stack.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
*/
77
import { LimitsTagChip } from './limits-tag-chip';
88
import { Autocomplete, AutocompleteRenderInputParams, Box, Stack, TextField, IconButton } from '@mui/material';
9-
import { useCallback, useState } from 'react';
9+
import { useCallback, useMemo, useState } from 'react';
1010
import { AddCircle, Delete } from '@mui/icons-material';
11-
import { LimitsPropertyName } from './limits-constants';
1211
import { useIntl } from 'react-intl';
1312
import { LimitsProperty } from '../../../services/network-modification-types';
1413
import { useFormContext, useWatch } from 'react-hook-form';
14+
import { usePredefinedProperties } from '@gridsuite/commons-ui';
1515

1616
export interface LimitsPropertiesSideStackProps {
1717
formName: string;
@@ -28,6 +28,11 @@ export function LimitsPropertiesSideStack({ formName, disabled }: Readonly<Limit
2828
const [editorError, setEditorError] = useState<string>('');
2929
const intl = useIntl();
3030

31+
const [predefinedProperties] = usePredefinedProperties('limitsGroup');
32+
const predefinedPropertiesNames = useMemo(() => {
33+
return Object.keys(predefinedProperties ?? {}).sort((a, b) => a.localeCompare(b));
34+
}, [predefinedProperties]);
35+
3136
const handleKeyPress = useCallback(
3237
(event: React.KeyboardEvent<HTMLInputElement>) => {
3338
if (event.key === 'Enter') {
@@ -94,7 +99,7 @@ export function LimitsPropertiesSideStack({ formName, disabled }: Readonly<Limit
9499
onMouseLeave={() => setHovered(false)}
95100
>
96101
<Autocomplete
97-
options={Object.values(LimitsPropertyName)}
102+
options={Object.values(predefinedPropertiesNames)}
98103
size="small"
99104
onChange={(event, value) => handleOnChange(value ?? '')}
100105
renderInput={(params: AutocompleteRenderInputParams) => (

0 commit comments

Comments
 (0)