Skip to content

Commit

Permalink
fix: event page listing issue fixed #518
Browse files Browse the repository at this point in the history
fixed event page issues
  • Loading branch information
jasurobo committed Nov 22, 2021
2 parents d55b121 + 7ea477b commit b1bda19
Show file tree
Hide file tree
Showing 7 changed files with 187 additions and 149 deletions.
26 changes: 12 additions & 14 deletions component/admin/EventInfo.jsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
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 = {
stage: "dev",
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 (
<div className="mx-10 mb-8">
Expand Down Expand Up @@ -154,12 +154,10 @@ const EventInfo = ({ eventDetails, setEventDetails }) => {
onClick={() => ref.current.click()}
>
<label htmlFor="inputFiles" className="font-bold relative">
{fileName === ""
? "Upload Image"
: fileName}
{fileName === "" ? "Upload Image" : fileName}
<input
type="file"
className="opacity-0 absolute top-0 left-0 w-full flex-grow"
className="hidden absolute top-0 left-0 w-full flex-grow"
placeholder="uplaod image"
id="inputFile"
ref={ref}
Expand Down
60 changes: 51 additions & 9 deletions component/admin/OrganizerInfo.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
import Image from "next/image";

import { useRef } from "react";
import PostService from "../../services/PostService";
const OrganizerInfo = ({ eventDetails, setEventDetails }) => {
const ref = useRef();
const imageUploadHandler = async (e) => {
const imageFile = e.target.files[0];

const imageData = {
stage: "dev",
fileName: imageFile.name,
category: "events",
ContentType: imageFile.type
};

try {
const s3ImageUrl = await PostService.uploadImage(imageFile, imageData);

if (s3ImageUrl) {
console.log(s3ImageUrl);
setEventDetails((prev) => ({ ...prev, organizerImage: s3ImageUrl }));
}
} catch (error) {
console.log(error);
}
};
return (
<div className="mx-10 mb-8">
<div className="flex mb-6 items-center justify-center">
Expand All @@ -11,13 +33,33 @@ const OrganizerInfo = ({ eventDetails, setEventDetails }) => {
></div>
</div>
<div className="flex items-center">
<Image
src="/images/svgs/avatar.svg"
alt="profile image"
height={180}
width={180}
className="cursor-pointer"
/>
<div className="relative">
<img
src={`${
eventDetails.organizerImage
? eventDetails.organizerImage
: "/images/svgs/avatar.svg"
}`}
alt="profile image"
height={180}
width={180}
className="cursor-pointer rounded-full"
/>
<div onClick={() => ref.current.click()}>
<label htmlFor="inputFiles" className="font-bold relative pl-8">
Change Photo
<input
type="file"
className="hidden absolute top-0 left-0 w-full flex-grow"
placeholder="uplaod image"
id="inputFile"
ref={ref}
accept="image/*"
onChange={imageUploadHandler}
/>
</label>
</div>
</div>
<div className="flex flex-col flex-grow ml-12">
<div className="flex flex-col mb-3">
<label
Expand Down
4 changes: 3 additions & 1 deletion config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const postsUrl = `${apiVerUrl}/posts`;
const allPostsUrl = "api/posts";
const postUser = `${apiVerUrl}/posts-by-user`;
const eventsUrl = `${apiVerUrl}/events`;
const createEventUrl = `${apiVerUrl}/admin/event`;
const eventIdUrl = `${apiVerUrl}/event`;
const createEventUrl = `${apiVerUrl}/admin/event`;
const changeStatusUrl = "api/user/post";
Expand Down Expand Up @@ -54,6 +55,7 @@ const configVars = {
postsUrl,
allPostsUrl,
eventsUrl,
createEventUrl,
eventIdUrl,
changeStatusUrl,
createEventUrl,
Expand All @@ -72,7 +74,7 @@ const configVars = {
skillUrl,
publishedPostsUrl,
// publishedPostsCountUrl,
logoutUrl,
logoutUrl
};

module.exports = configVars;
15 changes: 6 additions & 9 deletions pages/admin/create-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import notify from "../../lib/notify";
const CreateEvent = () => {
const cookies = new Cookies();
const userCookie = cookies.get("userNullcast");
console.log('cookies' , userCookie)
console.log("cookies", userCookie);
const [eventDetails, setEventDetails] = useState({
organizerImage: "",
organizerName: "",
Expand All @@ -33,20 +33,18 @@ const CreateEvent = () => {
};

const createEventHandler = async (e) => {
const eventData =
{
guest_name: eventDetails.organizerName,
const eventData = {
guest_name: eventDetails.organizerName,
guest_designation: eventDetails.tagLine,
guest_image: "https://upload.wikimedia.org/wikipedia/commons/thumb/8/8e/Nextjs-logo.svg/1200px-Nextjs-logo.svg.png",
guest_image: eventDetails.organizerImage,
title: eventDetails.eventName,
registration_link: eventDetails.eventLink,
banner_image:
"https://upload.wikimedia.org/wikipedia/commons/thumb/8/8e/Nextjs-logo.svg/1200px-Nextjs-logo.svg.png",
banner_image: eventDetails.eventImage,
description: eventDetails.description,
event_time: formatTime()
};
try {
const data = await EventService.createNewEvent(userCookie ,eventData);
const data = await EventService.createNewEvent(userCookie, eventData);
notify(data.data.message);
} catch (error) {
console.log(error);
Expand Down Expand Up @@ -94,5 +92,4 @@ const CreateEvent = () => {
);
};


export default CreateEvent;
41 changes: 20 additions & 21 deletions pages/blog.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ export async function getServerSideProps() {
const limit = 10; //should be 10
// const filterWhatsNew = true;
// const tagsArray = await TagService.getTags(filterWhatsNew);

try {
const postParams = {
// sort_field: "published_at",
// order: "ASC",
order: "DESC",
status: "published",
limit: limit,
page: 1,
page: 1
// with_table: "users, tags"
};
const { data } = await PostService.getPostsByUsers(postParams);
Expand All @@ -45,7 +45,7 @@ export async function getServerSideProps() {
};
}
} catch (err) {
notify(err?.response?.data?.message ?? err?.message, 'error');
notify(err?.response?.data?.message ?? err?.message, "error");
return {
props: {}
};
Expand All @@ -56,22 +56,22 @@ export default function BlogListing({ blog, count, limit }) {
const tagsArray = [
{
count: 0,
status: 'enabled',
_id: '610299948fb9dadb439a392f',
name: 'css',
user_id: '610296398fb9dadb439a392c',
createdAt: '2021-07-29T12:05:40.984Z',
updatedAt: '2021-07-29T12:05:40.984Z',
status: "enabled",
_id: "610299948fb9dadb439a392f",
name: "css",
user_id: "610296398fb9dadb439a392c",
createdAt: "2021-07-29T12:05:40.984Z",
updatedAt: "2021-07-29T12:05:40.984Z",
__v: 0
},
{
count: 0,
status: 'enabled',
_id: '610299a78fb9dadb439a3930',
name: 'fix',
user_id: '610296398fb9dadb439a392c',
createdAt: '2021-07-29T12:05:59.672Z',
updatedAt: '2021-07-29T12:05:59.672Z',
status: "enabled",
_id: "610299a78fb9dadb439a3930",
name: "fix",
user_id: "610296398fb9dadb439a392c",
createdAt: "2021-07-29T12:05:59.672Z",
updatedAt: "2021-07-29T12:05:59.672Z",
__v: 0
}
];
Expand All @@ -85,20 +85,19 @@ export default function BlogListing({ blog, count, limit }) {
const postParams = {
// sort_field: "published_at",
// order: "ASC",
status: 'published',
status: "published",
limit: limit,
page: 1,
page: 1
// with_table: "users, tags"
};
try {
const { data } = await PostService.getPostsByUsers(postParams);
console.log(data, 'success');

console.log(data, 'success');
setNewBlogs((prevValue) => {
return [...prevValue, ...data.posts];
});
} catch (err) {
notify(err?.response?.data?.message ?? err?.message, 'error');
notify(err?.response?.data?.message ?? err?.message, "error");
}
};
return (
Expand Down
Loading

0 comments on commit b1bda19

Please sign in to comment.