antes de alterar login
This commit is contained in:
@@ -20,12 +20,17 @@ export function NotificationMonitor() {
|
||||
// Primeiro, marcamos todas as reservas existentes como "vistas"
|
||||
// para não disparar notificações para o passado
|
||||
const loadExisting = async () => {
|
||||
const snapshot = await get(reservasRef);
|
||||
if (snapshot.exists()) {
|
||||
const data = snapshot.val();
|
||||
Object.keys(data).forEach(id => seenReservas.current.add(id));
|
||||
try {
|
||||
const snapshot = await get(reservasRef);
|
||||
if (snapshot.exists()) {
|
||||
const data = snapshot.val();
|
||||
Object.keys(data).forEach(id => seenReservas.current.add(id));
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("[NotificationMonitor] Error loading existing reservas:", error);
|
||||
} finally {
|
||||
isInitialLoad.current = false;
|
||||
}
|
||||
isInitialLoad.current = false;
|
||||
};
|
||||
|
||||
loadExisting();
|
||||
@@ -40,9 +45,13 @@ export function NotificationMonitor() {
|
||||
// Se ainda estivermos no load inicial (do get), ignoramos o toast
|
||||
if (isInitialLoad.current) return;
|
||||
|
||||
const data = snapshot.val();
|
||||
if (data.restauranteEmail === user.email && data.estado === "Pendente") {
|
||||
toast(`Nova reserva recebida de ${data.clienteEmail}!`, "info");
|
||||
try {
|
||||
const data = snapshot.val();
|
||||
if (data?.restauranteEmail === user.email && data?.estado === "Pendente") {
|
||||
toast(`Nova reserva recebida de ${data?.clienteEmail || "cliente"}!`, "info");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("[NotificationMonitor] Error processing new reserva:", error);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user