From 7687f7f511fdc241dde729b583d81f2eacea9433 Mon Sep 17 00:00:00 2001 From: jasirneoito Date: Wed, 12 Jan 2022 09:50:58 +0530 Subject: [PATCH] fix: blog status in admin page and drafted fillter added #633 fixed admin status and added drafted status filtter --- component/admin/AdminBlogsList.jsx | 51 +++++++++++++++++------ component/admin/AdminNavbar.jsx | 65 +++++++++++++++++------------- 2 files changed, 74 insertions(+), 42 deletions(-) diff --git a/component/admin/AdminBlogsList.jsx b/component/admin/AdminBlogsList.jsx index eca932fd..953db6f8 100644 --- a/component/admin/AdminBlogsList.jsx +++ b/component/admin/AdminBlogsList.jsx @@ -14,7 +14,7 @@ export default function AdminBlogsList({ posts, updated }) { * @param {*} blog * @author athulraj2002 * @returns null - * + * */ async function updatePostById(updateData, newPostId) { try { @@ -24,18 +24,18 @@ export default function AdminBlogsList({ posts, updated }) { } updated(); } catch (err) { - notify(err?.response?.data?.message ?? err?.message, 'error'); + notify(err?.response?.data?.message ?? err?.message, "error"); } } const approveBlog = async (blog) => { try { const newUpdatedPost = { - status: 'published', + status: "published" }; updatePostById(blog.id, newUpdatedPost); } catch (err) { - notify(err?.response?.data?.message ?? err?.message, 'error'); + notify(err?.response?.data?.message ?? err?.message, "error"); } }; @@ -48,22 +48,22 @@ export default function AdminBlogsList({ posts, updated }) { const rejectBlog = async (blog) => { try { const newUpdatedPost = { - status: 'rejected', + status: "rejected" }; updatePostById(blog.id, newUpdatedPost); } catch (err) { - notify(err?.response?.data?.message ?? err?.message, 'error'); + notify(err?.response?.data?.message ?? err?.message, "error"); } }; - const unpublishBlog = async (blog) => { + const unPublishBlog = async (blog) => { try { const newUpdatedPost = { - status: 'pending', + status: "pending" }; updatePostById(blog.id, newUpdatedPost); } catch (err) { - notify(err?.response?.data?.message ?? err?.message, 'error'); + notify(err?.response?.data?.message ?? err?.message, "error"); } // console.log(response); }; @@ -97,13 +97,37 @@ export default function AdminBlogsList({ posts, updated }) { {moment(item.updated_at).format("LL")} {" - "} - - {item.user.user_name} - + {item.user.user_name}
+
+ + {item.status} + +
+ {item.status == "published" ? (
unpublishBlog(item)} + onClick={() => unPublishBlog(item)} className={`flex items-center w-28 justify-center rounded-full h-8 mr-3 cursor-pointer hover:opacity-50 duration-500 ${MyBlogStyles.warningBg} `} > { getSettingsTags(); @@ -71,34 +72,40 @@ export default function AdminNavbar({ changeTag, changeStatus, event }) {
- {event ? " " : - selectStatus(e)} - className={`basic-single postFilter md:block hidden m-0 outline-none focus:outline-none text-sm bg-gray-200 border rounded px-0 cursor-pointer ${styles.min_w_10}`} - classNamePrefix="Blog Status" - clearValue={() => undefined} - placeholder="Select Status" - // closeMenuOnSelect={false} - />} - {router.pathname.split('/')[2] === 'events' &&
+ {event ? ( + " " + ) : ( + selectStatus(e)} + className={`basic-single postFilter md:block hidden m-0 outline-none focus:outline-none text-sm bg-gray-200 border rounded px-0 cursor-pointer ${styles.min_w_10}`} + classNamePrefix="Blog Status" + clearValue={() => undefined} + placeholder="Select Status" + // closeMenuOnSelect={false} + /> + )} + {router.pathname.split("/")[2] === "events" && ( + } +
+ )}
-
);