Skip to content

Commit

Permalink
Merge branch 'siyo' into deploy-server
Browse files Browse the repository at this point in the history
  • Loading branch information
needl3 committed May 21, 2023
2 parents 5ca5f4e + 99b7836 commit 23248f0
Show file tree
Hide file tree
Showing 18 changed files with 210 additions and 105 deletions.
2 changes: 1 addition & 1 deletion client/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ function App() {
<Route path="" element={<Landing />} />
<Route
path="/news/:year/:month/:slug"
element={<SingleNews />}
element={<SingleNews session={session} />}
/>
<Route path="/category/:cat" element={<Category />} />
<Route path="/author/:author" element={<Author />} />
Expand Down
18 changes: 12 additions & 6 deletions client/src/components/Comments.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
} from 'react-icons/ai'
import { BiComment, BiCommentAdd } from 'react-icons/bi'
import { getRelativeTime } from '../utils/relativeDuration'
import { setAlert } from '../redux/actions/misc'

const formatter = new Intl.NumberFormat('en-US', { notation: 'compact' })

Expand Down Expand Up @@ -235,7 +236,7 @@ const CommentBox = ({
)
}

function Comments({ articleId }) {
function Comments({ articleId, session }) {
const comments = useSelector(state => state.comments.comments)
const dispatch = useDispatch()
const [commenting, setCommenting] = useState({
Expand All @@ -259,8 +260,6 @@ function Comments({ articleId }) {
)
}, [articleId])

const session = useSession()

return (
<div>
<div className="my-2">
Expand Down Expand Up @@ -292,9 +291,16 @@ function Comments({ articleId }) {
) : (
<div
className="cursor-pointer"
onClick={() =>
setCommenting({ bool: true, commentStr: '' })
}
onClick={() => {
if (session.status == 'unauthenticated')
dispatch(
setAlert(
'You must login to comment!',
'danger'
)
)
else setCommenting({ bool: true, commentStr: '' })
}}
>
<BiCommentAdd className="inline mr-2 " />
<span>Add Comment</span>
Expand Down
12 changes: 4 additions & 8 deletions client/src/components/LeftSideBar/Critics/TopCritics.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { useState, useEffect } from 'react'
import { CgScrollV } from 'react-icons/cg'
import axios from 'axios'

import CriticCard from './CriticCard'
import { Link } from 'react-router-dom'

export default function TopCritics() {
const [critics, setCritics] = useState([])

Expand All @@ -28,13 +27,10 @@ export default function TopCritics() {

return (
<div className="mt-2 mb-4 w-full">
<h2 className="font-bold text-2xl leading-loose">
शीर्ष आलोचकहरू
<Link to="/explore-critics" className="text-sm ml-3">
{'अझ हेर्नुहोस् >>'}
</Link>
<h2 className="font-bold text-2xl leading-loose flex place-items-center gap-2">
शीर्ष आलोचकहरू <CgScrollV className="text-2xl" />
</h2>
<div>
<div className="overflow-y-scroll h-[80vh]">
{/* list of critics */}
{critics &&
critics.map(critic => {
Expand Down
6 changes: 2 additions & 4 deletions client/src/components/common/ArticlePreviewSm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export default function ArticlePreviewSm({
articleUrl,
}) {
return (
<div className="flex p-4 min-w-[35%] max-w-fit bg-white rounded-lg shadow-sm hover:shadow-xl border-b-2 duration-200 h-28 items-center justify-between my-2">
<div className="flex gap-2">
<div className="flex p-1 min-w-[35%] max-w-fit bg-white rounded-lg shadow-sm hover:shadow-xl border-b-2 duration-200 h-28 items-center justify-between my-2">
<div className="flex gap-1 place-items-center">
<Link to={articleUrl} className="w-1/3">
<img
src={imgUrl}
Expand All @@ -21,8 +21,6 @@ export default function ArticlePreviewSm({
{/* <h3 className="lg:text-md text-sm font-secondary font-medium hover:text-rose-600 duration-300"> */}
<Link to={articleUrl}>{title}</Link>
</h3>
{/* <div className="hidden lg:block text-xs">{summary}</div> */}
{/* </div> */}
</div>
</div>
)
Expand Down
14 changes: 12 additions & 2 deletions client/src/components/stats/Filters.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ const StatFilters = ({ type }) => {
type="date"
value={filters.dateFrom}
onChange={e =>
dispatch(statActions.setFromDate(e.target.value))
dispatch(
statActions.setFromDate({
value: e.target.value,
type,
})
)
}
/>
</div>
Expand All @@ -28,7 +33,12 @@ const StatFilters = ({ type }) => {
type="date"
value={filters.dateTo}
onChange={e =>
dispatch(statActions.setToDate(e.target.value))
dispatch(
statActions.setToDate({
value: e.target.value,
type,
})
)
}
/>
</div>
Expand Down
13 changes: 6 additions & 7 deletions client/src/pages/Category/Category.jsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
import React from 'react'
import { useSelector } from 'react-redux'
import { RectYAd } from '../../components/common'
import { RectXAd, RectYAd } from '../../components/common'
import RecentNews from '../Home/RecentNews'
import Content from './Content'

export default function Category() {
const adsY = useSelector(state => state.ads.rectY)
const adsX = useSelector(state => state.ads.rectX)
return (
<div className="flex justify-between">
<div className="flex flex-col justify-between">
{/* left-side that contains news */}
<div className=" w-2/3">
<div className="flex gap-4 w-min-2/3">
<Content />
<RectYAd ad={adsY ? (adsY[1] ? adsY[1] : false) : false} />
</div>
{/* right side */}
<div className="hidden w-1/3 sm:flex flex-col items-center px-4">
{/* ads go here */}
<RectYAd
ad={adsY ? (adsY[1] ? adsY[1] : false) : false}
type={'y'}
/>
</div>
<RectXAd ad={adsX ? (adsX[1] ? adsX[1] : false) : false} />
</div>
)
}
5 changes: 4 additions & 1 deletion client/src/pages/Category/Content.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ export default function Content() {
dispatch(
listNewsCat({
page: page,
cat: cat == 'hot' ? 'hot' : cat.toUpperCase(),
cat:
cat == 'hot' || cat == 'preference'
? cat
: cat.toUpperCase(),
})
)
}, [page, cat])
Expand Down
20 changes: 11 additions & 9 deletions client/src/pages/Dashboard/AdsMan.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export default function AdsMan() {
<h2>Add new ad</h2>
</div>
{show && (
<Popup title={show} setShow={setShow}>
<Popup title={show} setShow={setShow} width={'w-2/3'}>
<FormText
type="text"
name="name"
Expand All @@ -138,19 +138,21 @@ export default function AdsMan() {
labelText="Vertical Image (50x150px)"
handleChange={handleChange}
/>
</div>
<div className="flex">
<FormText
type="file"
name="imageSq"
labelText="Square Image (100x100px)"
handleChange={handleChange}
/>
<FormText
type="file"
name="audio"
labelText="Audio Ad (2MB, 5s)"
handleChange={handleChange}
/>
</div>
<FormText
type="file"
name="audio"
labelText="Audio Ad (2MB, 5s)"
handleChange={handleChange}
/>
<FormText
type="text"
name="redirectUrl"
Expand All @@ -165,7 +167,7 @@ export default function AdsMan() {
labelText="Category"
handleChange={handleChange}
/>
<div className="flex gap-4">
<div className="flex gap-4 w-fit">
<FormText
type="number"
name="priority"
Expand All @@ -185,7 +187,7 @@ export default function AdsMan() {
name="popup"
labelText="Mark as Popup"
handleChange={handleChange}
className="flex whitespace-nowrap place-items-center place-content-center gap-x-2 ml-8 text-xl"
className="flex flex-col whitespace-nowrap place-content-center text-xl"
checked={prop.popup}
/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/Dashboard/EditNews.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const EditNews = ({ isEdit }) => {
}
return (
<div className="ml-4 flex gap-8">
<div className="">
<div className="max-w-3xl">
<FormText
type="text"
name="title"
Expand Down
7 changes: 6 additions & 1 deletion client/src/pages/Dashboard/ReaderArticles.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from 'axios'
import React, { useEffect, useState } from 'react'
import { BsCalendar2Check, BsTrashFill } from 'react-icons/bs'
import { BsCalendar2Check, BsPencilSquare, BsTrashFill } from 'react-icons/bs'
import { useDispatch } from 'react-redux'
import { Link } from 'react-router-dom'
import { setAlert } from '../../redux/actions/misc'
Expand Down Expand Up @@ -131,6 +131,11 @@ export default function ReaderArticles() {
}}
className="cursor-pointer hover:fill-green-500 text-2xl"
/>
<Link
to={`../editNews/${article.year}/${article.month}/${article.slug}`}
>
<BsPencilSquare className="cursor-pointer hover:fill-purple-500 text-2xl" />
</Link>
<BsTrashFill
onClick={() => {
disapprove(article._id)
Expand Down
6 changes: 3 additions & 3 deletions client/src/pages/Home/SingleNews.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import Comments from '../../components/Comments'
import { delSingleNews, subscribeAuthor } from '../../redux/reducers/news'
import { setAlert } from '../../redux/actions/misc'

const SingleNews = () => {
const SingleNews = ({ session }) => {
const params = useParams()
const news = useSelector(state => state.news.singleNews)
const similar = useSelector(
Expand Down Expand Up @@ -180,7 +180,7 @@ const SingleNews = () => {
news?.author?.subscribed
? 'text-gray-600'
: 'text-rose-700'
} text-2xl my-auto cursor-pointer`}
} text-3xl my-auto cursor-pointer hover:text-green-700 hover:animate-bounce`}
title={
news?.author?.subscribed
? 'Unsubscribe'
Expand Down Expand Up @@ -248,7 +248,7 @@ const SingleNews = () => {
category={news?.category[0]}
data={similar}
/>
<Comments articleId={news?._id} />
<Comments articleId={news?._id} session={session} />
</div>
{/* right column */}
{!focus && (
Expand Down
Loading

0 comments on commit 23248f0

Please sign in to comment.