-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8f8260e
commit 386d7e9
Showing
1 changed file
with
66 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,71 @@ | ||
import React from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
import './Articles.css' | ||
import BtnRender from '../../Components/Article/BtnRender'; | ||
import React from "react"; | ||
import { Link } from "react-router-dom"; | ||
import "./Articles.css"; | ||
import BtnRender from "../../Components/Article/BtnRender"; | ||
// import VisibilityIcon from '@material-ui/icons/Visibility'; | ||
import { AiFillEye } from 'react-icons/ai' | ||
import moment from 'moment-timezone' | ||
import { AiFillEye } from "react-icons/ai"; | ||
import moment from "moment-timezone"; | ||
|
||
const ArticleItem = (props) => { | ||
const { title, createdAt, description, images, _id, archived } = props.article; | ||
const timeFormater = moment.utc(createdAt).format('MM/DD/YYYY') | ||
return ( | ||
<> | ||
<div className="article-card"> | ||
<input type="checkbox" checked={checked} | ||
onChange={() => props.handleCheck(_id)} /> | ||
<img className='article-img' src={images.url} alt={title} /> | ||
<div className='article-content'> | ||
<div style={{ padding: '1rem' }}> | ||
{props.isAdmin && props.isLoggedIn ? | ||
|
||
<input type="checkbox" name="archive" onClick={() => props.archiveArticle(_id, archived)}/> : | ||
null | ||
} | ||
<Link to={`/blog/${_id}`} className='article-card-header' | ||
// onClick={() => this.handleCount()} | ||
> | ||
<h2 className='article-card-header' >{title}</h2> | ||
</Link> | ||
<p className="article-card-meta"><span>1 <AiFillEye /> </span>{timeFormater}</p> | ||
<p className="work-content">{props.truncate(description)}</p> | ||
<br /> | ||
</div> | ||
{props.isAdmin && props.isLoggedIn ? | ||
<BtnRender article={props.article} deleteArticle={props.deleteArticle} /> : | ||
null | ||
} | ||
|
||
</div> | ||
const ArticleItem = props => { | ||
const { | ||
title, | ||
createdAt, | ||
description, | ||
images, | ||
_id, | ||
archived | ||
} = props.article; | ||
const timeFormater = moment.utc(createdAt).format("MM/DD/YYYY"); | ||
return ( | ||
<> | ||
<div className="article-card"> | ||
<div style={{ display: "flex" }}> | ||
{props.isAdmin && props.isLoggedIn && ( | ||
<input | ||
type="checkbox" | ||
checked={false} | ||
onChange={() => props.handleCheck(_id)} | ||
/> | ||
)} | ||
<img className="article-img" src={images.url} alt={title} /> | ||
</div> | ||
<div className="article-content"> | ||
<div style={{ padding: "1rem" }}> | ||
{props.isAdmin && props.isLoggedIn ? ( | ||
<input | ||
type="checkbox" | ||
name="archive" | ||
onClick={() => props.archiveArticle(_id, archived)} | ||
/> | ||
) : null} | ||
<Link | ||
to={`/blog/${_id}`} | ||
className="article-card-header" | ||
// onClick={() => this.handleCount()} | ||
> | ||
<h2 className="article-card-header">{title}</h2> | ||
</Link> | ||
<p className="article-card-meta"> | ||
<span> | ||
1 | ||
<AiFillEye /> | ||
</span> | ||
{timeFormater} | ||
</p> | ||
<p className="work-content">{props.truncate(description)}</p> | ||
<br /> | ||
</div> | ||
{props.isAdmin && props.isLoggedIn ? ( | ||
<BtnRender | ||
article={props.article} | ||
deleteArticle={props.deleteArticle} | ||
/> | ||
) : null} | ||
</div> | ||
<hr className='article-line' /> | ||
</> | ||
) | ||
} | ||
</div> | ||
<hr className="article-line" /> | ||
</> | ||
); | ||
}; | ||
|
||
export default ArticleItem; |