"use client"; import { useRef, useState } from "react"; import { Button } from "@mui/material"; import ProfileP from "@/components/icons/ProfileP"; import ArrowLeftPU from "@/components/icons/ArrowLeftPU"; import { uploadImage } from "@/helper"; import ModalUpload from "./ModalUpload"; import Image from "next/image"; function UploadFile({ image, setImage }) { const fileRef = useRef(); const [open, setOpen] = useState(false); const [data, setData] = useState(); const handleClose = () => setOpen(false); const handleOpen = () => setOpen(true); const openInput = () => fileRef.current.click(); const handleChange = async (event) => { if (!!event.target.value) { const result = await uploadImage(event); handleOpen(); setData(result); } }; const uploadImg = (prop) => { setImage(prop); handleClose(); }; return ( <>
{image ? ( img-uploaded ) : (
)}
); } export default UploadFile;