Skip to content

Commit

Permalink
fix: country value not updating when moving back and forth between st…
Browse files Browse the repository at this point in the history
…eps (#232)

#231
  • Loading branch information
shubhamv-ss authored Aug 13, 2024
1 parent e8d9d76 commit ba040e8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

### Bugfix

- country value is not updating if user moves back and forth between steps [#232](https://github.com/eclipse-tractusx/portal-frontend-registration/pull/232)
- remove code that always displays error message on screen [#230](https://github.com/eclipse-tractusx/portal-frontend-registration/pull/230)


## 2.0.1

### Change
Expand Down
16 changes: 9 additions & 7 deletions src/components/cax-companyData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,14 @@ export const CompanyDataCax = () => {

useEffect(() => {
const index = i18n.language === 'de' ? 0 : 1
countryList = countryList?.map((country) => ({
id: country.alpha2Code,
label:
country.countryName[index]?.value + ' (' + country.alpha2Code + ')',
}))
setCountryArr(countryList)
if (countryList?.length > 0 && Array.isArray(countryList[0].countryName)) {
countryList = countryList?.map((country) => ({
id: country.alpha2Code,
label:
country.countryName[index]?.value + ' (' + country.alpha2Code + ')',
}))
setCountryArr(countryList)
}
}, [countryList, i18n.language])

const defaultSelectedCountry = countryArr?.filter(
Expand Down Expand Up @@ -586,7 +588,7 @@ export const CompanyDataCax = () => {
<Autocomplete
id="selectList"
options={countryArr}
defaultValue={defaultSelectedCountry}
value={defaultSelectedCountry}
renderInput={(params) => (
<TextField variant="standard" {...params} />
)}
Expand Down

0 comments on commit ba040e8

Please sign in to comment.