File tree Expand file tree Collapse file tree 9 files changed +676
-522
lines changed Expand file tree Collapse file tree 9 files changed +676
-522
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import "bootstrap/dist/css/bootstrap.min.css";
66import Registration from "./components/registration" ;
77import Login from "./components/login" ;
88import Facebook from "./components/facebook" ;
9- import User from "./components/user" ;
9+ import User from "./components/user/index " ;
1010import CreateArticle from "./components/create-article" ;
1111import ArticleView from "./components/article/article-view" ;
1212import PrivateRoute from "./components/privateRoutes" ;
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ const Bookmark = () => {
1010 ( state ) => state . userReducer . bookmarks ,
1111 shallowEqual
1212 ) ;
13- const { _id } = useSelector (
13+ const { _id, user } = useSelector (
1414 ( state ) => state . articlesReducer . article ,
1515 shallowEqual
1616 ) ;
Original file line number Diff line number Diff line change @@ -274,6 +274,14 @@ class ArticleView extends Component {
274274 this . props . dispatch ( deleteArticle ( this . props . match . params . id ) ) ;
275275 window . location = "/" ;
276276 } ;
277+ showBookmark = ( ) => {
278+ if (
279+ this . props . loggedIn &&
280+ this . props . user . id !== this . state . articleDetails . user_id
281+ ) {
282+ return < Bookmark /> ;
283+ }
284+ } ;
277285
278286 render ( ) {
279287 return (
@@ -289,8 +297,7 @@ class ArticleView extends Component {
289297 </ h6 >
290298
291299 < Like />
292- { this . props . loggedIn ? < Bookmark /> : "" }
293-
300+ { this . showBookmark ( ) }
294301 { this . editAndDeleArticle ( ) }
295302
296303 < hr />
Original file line number Diff line number Diff line change 11import React from "react" ;
22import { Link } from "react-router-dom" ;
3+ import { formatDistanceToNow } from "date-fns" ;
4+
35const Article = ( props ) => {
6+ var date = new Date ( props . article . createdAt ) ;
7+
48 return (
59 < div className = "card" >
610 < div className = "card-body" >
@@ -16,7 +20,7 @@ const Article = (props) => {
1620 { props . article . user . name }
1721 </ Link >
1822 < br />
19- < b > Created at - </ b > { props . article . createdAt . substring ( 0 , 10 ) }
23+ < b > { formatDistanceToNow ( date ) } ago </ b >
2024 < br />
2125 </ div >
2226 </ div >
You can’t perform that action at this time.
0 commit comments