notification-bug-fix (#86)
All checks were successful
Deploy FitLien services to Dev / Deploy to Dev (push) Successful in 3m37s

Reviewed-on: #86
Reviewed-by: Dhansh A S <dhanshas@cosq.net>
Co-authored-by: Sharon Dcruz <sharondcruz@cosq.net>
Co-committed-by: Sharon Dcruz <sharondcruz@cosq.net>
This commit is contained in:
Sharon Dcruz 2025-08-14 08:35:40 +00:00 committed by Dhansh A S
parent c2914b16bb
commit d8ae223cce
2 changed files with 5 additions and 2 deletions

View File

@ -4,6 +4,7 @@ import * as admin from "firebase-admin";
const app = getAdmin(); const app = getAdmin();
const logger = getLogger(); const logger = getLogger();
const kTrainerRole = 'Trainer';
interface MembershipData { interface MembershipData {
id?: string; id?: string;
@ -546,6 +547,7 @@ async function sendTrainerNotifications(
const trainerName = await getTrainerName(assignment.trainerId); const trainerName = await getTrainerName(assignment.trainerId);
const trainerUserId = await getTrainerUserId(assignment.trainerId); const trainerUserId = await getTrainerUserId(assignment.trainerId);
const notifType = const notifType =
notificationType === "expired" notificationType === "expired"
? "trainer_client_plan_expired" ? "trainer_client_plan_expired"
@ -588,6 +590,7 @@ async function sendTrainerNotifications(
gymName, gymName,
assignmentId: assignment.id, assignmentId: assignment.id,
formattedExpiryDate: formattedDate, formattedExpiryDate: formattedDate,
role: kTrainerRole,
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()),

View File

@ -181,8 +181,8 @@ function prepareNotificationMessage(
title = title =
notification.data?.title || notification.data?.title ||
(notification.data?.status === "accepted" (notification.data?.status === "accepted"
? "Trainer Request Accepted" ? "Trainer Invitation Accepted"
: "Trainer Request Update"); : "Trainer Invitation Update");
body = body =
notification.data?.message || notification.data?.message ||
`${ `${