@@ -67,7 +67,6 @@ export async function loader({ context, request }: Route.LoaderArgs) {
67
67
68
68
// TODO: the id will likely come from a path param in the URL?
69
69
const personSinCase = await getSinCaseService ( ) . getSinCaseById ( '000000000' ) ;
70
-
71
70
const {
72
71
birthDetails,
73
72
contactInformation,
@@ -76,40 +75,40 @@ export async function loader({ context, request }: Route.LoaderArgs) {
76
75
personalInformation,
77
76
previousSin,
78
77
primaryDocuments,
79
- // TODO - Check why request details is not displayed
80
- // requestDetails,
81
78
secondaryDocument,
82
- } = personSinCase ;
79
+ } = personSinCase ?? { } ;
83
80
84
81
return {
85
82
documentTitle : t ( 'protected:send-validation.page-title' ) ,
86
- caseId : personSinCase . caseId ,
83
+ caseId : personSinCase ? .caseId ?? null ,
87
84
inPersonSINCase : {
88
85
primaryDocuments : {
89
86
...primaryDocuments ,
90
- currentStatusInCanadaName : getLocalizedApplicantStatusInCanadaChoiceById ( primaryDocuments . currentStatusInCanada , lang )
91
- . name ,
92
- documentTypeName : getLocalizedApplicantPrimaryDocumentChoiceById ( primaryDocuments . documentType , lang ) . name ,
93
- genderName : getLocalizedApplicantGenderById ( primaryDocuments . gender , lang ) . name ,
87
+ currentStatusInCanadaName :
88
+ primaryDocuments && getLocalizedApplicantStatusInCanadaChoiceById ( primaryDocuments . currentStatusInCanada , lang ) . name ,
89
+ documentTypeName :
90
+ primaryDocuments && getLocalizedApplicantPrimaryDocumentChoiceById ( primaryDocuments . documentType , lang ) . name ,
91
+ genderName : primaryDocuments && getLocalizedApplicantGenderById ( primaryDocuments . gender , lang ) . name ,
94
92
} ,
95
93
secondaryDocument : {
96
94
...secondaryDocument ,
97
- documentTypeName : getLocalizedApplicantSecondaryDocumentChoiceById ( secondaryDocument . documentType , lang ) . name ,
95
+ documentTypeName :
96
+ secondaryDocument && getLocalizedApplicantSecondaryDocumentChoiceById ( secondaryDocument . documentType , lang ) . name ,
98
97
} ,
99
98
personalInformation : {
100
99
...personalInformation ,
101
- genderName : getLocalizedApplicantGenderById ( personalInformation . gender , lang ) . name ,
100
+ genderName : personalInformation && getLocalizedApplicantGenderById ( personalInformation . gender , lang ) . name ,
102
101
} ,
103
102
birthDetails : {
104
103
...birthDetails ,
105
- countryName : getLocalizedCountryById ( birthDetails . country , lang ) . name ,
106
- provinceName : birthDetails . province
104
+ countryName : birthDetails && getLocalizedCountryById ( birthDetails . country , lang ) . name ,
105
+ provinceName : birthDetails ? .province
107
106
? birthDetails . country === serverEnvironment . PP_CANADA_COUNTRY_CODE
108
107
? getLocalizedProvinceById ( birthDetails . province , lang ) . name
109
108
: birthDetails . province
110
109
: undefined ,
111
110
} ,
112
- parentDetails : parentDetails . map ( ( parentdetail ) => ( {
111
+ parentDetails : parentDetails ? .map ( ( parentdetail ) => ( {
113
112
...parentdetail ,
114
113
countryName : parentdetail . unavailable
115
114
? undefined
@@ -124,26 +123,28 @@ export async function loader({ context, request }: Route.LoaderArgs) {
124
123
} ) ) ,
125
124
contactInformation : {
126
125
...contactInformation ,
127
- preferredLanguageName : getLocalizedLanguageOfCorrespondenceById ( contactInformation . preferredLanguage , lang ) . name ,
128
- countryName : getLocalizedCountryById ( contactInformation . country , lang ) . name ,
126
+ preferredLanguageName :
127
+ contactInformation && getLocalizedLanguageOfCorrespondenceById ( contactInformation . preferredLanguage , lang ) . name ,
128
+ countryName : contactInformation && getLocalizedCountryById ( contactInformation . country , lang ) . name ,
129
129
provinceName :
130
- contactInformation . country === serverEnvironment . PP_CANADA_COUNTRY_CODE
130
+ contactInformation ? .country === serverEnvironment . PP_CANADA_COUNTRY_CODE
131
131
? getLocalizedProvinceById ( contactInformation . province , lang ) . name
132
- : contactInformation . province ,
132
+ : contactInformation ? .province ,
133
133
} ,
134
134
previousSin : {
135
135
...previousSin ,
136
- hasPreviousSinText : getLocalizedApplicantHadSinOptionById ( previousSin . hasPreviousSin , lang ) . name ,
136
+ hasPreviousSinText : previousSin && getLocalizedApplicantHadSinOptionById ( previousSin . hasPreviousSin , lang ) . name ,
137
137
} ,
138
138
currentNameInfo : {
139
139
...currentNameInfo ,
140
- firstName : currentNameInfo . preferredSameAsDocumentName ? primaryDocuments . givenName : currentNameInfo . firstName ,
141
- middleName : currentNameInfo . preferredSameAsDocumentName ? undefined : currentNameInfo . middleName ,
142
- lastName : currentNameInfo . preferredSameAsDocumentName ? primaryDocuments . lastName : currentNameInfo . lastName ,
143
- supportingDocuments : currentNameInfo . preferredSameAsDocumentName ? undefined : currentNameInfo . supportingDocuments ,
144
- supportingDocumentsNames : currentNameInfo . preferredSameAsDocumentName
140
+ preferredSameAsDocumentName : currentNameInfo ?. preferredSameAsDocumentName ,
141
+ firstName : currentNameInfo ?. preferredSameAsDocumentName ? primaryDocuments ?. givenName : currentNameInfo ?. firstName ,
142
+ middleName : currentNameInfo ?. preferredSameAsDocumentName ? undefined : currentNameInfo ?. middleName ,
143
+ lastName : currentNameInfo ?. preferredSameAsDocumentName ? primaryDocuments ?. lastName : currentNameInfo ?. lastName ,
144
+ supportingDocuments : currentNameInfo ?. preferredSameAsDocumentName ? undefined : currentNameInfo ?. supportingDocuments ,
145
+ supportingDocumentsNames : currentNameInfo ?. preferredSameAsDocumentName
145
146
? undefined
146
- : currentNameInfo . supportingDocuments . required
147
+ : currentNameInfo ? .supportingDocuments . required
147
148
? currentNameInfo . supportingDocuments . documentTypes . map (
148
149
( doc ) => getLocalizedApplicantSupportingDocumentTypeById ( doc , lang ) . name ,
149
150
)
0 commit comments