From da20bfb6d4a4a8cd80fccb65a3740dc42bc352de Mon Sep 17 00:00:00 2001 From: Rishabh Kunwar Date: Fri, 19 Nov 2021 13:51:02 +0530 Subject: [PATCH] fix: added banner image and profile picture in event page --- component/admin/EventInfo.jsx | 26 +++++++------- component/admin/OrganizerInfo.jsx | 60 ++++++++++++++++++++++++++----- config/config.js | 4 ++- pages/admin/create-event.js | 15 ++++---- services/EventService.js | 17 +++++---- 5 files changed, 82 insertions(+), 40 deletions(-) diff --git a/component/admin/EventInfo.jsx b/component/admin/EventInfo.jsx index 46509c6d..34d286b4 100644 --- a/component/admin/EventInfo.jsx +++ b/component/admin/EventInfo.jsx @@ -1,12 +1,11 @@ import { useRef, useState } from "react"; -import PostService from '../../services/PostService' +import PostService from "../../services/PostService"; const EventInfo = ({ eventDetails, setEventDetails }) => { - const [fileName , setFileName] = useState("") + const [fileName, setFileName] = useState(""); const ref = useRef(); console.log(eventDetails?.eventImage); const imageUploadHandler = async (e) => { - const imageFile = e.target.files[0]; const imageData = { @@ -14,19 +13,20 @@ const EventInfo = ({ eventDetails, setEventDetails }) => { fileName: imageFile.name, category: "events", ContentType: imageFile.type - } + }; try { const s3ImageUrl = await PostService.uploadImage(imageFile, imageData); - if(s3ImageUrl){ - console.log(s3ImageUrl) - } + if (s3ImageUrl) { + setFileName(imageFile.name); + console.log(s3ImageUrl); + setEventDetails((prev) => ({ ...prev, eventImage: s3ImageUrl })); + } } catch (error) { - console.log(error) + console.log(error); } - setFileName(imageFile.name) - } + }; return (
@@ -154,12 +154,10 @@ const EventInfo = ({ eventDetails, setEventDetails }) => { onClick={() => ref.current.click()} >