Skip to content

Commit

Permalink
fix(connector management): fix customer selection (#1119)
Browse files Browse the repository at this point in the history
  • Loading branch information
lavanya-bmw authored Sep 24, 2024
1 parent ea3ab6e commit ffc6948
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 15 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Unreleased

### Bugfixes

- **Connector Management**
- fixed customer link selection and fixed resetting values [#1119](https://github.com/eclipse-tractusx/portal-frontend/pull/1119)

## 2.2.0-alpha.1

### Bugfixes
Expand Down
4 changes: 2 additions & 2 deletions DEPENDENCIES
Original file line number Diff line number Diff line change
Expand Up @@ -759,8 +759,8 @@ npm/npmjs/@types/lodash/4.17.7, MIT, approved, clearlydefined
npm/npmjs/@types/node/20.11.30, MIT, approved, #13826
npm/npmjs/@types/papaparse/5.3.14, MIT, approved, #10964
npm/npmjs/@types/parse-json/4.0.2, MIT, approved, clearlydefined
npm/npmjs/@types/prop-types/15.7.11, MIT, approved, clearlydefined
npm/npmjs/@types/prop-types/15.7.12, MIT, approved, clearlydefined
npm/npmjs/@types/prop-types/15.7.11, MIT, approved, #16176
npm/npmjs/@types/prop-types/15.7.12, MIT, approved, #16176
npm/npmjs/@types/qs/6.9.15, MIT, approved, #14071
npm/npmjs/@types/react-dom/18.2.22, MIT, approved, #8256
npm/npmjs/@types/react-redux/7.1.33, MIT, approved, #10970
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ import {
} from '@catena-x/portal-shared-components'
import HelpOutlineIcon from '@mui/icons-material/HelpOutline'
import Patterns from 'types/Patterns'
import { ConnectType } from 'features/connector/connectorApiSlice'
import {
ConnectType,
type EdcSubscriptionsType,
} from 'features/connector/connectorApiSlice'
import { Dropzone } from '../../../../shared/basic/Dropzone'
import { useEffect, useState } from 'react'
import './EdcComponentStyles.scss'
Expand Down Expand Up @@ -245,6 +248,7 @@ const ConnectorInsertForm = ({
control,
trigger,
getValues,
resetField,
selectedService,
subscriptions,
fetchServiceAccountUsers,
Expand All @@ -258,7 +262,8 @@ any) => {
const { t } = useTranslation()
const [selectedValue, setSelectedValue] = useState<string>()
const [serviceAccountUsers, setServiceAccountUsers] = useState([])
const [selectedTechnicalUser, setSelectedTechnicalUser] = useState('')
const [selectedTechnicalUser, setSelectedTechnicalUser] = useState({})
const [selectedCustomerLink, setSelectedCustomerLink] = useState({})

useEffect(() => {
if (fetchServiceAccountUsers)
Expand All @@ -274,10 +279,20 @@ any) => {
i.serviceAccountId === getValues().ConnectorTechnicalUser
)
if (selectedConnectorTechnicalUser.length > 0) {
setSelectedTechnicalUser(selectedConnectorTechnicalUser[0]?.name)
setSelectedTechnicalUser(selectedConnectorTechnicalUser[0])
}
}, [serviceAccountUsers])

useEffect(() => {
const selectedCustomer: EdcSubscriptionsType[] = subscriptions?.filter(
(item: { subscriptionId: string }) =>
item.subscriptionId === getValues().ConnectorSubscriptionId
)
if (selectedCustomer.length > 0) {
setSelectedCustomerLink(selectedCustomer[0])
}
}, [subscriptions])

const handleTechnicalUserSubmit = () => {
if (
selectedValue === t('content.edcconnector.modal.createNewTechnicalUser')
Expand Down Expand Up @@ -354,6 +369,12 @@ any) => {
)}
onChange={(event) => {
setSelectedValue(event.target.value)
resetField('TechnicalUserName', {
defaultValue: '',
})
resetField('TechnicalUserDescription', {
defaultValue: '',
})
}}
size="small"
sx={{
Expand Down Expand Up @@ -612,7 +633,7 @@ any) => {
'content.edcconnector.modal.insertform.subscription.error'
),
items: subscriptions,
defaultSelectValue: {},
defaultSelectValue: selectedCustomerLink ?? {},
keyTitle: 'name',
}}
/>
Expand Down
25 changes: 16 additions & 9 deletions src/components/pages/EdcConnector/AddConnectorOverlay/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ const AddConnectorOverlay = ({
handleSubmit,
getValues,
control,
resetField,
trigger,
formState: { errors },
reset,
Expand All @@ -120,8 +121,10 @@ const AddConnectorOverlay = ({
const [selected, setSelected] = useState<ConnectorType>({})

useEffect(() => {
if (openDialog) reset(formFields)
}, [openDialog, reset])
if (openDialog || connectorStep === 0) {
reset(formFields)
}
}, [openDialog, reset, connectorStep])

useEffect(() => {
if (serviceAccounts && serviceAccounts?.meta?.totalPages > page) {
Expand Down Expand Up @@ -216,7 +219,14 @@ const AddConnectorOverlay = ({
setNewTechnicalUSer={setNewTechnicalUSer}
newUserLoading={newUserLoading}
newUserSuccess={newUserSuccess}
{...{ handleSubmit, control, errors, trigger, getValues }}
{...{
handleSubmit,
control,
errors,
trigger,
getValues,
resetField,
}}
/>
</>
)}
Expand All @@ -225,12 +235,9 @@ const AddConnectorOverlay = ({
<Button
variant="outlined"
onClick={() => {
if (connectorStep === 1) {
onStepChange()
} else {
setSelected({})
handleOverlayClose()
}
if (connectorStep === 1) onStepChange()
else handleOverlayClose()
setSelected({})
}}
>
{connectorStep === 0
Expand Down

0 comments on commit ffc6948

Please sign in to comment.