Skip to content

Commit

Permalink
fix: admin event page #547
Browse files Browse the repository at this point in the history
ui updates
  • Loading branch information
ajoneoito committed Nov 30, 2021
1 parent fa20a23 commit 172fe14
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 29 deletions.
13 changes: 8 additions & 5 deletions pages/admin/events/create-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import moment from "moment";
import Cookies from "universal-cookie";
import notify from "../../../lib/notify";
import { useRouter } from "next/router";
import { getCookieValue } from "../../lib/cookie";
import SharedService from "../../services/SharedService";
import SharedService from "../../../services/SharedService";
import { getCookieValue } from "../../../lib/cookie";


export async function getServerSideProps(context) {
try {
Expand Down Expand Up @@ -102,7 +103,9 @@ const CreateEvent = () => {
try {
const data = await EventService.getEventById(reqData);
const finaldata = data.data;
console.log(finaldata);
const date = moment(finaldata.event_time).format('YYYY-MM-DD')
const time = moment(finaldata.event_time).format('HH:SS')
console.log(date, time)
setEventDetails({
organizerImage: finaldata.guest_image,
organizerName: finaldata.guest_name,
Expand All @@ -111,8 +114,8 @@ const CreateEvent = () => {
eventLocation:finaldata.location,
eventDescription: finaldata.description,
eventLink: finaldata.registration_link,
eventDate: '2020-10-15',
eventTime: "10.30",
eventDate: date,
eventTime: time,
eventImage: finaldata.banner_image
});
} catch (err) {
Expand Down
27 changes: 3 additions & 24 deletions services/EventService.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@ import {
createEventUrl
} from "../config/config";
import { getUrl } from "../lib/getUrl";
import {getImageUrl} from '../pages/admin/create-event'
async function getLatestEvents(reqParams) {
console.log(reqParams)

let url = getUrl();
try {
const res = await axios.get(`${url}/${eventsUrl}`, {
params: reqParams
});
return res.data.data;
} catch (err) {
console.log(err);
throw err;
}
}
Expand All @@ -26,15 +24,14 @@ async function getallevents(){
return data;
}
catch(err){
console.log(err)
throw err
}
}
async function getEventById(eventId) {
try {
const { data } = await axios.get(`${baseUrl}/${eventIdUrl}/${eventId}`);
return data;
} catch (err) {
console.log(err);
throw err;
}
}
Expand All @@ -53,48 +50,31 @@ async function createNewEvent(userCookie, eventData) {
})
if(response){
const res = await getImageUrl(eventData , response)
console.log(res)
response = await updateEvent({
guest_image : res[0],
banner_image : res[1]
}, response.data.data.id)
console.log(response.data)
return response
}
} catch (err) {
console.log(err);
throw err;
}
}
async function updateEvent(userCookie, eventData, eventid) {
try {
const response = await axios.put(`${baseUrl}/api/v1/admin/event/${eventid}` , eventData)
console.log(response);
return response
} catch (err) {
console.log(err);
throw err;
}
}

async function deleteEvent(eventId){
try{
const {data} = await axios.delete(`${baseUrl}/api/v1/admin/event/${eventId}`)
console.log(data)
return data
}catch(err){
console.log(err);
throw err;
}
}
async function getEventbyStatus(req){
console.log(req)
try{
const {data} = await axios.get(`${baseUrl}/v1/events?status=${req.status}`)
console.log(data)
return data
}
catch(err){
console.log(err);
throw err;
}
}
Expand All @@ -106,7 +86,6 @@ async function updateEvent(updatedData , eventId) {
return response
}
} catch (error) {
console.log(err);
throw err;
}
}
Expand Down

0 comments on commit 172fe14

Please sign in to comment.