fourth commit

This commit is contained in:
belasriiimad 2024-02-05 11:37:17 +00:00
parent 0e79054b4e
commit afda3a7b0c
3 changed files with 18 additions and 18 deletions

View File

@ -12,8 +12,8 @@ export default function Home() {
const { token, isLoggedIn } = useSelector(state => state.user)
const [articles, setArticles] = useState([])
const [loading, setLoading] = useState(false)
const [articleByTag, setArticleByTag] = useState('')
const [message, setMessage] = useState('')
const [articleByTag, setArticleByTag] = useState('')
const [articleByFollowing, setArticleByFollowing] = useState(false)
const [meta, setMeta] = useState({
to: 0,
@ -34,7 +34,7 @@ export default function Home() {
setArticles(response.data.data)
setMeta(response.data.meta)
}else {
setMessage('No articles found.')
setMessage('No articles found')
}
setLoading(false)
} else if (articleByFollowing) {
@ -44,7 +44,7 @@ export default function Home() {
setArticles(response.data.data)
setMeta(response.data.meta)
}else {
setMessage('No articles found.')
setMessage('No articles found')
}
setLoading(false)
} else {
@ -104,14 +104,14 @@ export default function Home() {
message ?
<div className="col-md-8">
<div className="alert alert-info">
No articles found
{ message }
</div>
</div>
:
:
<ArticleList articles={articles}
fetchNextArticles={fetchNextArticles}
meta={meta}
/>
/>
}
{/* display all the tags */}
<Tags setArticleByTag={setArticleByTag}

View File

@ -1,7 +1,7 @@
import axios from 'axios'
import React, { useState } from 'react'
import { BASE_URL } from '../../helpers/config'
import { Link, useNavigate } from 'react-router-dom'
import { useNavigate } from 'react-router-dom'
export default function SearchBox() {
const [searchTerm, setSearTerm] = useState('')
@ -91,7 +91,7 @@ export default function SearchBox() {
{ article.title }
</span>
<button onClick={() => viewArticleDetails(article.slug)}
className='text-decoration-none btn btn-link text-primary'>
className=' btn bt-link text-decoration-none text-primary'>
View
</button>
</div>

View File

@ -24,12 +24,12 @@ export default function UserArticles() {
try {
const response = await axios.get(`${BASE_URL}/user/articles`,
getConfig(token))
if (response.data.data.length) {
setArticles(response.data.data)
}else {
setMessage('No articles found.')
}
setLoading(false)
if (response.data.data.length) {
setArticles(response.data.data)
}else {
setMessage('No articles found')
}
setLoading(false)
} catch (error) {
setLoading(false)
console.log(error)
@ -64,7 +64,7 @@ export default function UserArticles() {
<div className="alert alert-info">
{ message }
</div>
:
:
<table className='table table-responsive'>
<caption>List of published articles</caption>
<thead>