I have data loaded from Firebase that loads reserved time slots by time and user ID like this
firebase
.firestore()
.collection(`Mayra`)
.get()
.then((querySnapshot) => {
querySnapshot.forEach((doc) => {
console.log("doc data loaded", doc.data());
doc data loaded Object {
"userDataJson": Object {
"15:00pm a 16:00pm": "oeXjttjPnPhkn6xIqhqsQhJvQM92",
},
}
doc data loaded Object {
"userDataJson": Object {
"11:00am a 12:00pm": "oeXjttjPnPhkn6xIqhqsQhJvQM92",
},
}
doc data loaded Object {
"userDataJson": Object {
"10:00am a 11:00am": "oeXjttjPnPhkn6xIqhqsQhJvQM92",
"17:00pm a 18:00pm": "oeXjttjPnPhkn6xIqhqsQhJvQM92",
},
}
doc data loaded Object {
"userDataJson": Object {
"11:00am a 12:00pm": "oeXjttjPnPhkn6xIqhqsQhJvQM92",
"19:00pm a 20:00pm": "oeXjttjPnPhkn6xIqhqsQhJvQM92",
},
}
and the doc.id from firebase are the dates loaded like this
console.log("doc id loaded", doc.id);
doc id loaded 2021-12-22
doc id loaded 2021-12-23
doc id loaded 2021-12-24
doc id loaded 2021-12-28
I am also loading User data in a different collection like this
const list = [];
await firebase
.firestore()
.collection("Members")
.get()
.then((querySnapshot) => {
querySnapshot.forEach((doc) => {
const { FirstName, LastName, Age, Cell, userId } = doc.data();
list.push({
key: doc.id,
Name: FirstName,
Last: LastName,
Cell: Cell,
Age: Age,
userId: userId
});
});
});
Using react-native-calendars {Agenda} my goal is to create the object array dynamically so that the userID is matched and so that the information can appear like this
const goalExample = {
"2021-11-24": [
{ time: "9:00AM - 10:00AM", name: "Gabo"},
{ time: "10:00AM - 11:00AM", name: "Carlos"},
{ time: "11:00AM - 12:00AM", name: "Jeff" },
],
"2021-11-25": [
{ time: "8:00AM - 9:00AM", name: "Kiki"},
],
"2021-11-26": [],
"2021-11-27": [
{ time: "10:00AM - 11:00AM", name: "Diego" },
],
};
So far I’ve managed to make it to
list.push(doc.id);
list.forEach((day) => {
mark[day] = [
{
time: "9:00AM - 10:00AM",
name: "carlos",
},
];
});
but cannot figure out how to load the data dynamically. Requesting help or other suggestions please.