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: Removed email and nationalId references
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: Removed email and nationalId references
21
+ * FIXED: Handle missing primaryContact gracefully
22
22
  */
23
23
  const formatUserProfile = (user, viewerType = "ADMIN", options = {}) => {
24
- // Get primary contact
25
- const primaryContact = user.primaryContact ||
26
- user.contacts?.find((c) => c.isPrimary === true);
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: primaryContact?.contactValue,
41
+ primaryContact: primaryContactValue || "N/A",
32
42
  gender: user.gender || "male",
33
43
  birthDate: user.birthDate || null,
34
44
  birthMonth: user.birthMonth || null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vr-commons",
3
- "version": "1.0.130",
3
+ "version": "1.0.131",
4
4
  "description": "Shared functions package",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",