mirror of
https://github.com/Unleash/unleash.git
synced 2025-03-04 00:18:40 +01:00
fix($env): fix environment order form state (#8449)
This commit is contained in:
parent
e22f6a04ba
commit
258eb36afe
@ -157,7 +157,7 @@ describe('OrderEnvironmentsDialog Component', () => {
|
|||||||
expect(onSubmitMock).toHaveBeenCalledTimes(1);
|
expect(onSubmitMock).toHaveBeenCalledTimes(1);
|
||||||
expect(onSubmitMock).toHaveBeenCalledWith([
|
expect(onSubmitMock).toHaveBeenCalledWith([
|
||||||
{ name: 'Dev', type: 'development' },
|
{ name: 'Dev', type: 'development' },
|
||||||
{ name: 'Prod', type: 'development' },
|
{ name: 'Staging', type: 'development' },
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -111,6 +111,22 @@ export const OrderEnvironmentsDialog: FC<OrderEnvironmentsDialogProps> = ({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onTypeChange = (index: number, type: string) => {
|
||||||
|
setEnvironments(
|
||||||
|
environments.map((env, i) =>
|
||||||
|
i === index ? { ...env, type } : { ...env },
|
||||||
|
),
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const onNameChange = (index: number, name: string) => {
|
||||||
|
setEnvironments(
|
||||||
|
environments.map((env, i) =>
|
||||||
|
i === index ? { ...env, name } : { ...env },
|
||||||
|
),
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledDialog open={open} title=''>
|
<StyledDialog open={open} title=''>
|
||||||
<FormTemplate
|
<FormTemplate
|
||||||
@ -199,11 +215,7 @@ export const OrderEnvironmentsDialog: FC<OrderEnvironmentsDialogProps> = ({
|
|||||||
}),
|
}),
|
||||||
)}
|
)}
|
||||||
onChange={(type) => {
|
onChange={(type) => {
|
||||||
const newEnvironments = [
|
onTypeChange(i, type);
|
||||||
...environments,
|
|
||||||
];
|
|
||||||
newEnvironments[i].type = type;
|
|
||||||
setEnvironments(newEnvironments);
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<TextField
|
<TextField
|
||||||
@ -211,12 +223,7 @@ export const OrderEnvironmentsDialog: FC<OrderEnvironmentsDialogProps> = ({
|
|||||||
label={`Environment ${i + 1} Name`}
|
label={`Environment ${i + 1} Name`}
|
||||||
value={environments[i]?.name || ''}
|
value={environments[i]?.name || ''}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
const newEnvironments = [
|
onNameChange(i, e.target.value);
|
||||||
...environments,
|
|
||||||
];
|
|
||||||
newEnvironments[i].name =
|
|
||||||
e.target.value;
|
|
||||||
setEnvironments(newEnvironments);
|
|
||||||
}}
|
}}
|
||||||
error={!!error}
|
error={!!error}
|
||||||
helperText={error}
|
helperText={error}
|
||||||
|
Loading…
Reference in New Issue
Block a user