Changes Updated

This commit is contained in:
Sharon Dcruz 2025-08-05 15:24:21 +05:30
parent c2be01e6b1
commit 3c405012b9

View File

@ -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()),