|
@@ -1,11 +1,10 @@
|
|
import { connect } from "react-redux";
|
|
import { connect } from "react-redux";
|
|
import "react-responsive-carousel/lib/styles/carousel.min.css";
|
|
import "react-responsive-carousel/lib/styles/carousel.min.css";
|
|
import { Carousel } from "react-responsive-carousel";
|
|
import { Carousel } from "react-responsive-carousel";
|
|
-import { backendURL } from "../../actions";
|
|
|
|
-
|
|
|
|
|
|
+import { actionAddlike, backendURL } from "../../actions";
|
|
|
|
+import {IoHeartOutline, IoHeartSharp} from "react-icons/io5"
|
|
|
|
|
|
const ImagesInPost = ({image}) => {
|
|
const ImagesInPost = ({image}) => {
|
|
- console.log(image);
|
|
|
|
return (
|
|
return (
|
|
<div>
|
|
<div>
|
|
<img className="object-cover object-center w-full h-96 bg-slate-500" src={image.url ?`${backendURL}/${image?.url}` : ""}/>
|
|
<img className="object-cover object-center w-full h-96 bg-slate-500" src={image.url ?`${backendURL}/${image?.url}` : ""}/>
|
|
@@ -13,6 +12,14 @@ const ImagesInPost = ({image}) => {
|
|
)
|
|
)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+const LikeButton = ({onLike, props,children}) => {
|
|
|
|
+ console.log(props);
|
|
|
|
+ console.log(children);
|
|
|
|
+ return(
|
|
|
|
+ <button className="flex items-center justify-center" onClick={()=>onLike(props)}><IoHeartOutline />{children}</button>
|
|
|
|
+ )
|
|
|
|
+}
|
|
|
|
+{/* <button className="flex items-center justify-center"><IoHeartOutline />{findPost?.likes?.length ? findPost?.likes?.length : "0"}</button> */}
|
|
|
|
|
|
const PostItem = ({findPost}) =>{
|
|
const PostItem = ({findPost}) =>{
|
|
return(
|
|
return(
|
|
@@ -33,7 +40,7 @@ const PostItem = ({findPost}) =>{
|
|
<div className="p-3">
|
|
<div className="p-3">
|
|
<div className="flex items-center justify-between">
|
|
<div className="flex items-center justify-between">
|
|
<div className="flex items-center space-x-3">
|
|
<div className="flex items-center space-x-3">
|
|
- <button className="flex items-center justify-center">Like</button>
|
|
|
|
|
|
+ <CLikeButton props={findPost?._id} children={findPost?.likes?.length ? findPost?.likes?.length : "0"}/>
|
|
<button className="flex items-center justify-center">Comment</button>
|
|
<button className="flex items-center justify-center">Comment</button>
|
|
<button className="flex items-center justify-center">Direct</button>
|
|
<button className="flex items-center justify-center">Direct</button>
|
|
</div>
|
|
</div>
|
|
@@ -52,6 +59,8 @@ const PostItem = ({findPost}) =>{
|
|
)
|
|
)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+const CLikeButton = connect(null,{onLike: actionAddlike})(LikeButton)
|
|
|
|
+
|
|
const CPostItem = connect(state=>({findPost: state.promise?.findPost?.payload || {}}))(PostItem)
|
|
const CPostItem = connect(state=>({findPost: state.promise?.findPost?.payload || {}}))(PostItem)
|
|
|
|
|
|
|
|
|