@blackcode_sa/metaestetics-api 1.12.70 → 1.12.71
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.
package/dist/index.js
CHANGED
|
@@ -18094,22 +18094,39 @@ var ReviewService = class extends BaseService {
|
|
|
18094
18094
|
* @returns A JavaScript Date object or null
|
|
18095
18095
|
*/
|
|
18096
18096
|
convertTimestamp(timestamp) {
|
|
18097
|
-
if (!timestamp)
|
|
18097
|
+
if (!timestamp) {
|
|
18098
|
+
console.warn("\u26A0\uFE0F convertTimestamp received null/undefined timestamp");
|
|
18099
|
+
return /* @__PURE__ */ new Date();
|
|
18100
|
+
}
|
|
18101
|
+
console.log("\u{1F50D} convertTimestamp input:", {
|
|
18102
|
+
type: typeof timestamp,
|
|
18103
|
+
value: timestamp,
|
|
18104
|
+
hasToDate: (timestamp == null ? void 0 : timestamp.toDate) !== void 0,
|
|
18105
|
+
hasIsTimestamp: (timestamp == null ? void 0 : timestamp.__isTimestamp) !== void 0,
|
|
18106
|
+
hasSeconds: (timestamp == null ? void 0 : timestamp.seconds) !== void 0
|
|
18107
|
+
});
|
|
18098
18108
|
if (timestamp && timestamp.__isTimestamp === true && typeof timestamp.seconds === "number") {
|
|
18099
|
-
|
|
18109
|
+
const converted = new Date(timestamp.seconds * 1e3 + (timestamp.nanoseconds || 0) / 1e6);
|
|
18110
|
+
console.log("\u2705 Converted __isTimestamp:", converted);
|
|
18111
|
+
return converted;
|
|
18100
18112
|
}
|
|
18101
18113
|
if (timestamp && timestamp.toDate && typeof timestamp.toDate === "function") {
|
|
18102
|
-
|
|
18114
|
+
const converted = timestamp.toDate();
|
|
18115
|
+
console.log("\u2705 Converted using toDate():", converted);
|
|
18116
|
+
return converted;
|
|
18103
18117
|
}
|
|
18104
18118
|
if (timestamp instanceof Date) {
|
|
18119
|
+
console.log("\u2705 Already a Date object:", timestamp);
|
|
18105
18120
|
return timestamp;
|
|
18106
18121
|
}
|
|
18107
18122
|
if (typeof timestamp === "string" || typeof timestamp === "number") {
|
|
18108
18123
|
const date = new Date(timestamp);
|
|
18109
18124
|
if (!isNaN(date.getTime())) {
|
|
18125
|
+
console.log("\u2705 Converted from string/number:", date);
|
|
18110
18126
|
return date;
|
|
18111
18127
|
}
|
|
18112
18128
|
}
|
|
18129
|
+
console.warn("\u26A0\uFE0F Could not convert timestamp, returning current date. Input was:", timestamp);
|
|
18113
18130
|
return /* @__PURE__ */ new Date();
|
|
18114
18131
|
}
|
|
18115
18132
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -18352,22 +18352,39 @@ var ReviewService = class extends BaseService {
|
|
|
18352
18352
|
* @returns A JavaScript Date object or null
|
|
18353
18353
|
*/
|
|
18354
18354
|
convertTimestamp(timestamp) {
|
|
18355
|
-
if (!timestamp)
|
|
18355
|
+
if (!timestamp) {
|
|
18356
|
+
console.warn("\u26A0\uFE0F convertTimestamp received null/undefined timestamp");
|
|
18357
|
+
return /* @__PURE__ */ new Date();
|
|
18358
|
+
}
|
|
18359
|
+
console.log("\u{1F50D} convertTimestamp input:", {
|
|
18360
|
+
type: typeof timestamp,
|
|
18361
|
+
value: timestamp,
|
|
18362
|
+
hasToDate: (timestamp == null ? void 0 : timestamp.toDate) !== void 0,
|
|
18363
|
+
hasIsTimestamp: (timestamp == null ? void 0 : timestamp.__isTimestamp) !== void 0,
|
|
18364
|
+
hasSeconds: (timestamp == null ? void 0 : timestamp.seconds) !== void 0
|
|
18365
|
+
});
|
|
18356
18366
|
if (timestamp && timestamp.__isTimestamp === true && typeof timestamp.seconds === "number") {
|
|
18357
|
-
|
|
18367
|
+
const converted = new Date(timestamp.seconds * 1e3 + (timestamp.nanoseconds || 0) / 1e6);
|
|
18368
|
+
console.log("\u2705 Converted __isTimestamp:", converted);
|
|
18369
|
+
return converted;
|
|
18358
18370
|
}
|
|
18359
18371
|
if (timestamp && timestamp.toDate && typeof timestamp.toDate === "function") {
|
|
18360
|
-
|
|
18372
|
+
const converted = timestamp.toDate();
|
|
18373
|
+
console.log("\u2705 Converted using toDate():", converted);
|
|
18374
|
+
return converted;
|
|
18361
18375
|
}
|
|
18362
18376
|
if (timestamp instanceof Date) {
|
|
18377
|
+
console.log("\u2705 Already a Date object:", timestamp);
|
|
18363
18378
|
return timestamp;
|
|
18364
18379
|
}
|
|
18365
18380
|
if (typeof timestamp === "string" || typeof timestamp === "number") {
|
|
18366
18381
|
const date = new Date(timestamp);
|
|
18367
18382
|
if (!isNaN(date.getTime())) {
|
|
18383
|
+
console.log("\u2705 Converted from string/number:", date);
|
|
18368
18384
|
return date;
|
|
18369
18385
|
}
|
|
18370
18386
|
}
|
|
18387
|
+
console.warn("\u26A0\uFE0F Could not convert timestamp, returning current date. Input was:", timestamp);
|
|
18371
18388
|
return /* @__PURE__ */ new Date();
|
|
18372
18389
|
}
|
|
18373
18390
|
/**
|
package/package.json
CHANGED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Review Date Timestamp Fix
|
|
2
|
+
|
|
3
|
+
## Problem
|
|
4
|
+
All reviews in the Patient App were displaying the same date (e.g., "September 26, 2025") regardless of when they were actually created. This was causing confusion as users couldn't distinguish between reviews from different dates.
|
|
5
|
+
|
|
6
|
+
## Root Cause
|
|
7
|
+
When fetching reviews from Firestore, the `createdAt` and `updatedAt` fields were Firestore Timestamp objects that weren't being properly converted to JavaScript Date objects. The code was using:
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
const reviews = snapshot.docs.map(doc => doc.data() as Review);
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
This direct type casting doesn't convert Firestore Timestamps (which have `seconds` and `nanoseconds` properties) into proper Date objects, leading to inconsistent date handling across the application.
|
|
14
|
+
|
|
15
|
+
## Solution
|
|
16
|
+
Added two helper methods to the `ReviewService` class:
|
|
17
|
+
|
|
18
|
+
### 1. `convertTimestamp(timestamp: any): Date`
|
|
19
|
+
Converts various timestamp formats to JavaScript Date objects:
|
|
20
|
+
- Firestore Timestamp with `__isTimestamp` flag
|
|
21
|
+
- Firestore Timestamp with `toDate()` method
|
|
22
|
+
- Regular Date objects
|
|
23
|
+
- String or number timestamps
|
|
24
|
+
- Fallback to current date for invalid inputs
|
|
25
|
+
|
|
26
|
+
### 2. `convertDocToReview(docData: any): Review`
|
|
27
|
+
Converts raw Firestore document data to a properly formatted Review object by:
|
|
28
|
+
- Converting main review timestamps (`createdAt`, `updatedAt`)
|
|
29
|
+
- Converting clinic review timestamps if present
|
|
30
|
+
- Converting practitioner review timestamps if present
|
|
31
|
+
- Converting procedure review timestamps if present
|
|
32
|
+
- Converting extended procedure reviews timestamps if present
|
|
33
|
+
|
|
34
|
+
## Changes Made
|
|
35
|
+
|
|
36
|
+
### Files Modified
|
|
37
|
+
- `Api/src/services/reviews/reviews.service.ts`
|
|
38
|
+
|
|
39
|
+
### Methods Updated
|
|
40
|
+
All review fetching methods now use `convertDocToReview()`:
|
|
41
|
+
1. `getReviewsByPatient(patientId: string)` - Line 372
|
|
42
|
+
2. `getReviewsByClinic(clinicId: string)` - Line 443
|
|
43
|
+
3. `getReviewsByPractitioner(practitionerId: string)` - Line 538
|
|
44
|
+
4. `getReview(reviewId: string)` - Line 285
|
|
45
|
+
5. `getReviewByAppointment(appointmentId: string)` - Line 723
|
|
46
|
+
|
|
47
|
+
## Package Version
|
|
48
|
+
- **Published Version**: `@blackcode_sa/metaestetics-api@1.12.70`
|
|
49
|
+
- **Change Type**: Patch (bug fix)
|
|
50
|
+
|
|
51
|
+
## Apps Updated
|
|
52
|
+
All apps have been updated to use version 1.12.70:
|
|
53
|
+
- ✅ Mobile (Patient App)
|
|
54
|
+
- ✅ DoctorMobile
|
|
55
|
+
- ✅ ClinicApp
|
|
56
|
+
|
|
57
|
+
## Testing
|
|
58
|
+
After updating, verify that:
|
|
59
|
+
1. Reviews display their actual creation dates
|
|
60
|
+
2. Each review shows a different date (if created on different days)
|
|
61
|
+
3. Dates are formatted correctly in the format: "Month Day, Year" (e.g., "September 26, 2025")
|
|
62
|
+
|
|
63
|
+
## Impact
|
|
64
|
+
This fix ensures that all review dates are properly displayed across all applications, allowing users to accurately track when feedback was submitted.
|
|
65
|
+
|
|
@@ -35,20 +35,37 @@ export class ReviewService extends BaseService {
|
|
|
35
35
|
* @returns A JavaScript Date object or null
|
|
36
36
|
*/
|
|
37
37
|
private convertTimestamp(timestamp: any): Date {
|
|
38
|
-
|
|
38
|
+
// Log what we receive for debugging
|
|
39
|
+
if (!timestamp) {
|
|
40
|
+
console.warn('⚠️ convertTimestamp received null/undefined timestamp');
|
|
41
|
+
return new Date();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
console.log('🔍 convertTimestamp input:', {
|
|
45
|
+
type: typeof timestamp,
|
|
46
|
+
value: timestamp,
|
|
47
|
+
hasToDate: timestamp?.toDate !== undefined,
|
|
48
|
+
hasIsTimestamp: timestamp?.__isTimestamp !== undefined,
|
|
49
|
+
hasSeconds: timestamp?.seconds !== undefined,
|
|
50
|
+
});
|
|
39
51
|
|
|
40
52
|
// Firebase Timestamp object with __isTimestamp
|
|
41
53
|
if (timestamp && timestamp.__isTimestamp === true && typeof timestamp.seconds === 'number') {
|
|
42
|
-
|
|
54
|
+
const converted = new Date(timestamp.seconds * 1000 + (timestamp.nanoseconds || 0) / 1000000);
|
|
55
|
+
console.log('✅ Converted __isTimestamp:', converted);
|
|
56
|
+
return converted;
|
|
43
57
|
}
|
|
44
58
|
|
|
45
59
|
// Firebase Firestore Timestamp with toDate method
|
|
46
60
|
if (timestamp && timestamp.toDate && typeof timestamp.toDate === 'function') {
|
|
47
|
-
|
|
61
|
+
const converted = timestamp.toDate();
|
|
62
|
+
console.log('✅ Converted using toDate():', converted);
|
|
63
|
+
return converted;
|
|
48
64
|
}
|
|
49
65
|
|
|
50
66
|
// Already a Date object
|
|
51
67
|
if (timestamp instanceof Date) {
|
|
68
|
+
console.log('✅ Already a Date object:', timestamp);
|
|
52
69
|
return timestamp;
|
|
53
70
|
}
|
|
54
71
|
|
|
@@ -56,10 +73,12 @@ export class ReviewService extends BaseService {
|
|
|
56
73
|
if (typeof timestamp === 'string' || typeof timestamp === 'number') {
|
|
57
74
|
const date = new Date(timestamp);
|
|
58
75
|
if (!isNaN(date.getTime())) {
|
|
76
|
+
console.log('✅ Converted from string/number:', date);
|
|
59
77
|
return date;
|
|
60
78
|
}
|
|
61
79
|
}
|
|
62
80
|
|
|
81
|
+
console.warn('⚠️ Could not convert timestamp, returning current date. Input was:', timestamp);
|
|
63
82
|
return new Date();
|
|
64
83
|
}
|
|
65
84
|
|