antes de alterar login
This commit is contained in:
@@ -17,23 +17,29 @@ export function useStaff() {
|
||||
const staffRef = ref(db, "Staff");
|
||||
|
||||
const unsubscribe = onValue(staffRef, (snapshot) => {
|
||||
const data = snapshot.val();
|
||||
const list: Staff[] = [];
|
||||
|
||||
if (data) {
|
||||
Object.keys(data).forEach((key) => {
|
||||
const item = data[key];
|
||||
if (item.restauranteEmail === user.email) {
|
||||
list.push({
|
||||
id: key,
|
||||
...item
|
||||
});
|
||||
}
|
||||
});
|
||||
try {
|
||||
const data = snapshot.val();
|
||||
const list: Staff[] = [];
|
||||
|
||||
if (data) {
|
||||
Object.keys(data).forEach((key) => {
|
||||
const item = data[key];
|
||||
if (item?.restauranteEmail === user.email) {
|
||||
list.push({
|
||||
id: key,
|
||||
...item
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
setStaff(list);
|
||||
} catch (error) {
|
||||
console.error("[useStaff] Error processing data:", error);
|
||||
setStaff([]);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
setStaff(list);
|
||||
setLoading(false);
|
||||
});
|
||||
|
||||
return () => off(staffRef, "value", unsubscribe);
|
||||
|
||||
Reference in New Issue
Block a user