Week 10 Issue with Stripe Payment History
Title : Dashboard Issue
Author Sampurna Adhikari
Both the Food Donor and Food Receiver have access to the Dashboard where Active Listings, Completed Orders and Active Requests are shown.
The issue is the Active Listings and Requests are being displayed and for the Total Spent, the amount is not being pulled.
let totalSales = 0;
let ordersSnap = { docs: [] };
const donorStripeId = userData?.stripeAccountId || userData?.donorStripeId;
console.log(" Donor Stripe ID:", donorStripeId);
if (donorStripeId) {
try {
ordersSnap = await getDocs(
query(
collection(db, "orders"),
where("donorStripeId", "==", donorStripeId),
orderBy("createdAt", "desc")
)
);
console.log(` Orders found: ${ordersSnap.size}`);
totalSales = ordersSnap.docs.reduce(
(sum, d) => sum + (d.data().totalAmount || 0),
0
);
console.log(` Total sales: $${totalSales}`);
} catch (err) {
console.error("Error fetching orders:", err);
}
} else {
console.log(" No Stripe ID found for donor");
}

Comments
Post a Comment