Skip to content

Commit 9710302

Browse files
committed
updated handle update configuration
1 parent 1fbee89 commit 9710302

File tree

1 file changed

+14
-5
lines changed
  • JeMPI_Apps/JeMPI_UI/src/pages/settings/common

1 file changed

+14
-5
lines changed

JeMPI_Apps/JeMPI_UI/src/pages/settings/common/Common.tsx

+14-5
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,25 @@ const CommonSettings = () => {
5555
)
5656
localStorage.setItem('configuration', JSON.stringify(updatedConfiguration))
5757
setConfiguration(updatedConfiguration)
58+
setRows((prevRows: any) =>
59+
prevRows.map((row: any) =>
60+
row.id === updatedRow.id ? { ...updatedRow } : row
61+
)
62+
)
5863
}
5964

6065
const getUpdatedConfiguration = (
6166
updatedRow: any,
6267
rowIndex: number,
6368
currentConfiguration: Configuration
6469
): Configuration => {
70+
const newConfiguration = { ...currentConfiguration }
6571
const fieldName = toSnakeCase(updatedRow.fieldName)
66-
if (!currentConfiguration.demographicFields) {
72+
if (!newConfiguration.demographicFields) {
6773
return currentConfiguration
6874
}
6975

70-
const fieldToUpdate = currentConfiguration.demographicFields[rowIndex]
76+
const fieldToUpdate = { ...newConfiguration.demographicFields[rowIndex] }
7177

7278
if (!fieldToUpdate) {
7379
return currentConfiguration
@@ -76,7 +82,10 @@ const CommonSettings = () => {
7682
fieldToUpdate.fieldName = fieldName
7783

7884
if (updatedRow?.indexGoldenRecord) {
79-
fieldToUpdate.indexGoldenRecord = `@index(${updatedRow.indexGoldenRecord.replace(' ', '')})`
85+
fieldToUpdate.indexGoldenRecord = `@index(${updatedRow.indexGoldenRecord.replace(
86+
' ',
87+
''
88+
)})`
8089
}
8190

8291
if (updatedRow?.m) {
@@ -93,9 +102,9 @@ const CommonSettings = () => {
93102
} as LinkMetaData
94103
}
95104

96-
currentConfiguration.demographicFields[rowIndex] = fieldToUpdate
105+
newConfiguration.demographicFields[rowIndex] = fieldToUpdate
97106

98-
return currentConfiguration
107+
return newConfiguration
99108
}
100109

101110
const handleCancelClick = (id: GridRowId) => () => {

0 commit comments

Comments
 (0)