import * as React from "react"; import Button from "@mui/material/Button"; import { styled } from "@mui/material/styles"; import Dialog from "@mui/material/Dialog"; import DialogTitle from "@mui/material/DialogTitle"; import DialogContent from "@mui/material/DialogContent"; import DialogActions from "@mui/material/DialogActions"; import IconButton from "@mui/material/IconButton"; import CloseIcon from "@mui/icons-material/Close"; import Typography from "@mui/material/Typography"; import Avatar from "@mui/material/Avatar"; import EditSquareIcon from "@mui/icons-material/EditSquare"; import { useRef, useState } from "react"; const BootstrapDialog = styled(Dialog)(({ theme }) => ({ "& .MuiDialogContent-root": { padding: theme.spacing(2), }, "& .MuiDialogActions-root": { padding: theme.spacing(1), }, })); export default function CustomizedDialogs() { const [open, setOpen] = React.useState(false); const handleClickOpen = () => { setOpen(true); }; const handleClose = () => { setOpen(false); }; const inputFile = useRef(null); const openFileExplorer = () => { // `current` points to the mounted file input element if (inputFile.current) { inputFile.current.click(); } }; const [selectedImage, setSelectedImage] = useState(null); return ( Change Profile Picture ({ position: "absolute", right: 8, top: 8, color: theme.palette.grey[500], })} > {selectedImage && Profile Picture} { console.log(event.target.files?[0]:undefined); // Log the selected file if (event.target.files && event.target.files[0]) { setSelectedImage(event.target.files[0]); // Update the state with the selected file } }} /> ); }