Fix Firestore undefined value error when creating prayers
This commit is contained in:
1 parent
a1236c173d
commit
b2cea9c0a3
3 files changed
+54
-63
No files matched your search
+9
-3
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user