diff --git a/frontend/src/component/environments/EnvironmentTable/OrderEnvironments/OrderEnvironmentsDialog/OrderEnvironmentsDialog.test.tsx b/frontend/src/component/environments/EnvironmentTable/OrderEnvironments/OrderEnvironmentsDialog/OrderEnvironmentsDialog.test.tsx index a1bd701ca530..29329dc5dcab 100644 --- a/frontend/src/component/environments/EnvironmentTable/OrderEnvironments/OrderEnvironmentsDialog/OrderEnvironmentsDialog.test.tsx +++ b/frontend/src/component/environments/EnvironmentTable/OrderEnvironments/OrderEnvironmentsDialog/OrderEnvironmentsDialog.test.tsx @@ -157,7 +157,7 @@ describe('OrderEnvironmentsDialog Component', () => { expect(onSubmitMock).toHaveBeenCalledTimes(1); expect(onSubmitMock).toHaveBeenCalledWith([ { name: 'Dev', type: 'development' }, - { name: 'Prod', type: 'development' }, + { name: 'Staging', type: 'development' }, ]); }); diff --git a/frontend/src/component/environments/EnvironmentTable/OrderEnvironments/OrderEnvironmentsDialog/OrderEnvironmentsDialog.tsx b/frontend/src/component/environments/EnvironmentTable/OrderEnvironments/OrderEnvironmentsDialog/OrderEnvironmentsDialog.tsx index aef072375a13..c9e9625fe447 100644 --- a/frontend/src/component/environments/EnvironmentTable/OrderEnvironments/OrderEnvironmentsDialog/OrderEnvironmentsDialog.tsx +++ b/frontend/src/component/environments/EnvironmentTable/OrderEnvironments/OrderEnvironmentsDialog/OrderEnvironmentsDialog.tsx @@ -111,6 +111,22 @@ export const OrderEnvironmentsDialog: FC = ({ }); }; + 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 ( = ({ }), )} onChange={(type) => { - const newEnvironments = [ - ...environments, - ]; - newEnvironments[i].type = type; - setEnvironments(newEnvironments); + onTypeChange(i, type); }} /> = ({ label={`Environment ${i + 1} Name`} value={environments[i]?.name || ''} onChange={(e) => { - const newEnvironments = [ - ...environments, - ]; - newEnvironments[i].name = - e.target.value; - setEnvironments(newEnvironments); + onNameChange(i, e.target.value); }} error={!!error} helperText={error}