notification-bug-fix #105
@ -406,14 +406,12 @@ async function getTrainerName(trainerId: string): Promise<string> {
|
|||||||
.collection("trainer_profiles")
|
.collection("trainer_profiles")
|
||||||
.doc(trainerId)
|
.doc(trainerId)
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
if (!doc.exists) {
|
if (!doc.exists) {
|
||||||
const userDoc = await app
|
const userDoc = await app
|
||||||
.firestore()
|
.firestore()
|
||||||
.collection("users")
|
.collection("users")
|
||||||
.doc(trainerId)
|
.doc(trainerId)
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
if (userDoc.exists) {
|
if (userDoc.exists) {
|
||||||
const userData = userDoc.data();
|
const userData = userDoc.data();
|
||||||
return userData?.name || userData?.displayName || "Unknown Trainer";
|
return userData?.name || userData?.displayName || "Unknown Trainer";
|
||||||
@ -428,7 +426,6 @@ async function getTrainerName(trainerId: string): Promise<string> {
|
|||||||
const lastName = fields["last-name"] || "";
|
const lastName = fields["last-name"] || "";
|
||||||
return `${firstName} ${lastName}`.trim() || "Unknown Trainer";
|
return `${firstName} ${lastName}`.trim() || "Unknown Trainer";
|
||||||
}
|
}
|
||||||
|
|
||||||
return data?.name || data?.displayName || "Unknown Trainer";
|
return data?.name || data?.displayName || "Unknown Trainer";
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(`Error getting trainer name for ${trainerId}:`, error);
|
logger.error(`Error getting trainer name for ${trainerId}:`, error);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user