Skip to content

Commit ced5cf0

Browse files
OCRVS-4373: Add certificate handlebars for all individual address fields (#4593)
* Adding mapping function for template * Fixing error in transformer moethod * Fixing Array locations * Adding documentation for address fields * Fix typos * Adding case in transformation methods for secondary address * Adding the yarn.lock * Fixing duplicate issues while develop merge * Fixing Urban & Rural condition for secondary adddress * Address change fix in Correction summary page * fix address state & district id resolve for secondary address * Add optional chaining to address field Co-authored-by: Tameem Bin Haider <[email protected]>
1 parent b43b0c9 commit ced5cf0

File tree

6 files changed

+105
-49
lines changed

6 files changed

+105
-49
lines changed

packages/client/src/forms/configuration/README.md

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -789,24 +789,44 @@ This object holds sections for death declaration forms. All sections are in sect
789789

790790
- #### `Father/Mother/Informant/Deceased Address`
791791
- #### `informant/father/mother/deceased`
792-
This is a formatted place of event which will show district, state country. This field is always available for relevant event.
793-
- #### `informantCountry/fatherCountry/motherCountry/deceasedCountry`
792+
This is a formatted place of event which will show district, state country. This field is always available for relevant event & it will be the primary address.
793+
- #### `informantPrimaryCountry/fatherPrimaryCountry/motherPrimaryCountry/deceasedPrimaryCountry`
794794
This field is always available.
795-
- #### `informantCity/fatherCity/motherCity/deceasedCity`
796-
This field is optionaly available if they are provided.
797-
- #### `informantAddressLine3/fatherAddressLine3/motherAddressLine3/deceasedAddressLine3`
798-
This field is optionaly available if they are provided.
799-
- #### `informantAddressLine2/fatherAddressLine2/motherAddressLine2/deceasedAddressLine2`
800-
This field is optionaly available if they are provided.
801-
- #### `informantNumber/fatherNumber/motherNumber/deceasedNumber`
802-
This field is optionaly available if they are provided.
803-
- #### `informantPostalCode/fatherPostalCode/motherPostalCode/deceasedPostalCode`
804-
This field is optionaly available if they are provided.
805-
- #### `informantAddressLine5/fatherAddressLine5/motherAddressLine5/deceasedAddressLine5`
806-
This field is optionaly available if they are provided.
807-
- #### `informantState/fatherState/motherState/deceasedState`
808-
This field is optionaly available if they are provided.
809-
- #### `informantDistrict/fatherDistrict/motherDistrict/deceasedDistrict`
810-
This field is optionaly available if they are provided.
811-
- #### `informantAddressLine1/fatherAddressLine1/motherAddressLine1/deceasedAddressLine1`
812-
This field is optionaly available if they are provided.
795+
- #### `informantSecondaryCountry/fatherSecondaryCountry/motherSecondaryCountry/deceasedSecondaryCountry`
796+
This field should be available if the No of address is configured for 2.
797+
- #### `informantPrimaryCity/fatherPrimaryCity/motherPrimaryCity/deceasedPrimaryCity`
798+
This field is optionally available if they are provided.
799+
- #### `informantSecondaryCity/fatherSecondaryCity/motherSecondaryCity/deceasedSecondaryCity`
800+
This field is optionally available if they are provided. Also it will be unavailable for No of address configured to 1.
801+
- #### `informantPrimaryAddressLine3/fatherPrimaryAddressLine3/motherPrimaryAddressLine3/deceasedPrimaryAddressLine3`
802+
This field is optionally available if they are provided.
803+
- #### `informantSecondaryAddressLine3/fatherSecondaryAddressLine3/motherSecondaryAddressLine3/deceasedSecondaryAddressLine3`
804+
This field is optionally available if they are provided. Also it will be unavailable for No of address configured to 1.
805+
- #### `informantPrimaryAddressLine2/fatherPrimaryAddressLine2/motherPrimaryAddressLine2/deceasedPrimaryAddressLine2`
806+
This field is optionally available if they are provided.
807+
- #### `informantSecondaryAddressLine2/fatherSecondaryAddressLine2/motherSecondaryAddressLine2/deceasedSecondaryAddressLine2`
808+
This field is optionally available if they are provided. Also it will be unavailable for No of address configured to 1.
809+
- #### `informantPrimaryNumber/fatherPrimaryNumber/motherPrimaryNumber/deceasedPrimaryNumber`
810+
This field is optionally available if they are provided.
811+
- #### `informantSecondaryNumber/fatherSecondaryNumber/motherSecondaryNumber/deceasedSecondaryNumber`
812+
This field is optionally available if they are provided. Also it will be unavailable for No of address configured to 1.
813+
- #### `informantPrimaryPostalCode/fatherPrimaryPostalCode/motherPrimaryPostalCode/deceasedPrimaryPostalCode`
814+
This field is optionally available if they are provided.
815+
- #### `informantSecondaryPostalCode/fatherSecondaryPostalCode/motherSecondaryPostalCode/deceasedSecondaryPostalCode`
816+
This field is optionally available if they are provided. Also it will be unavailable for No of address configured to 1.
817+
- #### `informantPrimaryAddressLine5/fatherPrimaryAddressLine5/motherPrimaryAddressLine5/deceasedPrimaryAddressLine5`
818+
This field is optionally available if they are provided.
819+
- #### `informantSecondaryAddressLine5/fatherSecondaryAddressLine5/motherSecondaryAddressLine5/deceasedSecondaryAddressLine5`
820+
This field is optionally available if they are provided. Also it will be unavailable for No of address configured to 1.
821+
- #### `informantPrimaryState/fatherPrimaryState/motherPrimaryState/deceasedPrimaryState`
822+
This field is optionally available if they are provided.
823+
- #### `informantSecondaryState/fatherSecondaryState/motherSecondaryState/deceasedSecondaryState`
824+
This field is optionally available if they are provided. Also it will be unavailable for No of address configured to 1.
825+
- #### `informantPrimaryDistrict/fatherPrimaryDistrict/motherPrimaryDistrict/deceasedPrimaryDistrict`
826+
This field is optionally available if they are provided.
827+
- #### `informantSecondaryDistrict/fatherSecondaryDistrict/motherSecondaryDistrict/deceasedSecondaryDistrict`
828+
This field is optionally available if they are provided. Also it will be unavailable for No of address configured to 1.
829+
- #### `informantPrimaryAddressLine1/fatherPrimaryAddressLine1/motherPrimaryAddressLine1/deceasedPrimaryAddressLine1`
830+
This field is optionally available if they are provided.
831+
- #### `informantSecondaryAddressLine1/fatherSecondaryAddressLine1/motherSecondaryAddressLine1/deceasedSecondaryAddressLine1`
832+
This field is optionally available if they are provided. Also it will be unavailable for No of address configured to 1.

packages/client/src/forms/configuration/administrative/addresses.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ function getAddressCaseFields(
768768
},
769769
{
770770
action: 'hide',
771-
expression: 'values.ruralOrUrbanPrimary !== "URBAN"'
771+
expression: `values.ruralOrUrban${sentenceCase(useCase)} !== "URBAN"`
772772
},
773773
{
774774
action: 'hide',
@@ -837,7 +837,7 @@ function getAddressCaseFields(
837837
},
838838
{
839839
action: 'hide',
840-
expression: 'values.ruralOrUrbanPrimary !== "URBAN"'
840+
expression: `values.ruralOrUrban${sentenceCase(useCase)} !== "URBAN"`
841841
},
842842
{
843843
action: 'hide',
@@ -906,7 +906,7 @@ function getAddressCaseFields(
906906
},
907907
{
908908
action: 'hide',
909-
expression: 'values.ruralOrUrbanPrimary !== "URBAN"'
909+
expression: `values.ruralOrUrban${sentenceCase(useCase)} !== "URBAN"`
910910
},
911911
{
912912
action: 'hide',
@@ -975,7 +975,7 @@ function getAddressCaseFields(
975975
},
976976
{
977977
action: 'hide',
978-
expression: 'values.ruralOrUrbanPrimary !== "URBAN"'
978+
expression: `values.ruralOrUrban${sentenceCase(useCase)} !== "URBAN"`
979979
},
980980
{
981981
action: 'hide',
@@ -1044,7 +1044,7 @@ function getAddressCaseFields(
10441044
},
10451045
{
10461046
action: 'hide',
1047-
expression: 'values.ruralOrUrbanPrimary !== "URBAN"'
1047+
expression: `values.ruralOrUrban${sentenceCase(useCase)} !== "URBAN"`
10481048
},
10491049
{
10501050
action: 'hide',
@@ -1113,7 +1113,7 @@ function getAddressCaseFields(
11131113
},
11141114
{
11151115
action: 'hide',
1116-
expression: 'values.ruralOrUrbanPrimary !== "RURAL"'
1116+
expression: `values.ruralOrUrban${sentenceCase(useCase)} !== "RURAL"`
11171117
},
11181118
{
11191119
action: 'hide',

packages/client/src/forms/mappings/query/field-mappings.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,8 @@ const transformAddressTemplateArray = (
770770
addressLocationLevel: keyof typeof LocationLevel,
771771
sectionId: string,
772772
nameKey: string,
773-
offlineData?: IOfflineData
773+
offlineData?: IOfflineData,
774+
addressCases?: AddressCases
774775
) => {
775776
if (!transformedData[sectionId]) {
776777
transformedData[sectionId] = {}
@@ -792,8 +793,11 @@ const transformAddressTemplateArray = (
792793
LocationLevel[addressLocationLevel]
793794
] = addressName
794795

795-
transformedData[sectionId][camelCase(`${nameKey}_${addressLocationLevel}`)] =
796-
addressName as string | Record<string, string>
796+
const addressCase =
797+
addressCases === AddressCases.SECONDARY_ADDRESS ? 'secondary' : 'primary'
798+
transformedData[sectionId][
799+
camelCase(`${nameKey}_${addressCase}_${addressLocationLevel}`)
800+
] = addressName as string | Record<string, string>
797801
}
798802

799803
export const addressOfflineTransformer =
@@ -851,7 +855,7 @@ export const individualAddressTransformer =
851855
}
852856

853857
const address =
854-
queryData[sectionId].address || queryData[sectionId]?.individual?.address
858+
queryData[sectionId]?.address || queryData[sectionId]?.individual?.address
855859
const addressFromQuery = (address || []).find(
856860
(addr: { type: AddressCases }) => addr.type === addressCase
857861
)
@@ -863,7 +867,8 @@ export const individualAddressTransformer =
863867
addressLocationLevel,
864868
sectionId,
865869
sectionId,
866-
offlineData
870+
offlineData,
871+
addressCase
867872
)
868873
}
869874
}
@@ -884,7 +889,7 @@ export const addressLineTemplateTransformer =
884889
) => {
885890
const address = (
886891
queryData[sectionId]?.individual?.address ||
887-
queryData[sectionId].address ||
892+
queryData[sectionId]?.address ||
888893
[]
889894
).find((add: { type: AddressCases }) => add.type === addressCase)
890895

@@ -896,7 +901,11 @@ export const addressLineTemplateTransformer =
896901
transformedData[sectionId] = {}
897902
}
898903
const index = lineNumber > 0 ? lineNumber - 1 : lineNumber
899-
const newTransformedName = camelCase(`${sectionId} ${transformedFieldName}`)
904+
const addCase =
905+
addressCase === AddressCases.SECONDARY_ADDRESS ? 'secondary' : 'primary'
906+
const newTransformedName = camelCase(
907+
`${sectionId}_${addCase}_${transformedFieldName}`
908+
)
900909
transformedData[sectionId][newTransformedName] = address.line[index] || ''
901910
}
902911

@@ -921,7 +930,7 @@ export const eventLocationAddressLineTemplateTransformer =
921930
}
922931
const index = lineNumber > 0 ? lineNumber - 1 : lineNumber
923932
transformedData[sectionId][transformedFieldName] =
924-
queryData.eventLocation.address.line[index] || ''
933+
queryData.eventLocation?.address.line[index] || ''
925934
}
926935

927936
export const eventLocationAddressOfflineTransformer =

packages/client/src/views/CorrectionForm/utils.ts

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,11 @@ export const renderValue = (
386386
'statePrimary',
387387
'districtPrimary',
388388
'internationalStatePrimary',
389-
'internationalDistrictPrimary'
389+
'internationalDistrictPrimary',
390+
'stateSecondary',
391+
'districtSecondary',
392+
'internationalStateSecondary',
393+
'internationalDistrictSecondary'
390394
].includes(field.name)
391395
) {
392396
const sectionData = draftData[sectionId]
@@ -396,12 +400,22 @@ export const renderValue = (
396400
resource: 'locations',
397401
initialValue: 'agentDefault'
398402
}
399-
dynamicOption.dependency = [
400-
'internationalStatePrimary',
401-
'statePrimary'
402-
].includes(field.name)
403-
? 'countryPrimary'
404-
: 'statePrimary'
403+
404+
if (field.name.includes('Secondary')) {
405+
dynamicOption.dependency = [
406+
'internationalStateSecondary',
407+
'stateSecondary'
408+
].includes(field.name)
409+
? 'countrySecondary'
410+
: 'stateSecondary'
411+
} else {
412+
dynamicOption.dependency = [
413+
'internationalStatePrimary',
414+
'statePrimary'
415+
].includes(field.name)
416+
? 'countryPrimary'
417+
: 'statePrimary'
418+
}
405419

406420
return renderSelectDynamicLabel(
407421
value,

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

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,11 @@ const renderValue = (
414414
'statePrimary',
415415
'districtPrimary',
416416
'internationalStatePrimary',
417-
'internationalDistrictPrimary'
417+
'internationalDistrictPrimary',
418+
'stateSecondary',
419+
'districtSecondary',
420+
'internationalStateSecondary',
421+
'internationalDistrictSecondary'
418422
].includes(field.name) &&
419423
isOriginalData
420424
) {
@@ -425,12 +429,21 @@ const renderValue = (
425429
resource: 'locations',
426430
initialValue: 'agentDefault'
427431
}
428-
dynamicOption.dependency = [
429-
'internationalStatePrimary',
430-
'statePrimary'
431-
].includes(field.name)
432-
? 'countryPrimary'
433-
: 'statePrimary'
432+
if (field.name.includes('Secondary')) {
433+
dynamicOption.dependency = [
434+
'internationalStateSecondary',
435+
'stateSecondary'
436+
].includes(field.name)
437+
? 'countrySecondary'
438+
: 'stateSecondary'
439+
} else {
440+
dynamicOption.dependency = [
441+
'internationalStatePrimary',
442+
'statePrimary'
443+
].includes(field.name)
444+
? 'countryPrimary'
445+
: 'statePrimary'
446+
}
434447

435448
return renderSelectDynamicLabel(
436449
value,

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23362,7 +23362,7 @@ undefsafe@^2.0.2, undefsafe@^2.0.5:
2336223362
resolved "https://registry.yarnpkg.com/undefsafe/-/undefsafe-2.0.5.tgz#38733b9327bdcd226db889fb723a6efd162e6e2c"
2336323363
integrity sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==
2336423364

23365-
underscore@>1.4.4:
23365+
underscore@>1.12.1, underscore@>1.4.4:
2336623366
version "1.13.6"
2336723367
resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.13.6.tgz#04786a1f589dc6c09f761fc5f45b89e935136441"
2336823368
integrity sha512-+A5Sja4HP1M08MaXya7p5LvjuM7K6q/2EaC0+iovj/wOcMsTzMvDFbasi/oSapiwOlt252IqsKqPjCl7huKS0A==

0 commit comments

Comments
 (0)