Skip to content

Commit b8d5385

Browse files
Record audit: Country change to anything other than farajaland (#4475)
* Record audit: Country change to anything other than farajaland * Refactored State & District Name showing * Removing unnecessary console.log
1 parent d267132 commit b8d5385

File tree

1 file changed

+47
-5
lines changed

1 file changed

+47
-5
lines changed

packages/client/src/views/RegisterForm/review/ReviewSection.tsx

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -403,9 +403,47 @@ const renderValue = (
403403
field: IFormField,
404404
intl: IntlShape,
405405
offlineCountryConfiguration: IOfflineData,
406-
language: string
406+
language: string,
407+
isOriginalData = false
407408
) => {
408409
const value: IFormFieldValue = getFormFieldValue(draftData, sectionId, field)
410+
411+
// Showing State & District Name instead of their ID
412+
if (
413+
[
414+
'statePrimary',
415+
'districtPrimary',
416+
'internationalStatePrimary',
417+
'internationalDistrictPrimary'
418+
].includes(field.name) &&
419+
isOriginalData
420+
) {
421+
const sectionData = draftData[sectionId]
422+
423+
if (sectionData.countryPrimary === window.config.COUNTRY) {
424+
const dynamicOption: IDynamicOptions = {
425+
resource: 'locations',
426+
initialValue: 'agentDefault'
427+
}
428+
dynamicOption.dependency = [
429+
'internationalStatePrimary',
430+
'statePrimary'
431+
].includes(field.name)
432+
? 'countryPrimary'
433+
: 'statePrimary'
434+
435+
return renderSelectDynamicLabel(
436+
value,
437+
dynamicOption,
438+
sectionData,
439+
intl,
440+
offlineCountryConfiguration,
441+
language
442+
)
443+
}
444+
445+
return value
446+
}
409447
if (field.type === SELECT_WITH_OPTIONS && field.options) {
410448
return renderSelectOrRadioLabel(value, field.options, intl)
411449
}
@@ -932,7 +970,8 @@ class ReviewSectionComp extends React.Component<FullProps, State> {
932970
field: IFormField,
933971
sectionErrors: IErrorsBySection,
934972
ignoreNestedFieldWrapping?: boolean,
935-
replaceEmpty?: boolean
973+
replaceEmpty?: boolean,
974+
isOriginalData?: boolean
936975
) => {
937976
const { intl, offlineCountryConfiguration, language } = this.props
938977

@@ -942,7 +981,8 @@ class ReviewSectionComp extends React.Component<FullProps, State> {
942981
field,
943982
intl,
944983
offlineCountryConfiguration,
945-
language
984+
language,
985+
isOriginalData
946986
)
947987

948988
if (replaceEmpty && !value) {
@@ -978,7 +1018,8 @@ class ReviewSectionComp extends React.Component<FullProps, State> {
9781018
nestedField,
9791019
intl,
9801020
offlineCountryConfiguration,
981-
language
1021+
language,
1022+
isOriginalData
9821023
)) ||
9831024
''
9841025
return (
@@ -1113,7 +1154,8 @@ class ReviewSectionComp extends React.Component<FullProps, State> {
11131154
field,
11141155
errorsOnFields,
11151156
undefined,
1116-
!index
1157+
!index,
1158+
true
11171159
)
11181160
)
11191161
.filter((value) => value)

0 commit comments

Comments
 (0)