From b27ab9c566f4735b26fb6bf085a936f788d63c52 Mon Sep 17 00:00:00 2001 From: mhRumi Date: Sat, 13 Feb 2021 22:50:16 +0600 Subject: [PATCH 1/4] attachment link in notice --- client/package.json | 2 +- client/src/pages/noticeFullView.jsx | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/client/package.json b/client/package.json index eec74d9..843bb9a 100644 --- a/client/package.json +++ b/client/package.json @@ -58,5 +58,5 @@ "last 1 safari version" ] }, - "proxy": "http://192.168.31.159:8000" + "proxy": "http://192.168.31.68:8000" } diff --git a/client/src/pages/noticeFullView.jsx b/client/src/pages/noticeFullView.jsx index dcccaac..45eeb69 100644 --- a/client/src/pages/noticeFullView.jsx +++ b/client/src/pages/noticeFullView.jsx @@ -1,5 +1,5 @@ import React from "react"; -import { EditIcon } from "@chakra-ui/icons"; +import { EditIcon, ExternalLinkIcon } from "@chakra-ui/icons"; import { Box, Button, @@ -9,6 +9,7 @@ import { FormLabel, IconButton, Input, + Link, Modal, ModalBody, ModalCloseButton, @@ -45,6 +46,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 +120,18 @@ const NoticeFullView = () => { {editedNotice.description} + {editedNotice.attachment.length > 0 && ( + + + + )} + Date: Tue, 23 Feb 2021 18:43:52 +0600 Subject: [PATCH 2/4] blog skeleton --- client/src/components/blog/addPostForm.jsx | 2 +- client/src/components/blog/blogskeleton.jsx | 19 ++++++ client/src/components/blog/singleBlog.jsx | 23 +++---- client/src/pages/myBlog.jsx | 67 ++++++++++++--------- client/src/pages/noticeFullView.jsx | 3 +- 5 files changed, 69 insertions(+), 45 deletions(-) create mode 100644 client/src/components/blog/blogskeleton.jsx 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/singleBlog.jsx b/client/src/components/blog/singleBlog.jsx index 91258ce..32478f2 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, TriangleDownIcon } 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,7 +135,10 @@ const SingleBlog = (blog) => { {(blog.reg_no === user.reg_no || ["admin", "superadmin"].includes(user.credential.role)) && ( - } /> + } + /> Edit Delete diff --git a/client/src/pages/myBlog.jsx b/client/src/pages/myBlog.jsx index 55a1d52..88a6304 100644 --- a/client/src/pages/myBlog.jsx +++ b/client/src/pages/myBlog.jsx @@ -4,37 +4,48 @@ 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 [blogs, setBlogs] = useState([]); - const history = useHistory(); + const addPost = () => { + history.push("/addpost"); + }; - const addPost = () =>{ - history.push('/addpost'); - } + useEffect(() => { + axios + .get("/api/blogs/true") + .then((res) => { + console.log(res.data); + setBlogs(res.data); + setRequestState("loaded"); + }) + .catch((err) => { + console.log(err); + }); + }, []); - useEffect(() => { - axios.get("/api/blogs/true").then((res) => { - console.log(res.data); - setBlogs(res.data); - }).catch(err => { - console.log(err); - }) - }, []) - return ( - - - -