antes de alterar login

This commit is contained in:
2026-05-26 16:40:01 +01:00
parent ef265ceeef
commit 3aa6e5468d
12 changed files with 316 additions and 92 deletions

View File

@@ -17,26 +17,32 @@ export function useMesas() {
const mesasRef = ref(db, "Mesas");
const unsubscribe = onValue(mesasRef, (snapshot) => {
const data = snapshot.val();
const list: Mesa[] = [];
if (data) {
Object.keys(data).forEach((key) => {
const item = data[key];
if (item.restauranteEmail === user.email) {
list.push({
id: key,
...item
});
}
});
}
// Sort by table number
list.sort((a, b) => a.numero - b.numero);
try {
const data = snapshot.val();
const list: Mesa[] = [];
if (data) {
Object.keys(data).forEach((key) => {
const item = data[key];
if (item?.restauranteEmail === user.email) {
list.push({
id: key,
...item
});
}
});
}
// Sort by table number
list.sort((a, b) => a.numero - b.numero);
setMesas(list);
setLoading(false);
setMesas(list);
} catch (error) {
console.error("[useMesas] Error processing data:", error);
setMesas([]);
} finally {
setLoading(false);
}
});
return () => off(mesasRef, "value", unsubscribe);