Fix Firestore undefined value error when creating prayers

This commit is contained in:
nmemmert committed 2026-01-17 15:17:31 -05:00
1 parent a1236c173d
commit b2cea9c0a3
3 files changed
+54 -63

No files matched your search

+9 -3
View File
@@ -102,15 +102,21 @@ export default function Home() {
}
try {
const prayerData = {
const prayerData: any = {
userId: user.uid,
date,
text,
prayFor: prayFor || undefined,
answered,
answerDetails: answerDetails || undefined,
};
// Only add optional fields if they have values
if (prayFor) {
prayerData.prayFor = prayFor;
}
if (answerDetails) {
prayerData.answerDetails = answerDetails;
}
if (editingPrayer) {
// Update existing prayer
await updateDoc(doc(db, 'prayers', editingPrayer.id), prayerData);