Changes Updated
This commit is contained in:
parent
c2be01e6b1
commit
3c405012b9
@ -274,6 +274,7 @@ async function processExpiredMembership(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async function sendPlanExpiredNotification(
|
async function sendPlanExpiredNotification(
|
||||||
membershipId: string,
|
membershipId: string,
|
||||||
membershipData: MembershipData
|
membershipData: MembershipData
|
||||||
@ -298,6 +299,7 @@ async function sendPlanExpiredNotification(
|
|||||||
|
|
||||||
let expiryDate: Date | undefined;
|
let expiryDate: Date | undefined;
|
||||||
let formattedDate = "Unknown Date";
|
let formattedDate = "Unknown Date";
|
||||||
|
let daysSinceExpiry = 0;
|
||||||
|
|
||||||
const payments = await getPaymentsForMembership(membershipId);
|
const payments = await getPaymentsForMembership(membershipId);
|
||||||
if (payments.length > 0) {
|
if (payments.length > 0) {
|
||||||
@ -311,6 +313,10 @@ async function sendPlanExpiredNotification(
|
|||||||
month: "long",
|
month: "long",
|
||||||
day: "numeric",
|
day: "numeric",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const now = new Date();
|
||||||
|
const timeDiff = now.getTime() - expiryDate.getTime();
|
||||||
|
daysSinceExpiry = Math.floor(timeDiff / (1000 * 3600 * 24));
|
||||||
}
|
}
|
||||||
|
|
||||||
await app
|
await app
|
||||||
@ -323,6 +329,7 @@ async function sendPlanExpiredNotification(
|
|||||||
notificationSent: false,
|
notificationSent: false,
|
||||||
timestamp: admin.firestore.FieldValue.serverTimestamp(),
|
timestamp: admin.firestore.FieldValue.serverTimestamp(),
|
||||||
read: false,
|
read: false,
|
||||||
|
readBy: [],
|
||||||
data: {
|
data: {
|
||||||
title: "Plan Expired",
|
title: "Plan Expired",
|
||||||
message: `The plan ${
|
message: `The plan ${
|
||||||
@ -332,7 +339,9 @@ async function sendPlanExpiredNotification(
|
|||||||
clientName,
|
clientName,
|
||||||
membershipId,
|
membershipId,
|
||||||
gymName,
|
gymName,
|
||||||
|
ownerId: gymOwnerId,
|
||||||
formattedExpiryDate: formattedDate,
|
formattedExpiryDate: formattedDate,
|
||||||
|
daysSinceExpiry,
|
||||||
expiryDate: expiryDate
|
expiryDate: expiryDate
|
||||||
? admin.firestore.Timestamp.fromDate(expiryDate)
|
? admin.firestore.Timestamp.fromDate(expiryDate)
|
||||||
: admin.firestore.Timestamp.fromDate(new Date()),
|
: admin.firestore.Timestamp.fromDate(new Date()),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user