search blog update
This commit is contained in:
parent
df179be1fa
commit
49794dfb7b
@ -83,7 +83,8 @@ const Blogs = () => {
|
||||
}).then((value) => {
|
||||
if (value === true) {
|
||||
axios
|
||||
.delete(`/api/v1/blog/deleteblog/${id}`, { // Correct the API endpoint
|
||||
.delete(`/api/v1/blog/deleteblog/${id}`, {
|
||||
// Correct the API endpoint
|
||||
headers: {
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
Authorization: `Bearer ${token}`,
|
||||
@ -110,24 +111,23 @@ const Blogs = () => {
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
setTimeout(() => {
|
||||
if (query !== "") {
|
||||
let searchedResult = [];
|
||||
searchedResult = BlogsData.filter((item) =>
|
||||
item.title.toString().includes(query)
|
||||
const lowerCaseQuery = query.toLowerCase(); // Convert query to lowercase
|
||||
|
||||
const searchedResult = BlogsData.filter((item) =>
|
||||
item.title.toString().toLowerCase().includes(lowerCaseQuery)
|
||||
);
|
||||
|
||||
setShowData(searchedResult);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
getBlogsData();
|
||||
}
|
||||
}, 100);
|
||||
}, [query]);
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<div className="main-content">
|
||||
<div className="page-content">
|
||||
@ -323,7 +323,10 @@ const Blogs = () => {
|
||||
<td className="text-start">
|
||||
<Link to={`/blog/view/${blog._id}`}>
|
||||
<button
|
||||
style={{ color: "white", marginRight: "1rem" }}
|
||||
style={{
|
||||
color: "white",
|
||||
marginRight: "1rem",
|
||||
}}
|
||||
type="button"
|
||||
className="
|
||||
btn btn-primary btn-sm
|
||||
@ -338,7 +341,10 @@ const Blogs = () => {
|
||||
</Link>
|
||||
<Link to={`/blog/edit/${blog._id}`}>
|
||||
<button
|
||||
style={{ color: "white", marginRight: "1rem" }}
|
||||
style={{
|
||||
color: "white",
|
||||
marginRight: "1rem",
|
||||
}}
|
||||
type="button"
|
||||
className="
|
||||
btn btn-info btn-sm
|
||||
@ -381,10 +387,7 @@ const Blogs = () => {
|
||||
aria-live="polite"
|
||||
>
|
||||
Showing {currentPage * itemPerPage - itemPerPage + 1} to{" "}
|
||||
{Math.min(
|
||||
currentPage * itemPerPage,
|
||||
BlogsData.length
|
||||
)}{" "}
|
||||
{Math.min(currentPage * itemPerPage, BlogsData.length)}{" "}
|
||||
of {BlogsData.length} entries
|
||||
</div>
|
||||
</div>
|
||||
|
@ -58,55 +58,6 @@ const CreateBlog = () => {
|
||||
setimage(null);
|
||||
};
|
||||
|
||||
// const handleSubmit = () => {
|
||||
// setLoading(true);
|
||||
|
||||
// const contentState = blogContent.getCurrentContent();
|
||||
// const htmlData = stateToHTML(contentState);
|
||||
// // console.log(title, typeof htmlData, image, tag);
|
||||
|
||||
// const formData = new FormData();
|
||||
// formData.append("title", title);
|
||||
// formData.append("blog_content", htmlData);
|
||||
|
||||
// formData.append("image", image);
|
||||
// formData.append("tags", tag);
|
||||
// // for (let entry of formData.entries()) {
|
||||
// // console.log(entry);
|
||||
// // }
|
||||
// axios
|
||||
// .post(`/api/v1/blog/create`, formData, {
|
||||
// headers: {
|
||||
// Authorization: `Bearer ${token}`,
|
||||
// "Content-Type": "multipart/form-data",
|
||||
// "Access-Control-Allow-Origin": "*",
|
||||
// },
|
||||
// })
|
||||
// .then((res) => {
|
||||
// swal({
|
||||
// title: "Added",
|
||||
// text: "Blog added successfully!",
|
||||
// icon: "success",
|
||||
// button: "ok",
|
||||
// });
|
||||
// setLoading(false);
|
||||
// navigate("/blogs");
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// console.log(err);
|
||||
// setLoading(false);
|
||||
// const message = err.response?.data?.message
|
||||
// ? err.response?.data?.message
|
||||
// : "Something went wrong!";
|
||||
// swal({
|
||||
// title: "Warning",
|
||||
// text: message,
|
||||
// icon: "error",
|
||||
// button: "Retry",
|
||||
// dangerMode: true,
|
||||
// });
|
||||
// });
|
||||
// };
|
||||
const handleSubmit = () => {
|
||||
// Check if any of the required fields are empty
|
||||
if (!title || !image || !tag || !blogContent) {
|
||||
|
Loading…
Reference in New Issue
Block a user