image loading
This commit is contained in:
+4
-2
@@ -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,
|
||||||
});
|
});
|
||||||
|
|||||||
+4
-2
@@ -23,7 +23,10 @@ function ImageUpload({ onImageURLSet }) {
|
|||||||
const uploadTask = firebase
|
const uploadTask = firebase
|
||||||
.storage()
|
.storage()
|
||||||
.ref(`images/${image.name}`)
|
.ref(`images/${image.name}`)
|
||||||
.put(image);
|
.put(image, {
|
||||||
|
cacheControl: "public,max-age=3000000",
|
||||||
|
contentType: "image/jpeg",
|
||||||
|
});
|
||||||
|
|
||||||
setState(UPLOADING);
|
setState(UPLOADING);
|
||||||
|
|
||||||
@@ -68,7 +71,6 @@ function ImageUpload({ onImageURLSet }) {
|
|||||||
multiple
|
multiple
|
||||||
type="file"
|
type="file"
|
||||||
accept="image/*"
|
accept="image/*"
|
||||||
capture="camera"
|
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
/>
|
/>
|
||||||
<label htmlFor="raised-button-file">
|
<label htmlFor="raised-button-file">
|
||||||
|
|||||||
+4
-3
@@ -49,9 +49,10 @@ export function CheckboxListSecondary({ messaggi, onChecked }) {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<p
|
<p style={{ maxWidth: 200, width: 200 }}>
|
||||||
style={{ maxWidth: 200, width: 200 }}
|
{`"${m.testo}"`}
|
||||||
>{`"${m.testo}" da ${m.autore}`}</p>
|
{m.autore && <span>da {m.autore}</span>}
|
||||||
|
</p>
|
||||||
<IconButton
|
<IconButton
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user