import React, { useEffect, useState } from "react"; import firebase from "firebase/compat/app"; import { CircularProgress, Container, Stack, Typography } from "@mui/material"; import logoSrc from "../assets/logo_chat.svg"; export const HomePage = () => { const [eventi, cambiaEventi] = useState([]); useEffect(() => { var messagesRef = firebase.database().ref(`/eventi`); messagesRef.once("value", function (snapshot) { const eventiObject = snapshot.val(); console.log(eventiObject); const e = Object.keys(eventiObject) .map((d) => { return { key: d, ...eventiObject[d] }; }) .sort((a, b) => { return parseInt(a.timestamp) - parseInt(b.timestamp); }) .map((d, i) => { const color = `hsl(${i * 10}, 75%, 70%`; return (
); }); cambiaEventi(e); }); }, []); if (!eventi) return ; return (