|
|
|
@ -2,13 +2,15 @@ import React, { useEffect, useState } from "react"; |
|
|
|
import firebase from "firebase/app"; |
|
|
|
import firebase from "firebase/app"; |
|
|
|
import { Stack } from "@mui/system"; |
|
|
|
import { Stack } from "@mui/system"; |
|
|
|
import { CheckboxListSecondary } from "./index"; |
|
|
|
import { CheckboxListSecondary } from "./index"; |
|
|
|
|
|
|
|
import { useParams } from "react-router-dom"; |
|
|
|
|
|
|
|
|
|
|
|
export const Admin = () => { |
|
|
|
export const Admin = () => { |
|
|
|
const [messaggi, cambiaMessaggi] = useState([]); |
|
|
|
const [messaggi, cambiaMessaggi] = useState([]); |
|
|
|
|
|
|
|
const { evento } = useParams(); |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
// Get a reference to the messages node in the Realtime Database
|
|
|
|
// Get a reference to the messages node in the Realtime Database
|
|
|
|
var messagesRef = firebase.database().ref("/messaggi"); |
|
|
|
var messagesRef = firebase.database().ref(`/messaggi/${evento}`); |
|
|
|
console.log(messagesRef); |
|
|
|
console.log(messagesRef); |
|
|
|
|
|
|
|
|
|
|
|
messagesRef.on("value", function (snapshot) { |
|
|
|
messagesRef.on("value", function (snapshot) { |
|
|
|
@ -34,7 +36,7 @@ export const Admin = () => { |
|
|
|
onChecked={(m) => { |
|
|
|
onChecked={(m) => { |
|
|
|
firebase |
|
|
|
firebase |
|
|
|
.database() |
|
|
|
.database() |
|
|
|
.ref("messaggi/" + m.id) |
|
|
|
.ref(`/messaggi/${evento}/` + m.id) |
|
|
|
.update({ |
|
|
|
.update({ |
|
|
|
approvato: !m.approvato, |
|
|
|
approvato: !m.approvato, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|