image loading

This commit is contained in:
Danilo Di Cuia
2023-01-07 19:26:22 +01:00
parent ce499bbed7
commit c71766d6ea
3 changed files with 12 additions and 7 deletions
+4 -2
View File
@@ -2,13 +2,15 @@ import React, { useEffect, useState } from "react";
import firebase from "firebase/app";
import { Stack } from "@mui/system";
import { CheckboxListSecondary } from "./index";
import { useParams } from "react-router-dom";
export const Admin = () => {
const [messaggi, cambiaMessaggi] = useState([]);
const { evento } = useParams();
useEffect(() => {
// 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);
messagesRef.on("value", function (snapshot) {
@@ -34,7 +36,7 @@ export const Admin = () => {
onChecked={(m) => {
firebase
.database()
.ref("messaggi/" + m.id)
.ref(`/messaggi/${evento}/` + m.id)
.update({
approvato: !m.approvato,
});
+4 -2
View File
@@ -23,7 +23,10 @@ function ImageUpload({ onImageURLSet }) {
const uploadTask = firebase
.storage()
.ref(`images/${image.name}`)
.put(image);
.put(image, {
cacheControl: "public,max-age=3000000",
contentType: "image/jpeg",
});
setState(UPLOADING);
@@ -68,7 +71,6 @@ function ImageUpload({ onImageURLSet }) {
multiple
type="file"
accept="image/*"
capture="camera"
onChange={handleChange}
/>
<label htmlFor="raised-button-file">
+4 -3
View File
@@ -49,9 +49,10 @@ export function CheckboxListSecondary({ messaggi, onChecked }) {
}}
/>
<p
style={{ maxWidth: 200, width: 200 }}
>{`"${m.testo}" da ${m.autore}`}</p>
<p style={{ maxWidth: 200, width: 200 }}>
{`"${m.testo}"`}
{m.autore && <span>da {m.autore}</span>}
</p>
<IconButton
variant="outlined"
onClick={() => {