From 3c405012b9090822fe52f9bd6753c69a98978d03 Mon Sep 17 00:00:00 2001 From: Sharon Dcruz Date: Tue, 5 Aug 2025 15:24:21 +0530 Subject: [PATCH] Changes Updated --- .../src/notifications/membershipStatusNotifications.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/functions/src/notifications/membershipStatusNotifications.ts b/functions/src/notifications/membershipStatusNotifications.ts index bc908e2..19bb5a8 100644 --- a/functions/src/notifications/membershipStatusNotifications.ts +++ b/functions/src/notifications/membershipStatusNotifications.ts @@ -274,6 +274,7 @@ async function processExpiredMembership( } } + async function sendPlanExpiredNotification( membershipId: string, membershipData: MembershipData @@ -298,6 +299,7 @@ async function sendPlanExpiredNotification( let expiryDate: Date | undefined; let formattedDate = "Unknown Date"; + let daysSinceExpiry = 0; const payments = await getPaymentsForMembership(membershipId); if (payments.length > 0) { @@ -311,6 +313,10 @@ async function sendPlanExpiredNotification( month: "long", day: "numeric", }); + + const now = new Date(); + const timeDiff = now.getTime() - expiryDate.getTime(); + daysSinceExpiry = Math.floor(timeDiff / (1000 * 3600 * 24)); } await app @@ -323,6 +329,7 @@ async function sendPlanExpiredNotification( notificationSent: false, timestamp: admin.firestore.FieldValue.serverTimestamp(), read: false, + readBy: [], data: { title: "Plan Expired", message: `The plan ${ @@ -332,7 +339,9 @@ async function sendPlanExpiredNotification( clientName, membershipId, gymName, + ownerId: gymOwnerId, formattedExpiryDate: formattedDate, + daysSinceExpiry, expiryDate: expiryDate ? admin.firestore.Timestamp.fromDate(expiryDate) : admin.firestore.Timestamp.fromDate(new Date()),