client/contexts/AuthContext.js
//users subscriptions into the usersSubscriptions state
users subscriptions into the usersSubscriptions state
users subscriptions into the usersSubscriptions state
function read(user) {
    if (user) {
      const str = user.uid || "";
      userSubReff = ref(database, "users/" + str + "/subscriptions");
      onValue(userSubReff, (snapshot) => {
        setSubs([]);
        const data = snapshot.val();
        if (data !== null) {
          Object.values(data).map((subscription) => {
            setSubs((oldArray) => [...oldArray, subscription]);
          });
        }
      });
      let userExpReff = ref(database, "users/" + str + "/expenses");
      onValue(userExpReff, (snapshot) => {
        setExpenses([]);
        const data = snapshot.val();
        if (data !== null) {
          Object.values(data).map((expense) => {
            setExpenses((oldArray) => [...oldArray, expense]);
          });
        }
      });
      let userIncReff = ref(database, "users/" + str + "/incomes");
      onValue(userIncReff, (snapshot) => {
        setIncomes([]);
        const data = snapshot.val();
        if (data !== null) {
          Object.values(data).map((income) => {
            setIncomes((oldArray) => [...oldArray, income]);
          });
        }
      });
    }
  }
function read ( user ) { if ( user ) { const str = user . uid || "" ; userSubReff = ref ( database , "users/" + str + "/subscriptions" ) ; onValue ( userSubReff , ( snapshot ) => { setSubs ( [ ] ) ; const data = snapshot . val ( ) ; if ( data !== null ) { Object . values ( data ) . map ( ( subscription ) => { setSubs ( ( oldArray ) => [ ... oldArray , subscription ] ) ; } ) ; } } ) ; let userExpReff = ref ( database , "users/" + str + "/expenses" ) ; onValue ( userExpReff , ( snapshot ) => { setExpenses ( [ ] ) ; const data = snapshot . val ( ) ; if ( data !== null ) { Object . values ( data ) . map ( ( expense ) => { setExpenses ( ( oldArray ) => [ ... oldArray , expense ] ) ; } ) ; } } ) ; let userIncReff = ref ( database , "users/" + str + "/incomes" ) ; onValue ( userIncReff , ( snapshot ) => { setIncomes ( [ ] ) ; const data = snapshot . val ( ) ; if ( data !== null ) { Object . values ( data ) . map ( ( income ) => { setIncomes ( ( oldArray ) => [ ... oldArray , income ] ) ; } ) ; } } ) ; } }
users subscriptions into the usersSubscriptions state
users subscriptions into the usersSubscriptions state