vr-commons 1.0.130 → 1.0.131
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -91,7 +91,7 @@ export declare const JACKET_ID_REGEX: RegExp;
|
|
|
91
91
|
export declare const JACKET_ID_PREFIX = "JKT";
|
|
92
92
|
/**
|
|
93
93
|
* Format user profile based on viewer type and options
|
|
94
|
-
* FIXED:
|
|
94
|
+
* FIXED: Handle missing primaryContact gracefully
|
|
95
95
|
*/
|
|
96
96
|
export declare const formatUserProfile: (user: User, viewerType?: UserType, options?: ProfileFormatOptions) => RiderProfile | PassengerProfile | AgentProfile | AdminProfile | SuperAdminProfile;
|
|
97
97
|
/**
|
|
@@ -18,17 +18,27 @@ exports.JACKET_ID_PREFIX = "JKT";
|
|
|
18
18
|
// ============================================================================
|
|
19
19
|
/**
|
|
20
20
|
* Format user profile based on viewer type and options
|
|
21
|
-
* FIXED:
|
|
21
|
+
* FIXED: Handle missing primaryContact gracefully
|
|
22
22
|
*/
|
|
23
23
|
const formatUserProfile = (user, viewerType = "ADMIN", options = {}) => {
|
|
24
|
-
//
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
// ✅ FIX: Safely get primary contact
|
|
25
|
+
let primaryContactValue = null;
|
|
26
|
+
// Check if primaryContact is directly loaded
|
|
27
|
+
if (user.primaryContact?.contactValue) {
|
|
28
|
+
primaryContactValue = user.primaryContact.contactValue;
|
|
29
|
+
}
|
|
30
|
+
// Check if primaryContact is in the contacts array
|
|
31
|
+
else if (user.contacts) {
|
|
32
|
+
const primary = user.contacts.find((c) => c.isPrimary === true);
|
|
33
|
+
if (primary) {
|
|
34
|
+
primaryContactValue = primary.contactValue;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
27
37
|
const baseProfile = {
|
|
28
38
|
id: user.id,
|
|
29
39
|
firstName: user.firstName,
|
|
30
40
|
lastName: user.lastName,
|
|
31
|
-
primaryContact:
|
|
41
|
+
primaryContact: primaryContactValue || "N/A",
|
|
32
42
|
gender: user.gender || "male",
|
|
33
43
|
birthDate: user.birthDate || null,
|
|
34
44
|
birthMonth: user.birthMonth || null,
|