Skip to content

Commit

Permalink
fix(*): update articles pages
Browse files Browse the repository at this point in the history
  • Loading branch information
HoseaCodes committed Feb 12, 2024
1 parent 8f8260e commit 386d7e9
Showing 1 changed file with 66 additions and 41 deletions.
107 changes: 66 additions & 41 deletions src/Pages/Articles/ArticleCard.jsx
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 &nbsp;<AiFillEye /> &nbsp;</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 &nbsp;
<AiFillEye /> &nbsp;
</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;

0 comments on commit 386d7e9

Please sign in to comment.