Skip to content

Commit

Permalink
fix: changed put function to patch
Browse files Browse the repository at this point in the history
  • Loading branch information
rishabhkunwar11 committed Feb 1, 2022
1 parent b31fe43 commit e6d1f3a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 22 deletions.
2 changes: 1 addition & 1 deletion pages/events/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export default function EventListing({ events, count, limit }) {
{newEvents && <EventFeatured event={newEvents[0] || ""} />}
{newEvents?.length > 0 ? (
<EvListing
events={newEvents.slice(1) || ""}
events={events?.filter((each) => each.id !== newEvents[0]?.id) || ""}
currentCount={currentCount}
eventCount={newEvents.count}
/>
Expand Down
25 changes: 20 additions & 5 deletions services/EventService.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,23 +114,23 @@ async function updateEvent(eventId, updatedData) {
if (res) {
console.log(res);
if (typeof res === "object" && !res.url) {
const response = await axios.put(
const response = await axios.patch(
`${baseUrl}/${createEventUrl}/${eventId}`,
{ ...updatedData, guest_image: res[0], banner_image: res[1] }
);
if (response) {
return response;
}
} else if (res.type === "guest") {
const response = await axios.put(
const response = await axios.patch(
`${baseUrl}/${createEventUrl}/${eventId}`,
{ ...updatedData, guest_image: res.url }
);
if (response) {
return response;
}
} else if (res.type === "banner") {
const response = await axios.put(
const response = await axios.patch(
`${baseUrl}/${createEventUrl}/${eventId}`,
{ ...updatedData, banner_image: res.url }
);
Expand All @@ -140,7 +140,7 @@ async function updateEvent(eventId, updatedData) {
}
} else {
try {
const response = await axios.put(
const response = await axios.patch(
`${baseUrl}/${createEventUrl}/${eventId}`,
updatedData
);
Expand All @@ -157,7 +157,7 @@ async function updateEvent(eventId, updatedData) {
}
} else {
try {
const response = await axios.put(
const response = await axios.patch(
`${baseUrl}/${createEventUrl}/${eventId}`,
updatedData
);
Expand All @@ -170,6 +170,20 @@ async function updateEvent(eventId, updatedData) {
}
}

//admin review event

async function adminReviewEvent(eventId, adminReviewdData) {
try {
const response = await axios.patch(
`${baseUrl}/${adminEventReviewUrl}/${eventId}`,
adminReviewdData
);
if (response) {
return response.data;
}
} catch (error) {}
}

// book event
async function bookEvent(email, eventId, full_name, userId) {
try {
Expand Down Expand Up @@ -215,6 +229,7 @@ const EventService = {
createNewEvent,
getAllEvents,
getAllEventsSlug,
adminReviewEvent,
deleteEvent,
getEventByStatus,
updateEvent
Expand Down
31 changes: 15 additions & 16 deletions services/PostService.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ async function updatePostById(postId, postDetails) {

async function adminReview(postId, postDetails) {
try {
const { data } = await axios.put(
const { data } = await axios.patch(
`${baseUrl}/${adminReviewUrl}/${postId}`,
postDetails
);
Expand Down Expand Up @@ -165,25 +165,24 @@ async function deletePostById(userCookie, postId) {
// }
// }

async function getPostByTags(tagName, status , data) {
if(data){
const response = await axios.get(`${baseUrl}/${postsUrl}/${data?.tag}` , {
params : data
})
return response.data
}
else{
try {
const response = await axios.get(`${baseUrl}/${postsUrl}/${tagName}`, {
params: { status: status }
async function getPostByTags(tagName, status, data) {
if (data) {
const response = await axios.get(`${baseUrl}/${postsUrl}/${data?.tag}`, {
params: data
});
return response.data;
} catch (err) {
console.log(err);
throw err;
} else {
try {
const response = await axios.get(`${baseUrl}/${postsUrl}/${tagName}`, {
params: { status: status }
});
return response.data;
} catch (err) {
console.log(err);
throw err;
}
}
}
}

async function adminChangePostStatus(userCookie, postId, statusUpdate) {
try {
Expand Down

0 comments on commit e6d1f3a

Please sign in to comment.