Skip to content

Commit

Permalink
fix(connector management): fix technical user selection (#1085)
Browse files Browse the repository at this point in the history
  • Loading branch information
lavanya-bmw authored Sep 6, 2024
1 parent e3631b8 commit 4c6e39e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## Unreleased

### Bugfixes

- **Connector Management**
- fixed technical user selection

## 2.2.0-RC2

### Feature

- Customer Detail Data Overlay
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { Dropzone } from '../../../../shared/basic/Dropzone'
import { useEffect, useState } from 'react'
import './EdcComponentStyles.scss'
import { ConnectorFormFields } from '..'
import { type ServiceAccountListEntry } from 'features/admin/serviceApiSlice'

export const ConnectorFormInput = ({
control,
Expand Down Expand Up @@ -243,6 +244,7 @@ const ConnectorInsertForm = ({
errors,
control,
trigger,
getValues,
selectedService,
subscriptions,
fetchServiceAccountUsers,
Expand All @@ -256,6 +258,7 @@ any) => {
const { t } = useTranslation()
const [selectedValue, setSelectedValue] = useState<string>()
const [serviceAccountUsers, setServiceAccountUsers] = useState([])
const [selectedTechnicalUser, setSelectedTechnicalUser] = useState('')

useEffect(() => {
if (fetchServiceAccountUsers)
Expand All @@ -264,6 +267,17 @@ any) => {
)
}, [fetchServiceAccountUsers])

useEffect(() => {
const selectedConnectorTechnicalUser: ServiceAccountListEntry[] =
serviceAccountUsers?.filter(
(i: { serviceAccountId: string }) =>
i.serviceAccountId === getValues().ConnectorTechnicalUser
)
if (selectedConnectorTechnicalUser.length > 0) {
setSelectedTechnicalUser(selectedConnectorTechnicalUser[0]?.name)
}
}, [serviceAccountUsers])

const handleTechnicalUserSubmit = () => {
if (
selectedValue === t('content.edcconnector.modal.createNewTechnicalUser')
Expand Down Expand Up @@ -374,7 +388,7 @@ any) => {
'content.edcconnector.modal.insertform.technicalUser.error'
),
items: serviceAccountUsers,
defaultSelectValue: {},
defaultSelectValue: selectedTechnicalUser ?? {},
keyTitle: 'name',
}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ const AddConnectorOverlay = ({
setNewTechnicalUSer={setNewTechnicalUSer}
newUserLoading={newUserLoading}
newUserSuccess={newUserSuccess}
{...{ handleSubmit, control, errors, trigger }}
{...{ handleSubmit, control, errors, trigger, getValues }}
/>
</>
)}
Expand Down

0 comments on commit 4c6e39e

Please sign in to comment.