This commit is contained in:
NotII
2025-03-23 22:52:47 +00:00
parent 290bba7f05
commit 4d8e199ab6
6 changed files with 177 additions and 135 deletions

View File

@@ -75,8 +75,13 @@ export default function OrderNotifications() {
const checkForNewOrders = async () => {
try {
// Fetch orders from the last 24 hours that are in paid status
const orderData = await clientFetch("/orders?status=paid&limit=10");
// Get orders from the last 24 hours with a more efficient query
const yesterday = new Date();
yesterday.setDate(yesterday.getDate() - 1);
const timestamp = yesterday.toISOString();
// Include timestamp filter to reduce load
const orderData = await clientFetch(`/orders?status=paid&limit=10&after=${timestamp}`);
const orders: Order[] = orderData.orders || [];
// If this is the first fetch, just store the orders without notifications