Skip to content

Commit

Permalink
fix read more button redirection
Browse files Browse the repository at this point in the history
  • Loading branch information
mamadfar committed Mar 15, 2023
1 parent c93f4fd commit 41c8f67
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
Binary file added api/tmp/uploads/1678883222100js.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added api/tmp/uploads/1678883255710js.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions client/src/components/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {FC} from 'react';
import "./Button.scss";

const Button:FC<{title: string}> = ({title}) => {
const Button:FC<{title: string, handler?: () => void}> = ({title, handler}) => {
return (
<button className="button">{title}</button>
<button className="button" onClick={handler}>{title}</button>
);
}

Expand Down
2 changes: 2 additions & 0 deletions client/src/pages/Home.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

.post {
display: flex;
align-items: center;
gap: 100px;
&:nth-child(2n+1) {
flex-direction: row-reverse;
Expand All @@ -17,6 +18,7 @@
&__img {
flex: 2;
position: relative;
height: 100%;
&::after {
content: "";
width: 100%;
Expand Down
11 changes: 4 additions & 7 deletions client/src/pages/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import "./Home.scss";
import {Link, useLocation} from "react-router-dom";
import {Link, useLocation, useNavigate} from "react-router-dom";
import {Button} from "../components";
import {useEffect, useState} from "react";
import {IPost} from "../model/post.model";
Expand All @@ -9,7 +9,8 @@ import parse from "html-react-parser";
const Home = () => {
const [posts, setPosts] = useState<IPost[]>([]);

const {search} = useLocation()
const {search} = useLocation();
const navigation = useNavigate();

const getPosts = async () => {
try {
Expand All @@ -26,10 +27,6 @@ const Home = () => {
getPosts();
}, [search])

const getText = (html: string) => {

}

return (
<div className="home">
<div className="posts">
Expand All @@ -43,7 +40,7 @@ const Home = () => {
<h1>{post.title}</h1>
</Link>
<p>{parse(post.desc)}</p>
<Button title="Read More"/>
<Button title="Read More" handler={() => navigation(`/post/${post.id}`)}/>
</div>
</div>
))}
Expand Down

0 comments on commit 41c8f67

Please sign in to comment.