diff --git a/src/app/blog/components/TagInput.tsx b/src/app/blog/components/TagInput.tsx index cf8ac53..9f0f931 100644 --- a/src/app/blog/components/TagInput.tsx +++ b/src/app/blog/components/TagInput.tsx @@ -15,7 +15,10 @@ const TagInput: React.FC = () => { const [tagInput, setTagInput] = useState(""); // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment - const [blog, setBlog] = useEditorContent((state: any) => [ state.blog as BlogTagTypes,state.setBlog,]); + const [blog, setBlog] = useEditorContent((state: any) => [ + state.blog as BlogTagTypes, + state.setBlog, + ]); // const onTagsChnage = (e: React.ChangeEvent) => { // } @@ -24,7 +27,6 @@ const TagInput: React.FC = () => { setTagInput(event.target.value); }; - console.log("tags", tags); const handleAddTag = () => { if (tagInput.trim() !== "" && !tags.includes(tagInput)) { setTags([...tags, tagInput]); @@ -34,9 +36,8 @@ const TagInput: React.FC = () => { const handleAutocompleteChange = ( event: React.SyntheticEvent, - value: string | null + value: string | null, ) => { - console.log("value", event); if (value) { setTags([...tags, value]); } diff --git a/src/app/home/HeroPage.tsx b/src/app/home/HeroPage.tsx index 01078b9..7adf7c0 100644 --- a/src/app/home/HeroPage.tsx +++ b/src/app/home/HeroPage.tsx @@ -93,7 +93,7 @@ export default function HeroPage() { { - if (!profile && !blogs) return; - else setIsLoading(false); - }, [profile, blogs]); + console.log("isloading", isLoading); return ( + + + - {isLoading ? ( - - - - ) : ( + + - - - + - - - {/* - Blogs - */} - {blogs.length == 0 && ( - - No Blogs Yet - - )} - {blogs.map((blog, idx) => { - return ( - { - window.location.href = `/${blog._id}`; - }} - > + + + {isLoading == false && blogs.length == 0 && ( + + No Blogs Yet + + )} + {isLoading ? ( + + + + ) : ( + <> + {blogs.map((blog, idx) => { + return ( { + window.location.href = `/${blog._id}`; + }} > - - - - - {blog.title} - - - - - - {(blog.likes as []).length} - + - - - {(blog.comments as []).length} - - + + + {blog.title} + + + + + + {(blog.likes as []).length} + + + + + + {(blog.comments as []).length} + + + - - - {blog.date} + + {blog.date} + - - - - ); - })} - + + + ); + })} + + )} - )} + ); } diff --git a/src/app/user/components/Loaders.tsx b/src/app/user/components/Loaders.tsx new file mode 100644 index 0000000..b1e8d54 --- /dev/null +++ b/src/app/user/components/Loaders.tsx @@ -0,0 +1,14 @@ +import Skeleton from "@mui/material/Skeleton"; +import Stack from "@mui/material/Stack"; + +export default function Loaders() { + return ( + + + + + + + + ); +} diff --git a/src/layout/headeroptions/HeaderActions.tsx b/src/layout/headeroptions/HeaderActions.tsx index 076cb52..465cc82 100644 --- a/src/layout/headeroptions/HeaderActions.tsx +++ b/src/layout/headeroptions/HeaderActions.tsx @@ -58,6 +58,9 @@ const AuthorizedActions = () => { const savedNotify = () => toast.success("🎉Yayy, Congrats on adding value to community amigo!"); + const noImageNotify = () => + toast.error("Please add a cover image to your blog!"); + useEffect(() => { if (location.pathname !== "/blog/create") { // eslint-disable-next-line @typescript-eslint/no-unsafe-call @@ -71,6 +74,11 @@ const AuthorizedActions = () => { const uploadImageToFirebase = async () => { if (blog == null) return; + if (blog.coverImage == null || blog.coverImage == "") { + noImageNotify(); + return; + } + const user = JSON.parse( localStorage.getItem("user") as string, ) as unknown as userTypes; diff --git a/src/lib/axios/api.ts b/src/lib/axios/api.ts index 14a2b53..c245843 100644 --- a/src/lib/axios/api.ts +++ b/src/lib/axios/api.ts @@ -42,7 +42,6 @@ const APIMethods = { return await APIInstance.post(`/blog/getBlog`, blogId); }, createBlog: async (data: any) => { - console.log(data); return await AuthorizedAPIInstance.post("/blog/create", data); }, updateBlog: async (id: string, data: any) => {