diff --git a/client/package-lock.json b/client/package-lock.json index 714d44c..9891742 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -9357,14 +9357,6 @@ "resolved": "https://registry.npmjs.org/humps/-/humps-2.0.1.tgz", "integrity": "sha1-3QLqYIG9BWjcXQcxhEY5V7qe+ao=" }, - - "hyphenate-style-name": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/hyphenate-style-name/-/hyphenate-style-name-1.0.4.tgz", - "integrity": "sha512-ygGZLjmXfPHj+ZWh6LwbC37l43MhfztxetbFCoYTM2VjkIUpeHgSNn7QIyVFj7YQ1Wl9Cbw5sholVJPzWvC2MQ==" - }, - - "iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", diff --git a/client/package.json b/client/package.json index 59d6a25..843bb9a 100644 --- a/client/package.json +++ b/client/package.json @@ -58,5 +58,5 @@ "last 1 safari version" ] }, - "proxy": "http://10.100.162.87:8000" + "proxy": "http://192.168.31.68:8000" } diff --git a/client/src/components/blog/addPostForm.jsx b/client/src/components/blog/addPostForm.jsx index 20dff46..995bce1 100644 --- a/client/src/components/blog/addPostForm.jsx +++ b/client/src/components/blog/addPostForm.jsx @@ -91,7 +91,7 @@ const AddPostForm = (props) => { }; return ( - + Create a Post diff --git a/client/src/components/blog/blogskeleton.jsx b/client/src/components/blog/blogskeleton.jsx new file mode 100644 index 0000000..f2953ef --- /dev/null +++ b/client/src/components/blog/blogskeleton.jsx @@ -0,0 +1,19 @@ +import { Box, Flex, SkeletonCircle, SkeletonText } from "@chakra-ui/react"; + +const BlogSkeleton = () => { + return ( + + + + + + + + + + + + ); +}; + +export default BlogSkeleton; diff --git a/client/src/components/blog/showComment.jsx b/client/src/components/blog/showComment.jsx index 4fbf144..7bb7913 100644 --- a/client/src/components/blog/showComment.jsx +++ b/client/src/components/blog/showComment.jsx @@ -5,6 +5,7 @@ import { Flex, FormControl, FormLabel, + IconButton, Menu, MenuButton, MenuItem, @@ -21,14 +22,13 @@ import { useToast, } from "@chakra-ui/react"; import { AuthContext } from "../../contexts/authContext"; -import { useContext, useState, useEffect } from "react"; -import { ChevronDownIcon, TriangleDownIcon } from "@chakra-ui/icons"; -import { BsThreeDots } from "react-icons/bs"; +import { useContext, useState } from "react"; import axios from "axios"; import { useHistory } from "react-router-dom"; import { HtmlEditor, MenuBar } from "@aeaton/react-prosemirror"; import { options, menu } from "@aeaton/react-prosemirror-config-default"; import { Link } from "react-router-dom"; +import { AiOutlineEllipsis } from "react-icons/ai"; const BlogComment = (comment) => { const { isOpen, onOpen, onClose } = useDisclosure(); @@ -108,7 +108,12 @@ const BlogComment = (comment) => { {(comment.user.reg_no === user.reg_no || ["admin", "superadmin"].includes(user.credential.role)) && ( - } /> + } + /> {comment.user.reg_no === user.reg_no && ( Edit diff --git a/client/src/components/blog/singleBlog.jsx b/client/src/components/blog/singleBlog.jsx index 7e4bc69..56ee8dd 100644 --- a/client/src/components/blog/singleBlog.jsx +++ b/client/src/components/blog/singleBlog.jsx @@ -1,9 +1,4 @@ -import { - ChatIcon, - ChevronDownIcon, - DeleteIcon, - TriangleDownIcon, -} from "@chakra-ui/icons"; +import { ChatIcon } from "@chakra-ui/icons"; import { Avatar, Box, @@ -13,7 +8,6 @@ import { FormControl, FormLabel, IconButton, - Image, Input, Menu, MenuButton, @@ -26,17 +20,15 @@ import { ModalFooter, ModalHeader, ModalOverlay, - Select, Spacer, Text, - Textarea, useDisclosure, useToast, } from "@chakra-ui/react"; -import Layout from "../generic/layout"; + import ShowComment from "./showComment"; import WriteComment from "./writeComment"; -import { useContext, useState, useEffect } from "react"; +import { useContext, useState } from "react"; import BlogCarosuel from "./blogCarosuel"; import React from "react"; import { useHistory } from "react-router-dom"; @@ -45,16 +37,16 @@ import axios from "axios"; import { HtmlEditor, MenuBar } from "@aeaton/react-prosemirror"; import { options, menu } from "@aeaton/react-prosemirror-config-default"; import { Link } from "react-router-dom"; +import { AiOutlineEllipsis } from "react-icons/ai"; const SingleBlog = (blog) => { const { isOpen, onOpen, onClose } = useDisclosure(); const initialRef = React.useRef(); const [editedBlog, setEditedBlog] = useState(blog); const [comments, setComments] = useState([]); - const [loadPromise, setLoadPromise] = useState(false); const [requestState, setRequestState] = useState("none"); const [deleteRequestState, setDeleteRequestState] = useState("none"); - const firstField = React.useRef(); + const toast = useToast(); const history = useHistory(); const { unauthorizedHandler, user } = useContext(AuthContext); @@ -143,9 +135,15 @@ const SingleBlog = (blog) => { {(blog.reg_no === user.reg_no || ["admin", "superadmin"].includes(user.credential.role)) && ( - } /> + } + /> - {blog.reg_no === user.reg_no && Edit} + {blog.reg_no === user.reg_no && ( + Edit + )} Delete diff --git a/client/src/pages/approveBlog.jsx b/client/src/pages/approveBlog.jsx index 5fbb930..6972986 100644 --- a/client/src/pages/approveBlog.jsx +++ b/client/src/pages/approveBlog.jsx @@ -1,13 +1,10 @@ import Layout from "../components/generic/layout"; -import { useContext, useState, useEffect } from "react"; +import { useState, useEffect } from "react"; import axios from "axios"; -import { AuthContext } from "../contexts/authContext"; import ApproveBlogCard from "../components/blog/approveBlogCard"; import { Flex } from "@chakra-ui/react"; const ApproveBlog = () => { const [unApprovedBlogs, setunApprovedBlogs] = useState([]); - const { unauthorizedHandler } = useContext(AuthContext); - const [loading, setLoading] = useState(true); useEffect(() => { axios diff --git a/client/src/pages/myBlog.jsx b/client/src/pages/myBlog.jsx index c721053..88a6304 100644 --- a/client/src/pages/myBlog.jsx +++ b/client/src/pages/myBlog.jsx @@ -4,10 +4,12 @@ import Layout from "../components/generic/layout"; import { useState, useEffect } from "react"; import axios from "axios"; import { useHistory } from "react-router-dom"; +import BlogSkeleton from "../components/blog/blogskeleton"; const MyBlog = () => { const [blogs, setBlogs] = useState([]); const history = useHistory(); + const [requestState, setRequestState] = useState("loading"); const addPost = () => { history.push("/addpost"); @@ -17,12 +19,15 @@ const MyBlog = () => { axios .get("/api/blogs/true") .then((res) => { + console.log(res.data); setBlogs(res.data); + setRequestState("loaded"); }) .catch((err) => { console.log(err); }); }, []); + return ( @@ -33,12 +38,11 @@ const MyBlog = () => { placeholder="Create a blog" /> + {requestState === "loading" && } - {blogs - .sort((a, b) => b.id - a.id) - .map((blog) => ( - - ))} + {blogs.map((blog) => ( + + ))} ); diff --git a/client/src/pages/notice.jsx b/client/src/pages/notice.jsx index 8f33c9d..7833c78 100644 --- a/client/src/pages/notice.jsx +++ b/client/src/pages/notice.jsx @@ -1,4 +1,4 @@ -import { Box, Center, Heading } from "@chakra-ui/react"; +import { Box, Center, Heading, Skeleton, Stack } from "@chakra-ui/react"; import SingleNotice from "../components/notice/singleNotice"; import Layout from "../components/generic/layout"; import { useState, useEffect } from "react"; @@ -6,12 +6,14 @@ import axios from "axios"; const Notice = () => { const [notices, setNotices] = useState([]); + const [requestState, setRequestState] = useState("loading"); useEffect(() => { axios .get("/api/notice") .then((res) => { setNotices(res.data); + setRequestState("loaded"); }) .catch((err) => {}); }, []); @@ -22,7 +24,17 @@ const Notice = () => { Notice Board +
+ {requestState === "loading" && ( + + +
contents wrapped
+
won't be visible
+
+
+ )} + {notices.map((notice) => ( diff --git a/client/src/pages/noticeFullView.jsx b/client/src/pages/noticeFullView.jsx index dcccaac..2cfbea0 100644 --- a/client/src/pages/noticeFullView.jsx +++ b/client/src/pages/noticeFullView.jsx @@ -45,6 +45,12 @@ const NoticeFullView = () => { const [loadPromise, setLoadPromise] = useState(false); const key = useParams().id; + const goExternal = (e) => { + window.location.replace( + `/192.168.31.68:8000/${editedNotice.attachment[0]}` + ); + }; + useEffect(() => { setLoading(true); const loadFirst = async () => { @@ -113,6 +119,18 @@ const NoticeFullView = () => { {editedNotice.description} + {editedNotice.attachment.length > 0 && ( + + + + )} +