@@ -7,15 +7,17 @@ import {
7
7
setCurrentPost ,
8
8
} from "../../../actions/getPostAction" ;
9
9
import { showNav } from "../../../actions/navAction" ;
10
- import PostHolder from "./Post-Placeholder/PostHolder" ;
11
10
import { ParsedData } from "draftjs-raw-parser" ;
12
11
import { getThatProfileE } from "../../../actions/profileAction" ;
13
12
import { reallyGetAllPosts } from "../../../actions/getPostAction" ;
14
13
import { postComment } from "../../../actions/commentAction" ;
15
14
import Comment from "../../comment/Comment" ;
15
+ import * as S from "@chakra-ui/react" ;
16
+ import styled from "styled-components" ;
17
+ import { useToast } from "@chakra-ui/react" ;
16
18
17
19
const Post = ( {
18
- post : { currentPost, openedPost, loadingPost , likedStatus, likedPost } ,
20
+ post : { currentPost, openedPost, likedStatus, likedPost } ,
19
21
getPost,
20
22
likePost,
21
23
getLikedPosts,
@@ -25,9 +27,11 @@ const Post = ({
25
27
getThatProfileE,
26
28
reallyGetAllPosts,
27
29
setCurrentPost,
30
+ comment,
28
31
} ) => {
29
32
const [ lik , setLik ] = useState ( [ ] ) ;
30
33
const [ post , setPost ] = useState ( { } ) ;
34
+ const toast = useToast ( ) ;
31
35
32
36
useEffect ( ( ) => {
33
37
showNav ( ) ;
@@ -69,6 +73,19 @@ const Post = ({
69
73
// eslint-disable-next-line
70
74
} , [ likedStatus , post . _id , likedPost . length ] ) ;
71
75
76
+ useEffect ( ( ) => {
77
+ if ( comment . commentToast ) {
78
+ toast ( {
79
+ position : "bottom-left" ,
80
+ title : "Comment Posted" ,
81
+ description : "Your comment has been posted" ,
82
+ status : "success" ,
83
+ duration : 5000 ,
84
+ isClosable : true ,
85
+ } ) ;
86
+ }
87
+ } , [ comment . commentToast ] ) ;
88
+
72
89
/*
73
90
* This onClick Function, request the backend to
74
91
* register the like by user and save it to DB
@@ -97,8 +114,6 @@ const Post = ({
97
114
) ;
98
115
} ;
99
116
100
- const loadingStyles = loadingPost ? { display : "none" } : { } ;
101
-
102
117
const getThatP = ( ) => {
103
118
getThatProfileE ( openedPost . user ) ;
104
119
reallyGetAllPosts ( openedPost . user ) ;
@@ -107,39 +122,79 @@ const Post = ({
107
122
108
123
return (
109
124
< React . Fragment >
110
- { loadingPost && < PostHolder /> }
111
- < div className = "post-container-one" style = { loadingStyles } >
112
- < h1 className = "post-heading" > { post . heading } </ h1 >
113
- < div className = "user-p d-flex align-items-center" >
125
+ < S . Flex flexDir = "column" px = "400px" >
126
+ < S . Heading fontSize = "80" color = "gray.900" >
127
+ { post . heading }
128
+ </ S . Heading >
129
+ < S . Flex flexDir = "column" >
114
130
{ openedPost . user ? (
115
- < span onClick = { getThatP } > { post . name } </ span >
131
+ < S . Box
132
+ onClick = { getThatP }
133
+ fontSize = "23px"
134
+ color = "gray.700"
135
+ mb = "10px"
136
+ >
137
+ { post . name }
138
+ </ S . Box >
116
139
) : (
117
140
< span > No id</ span >
118
141
) }
119
- < div className = "dot-i" > </ div >
120
- < span > { "7min" } </ span >
121
- < i
122
- onClick = { likeThisPost }
123
- className = { `fa${ likedBtn ( ) ? "s" : "r" } fa-heart` }
124
- style = { likedBtn ( ) ? { color : "rgb(255, 0, 106)" } : { } }
125
- > </ i >
126
- </ div >
127
- < div className = "img-post-container" >
128
- < img src = { post !== undefined ? `${ post . image } ` : null } alt = "post" />
129
- </ div >
130
- < div className = "nn-new" >
142
+ < S . Flex alignItems = "center" mb = "10px" >
143
+ < S . Text fontSize = "18" > { "7min" } </ S . Text >
144
+ < span
145
+ style = { {
146
+ width : "5px" ,
147
+ height : "5px" ,
148
+ borderRadius : "100%" ,
149
+ backgroundColor : "#454545" ,
150
+ margin : "0 10px 0 10px" ,
151
+ } }
152
+ > </ span >
153
+ < i
154
+ onClick = { likeThisPost }
155
+ className = { `fa${ likedBtn ( ) ? "s" : "r" } fa-heart` }
156
+ style = {
157
+ likedBtn ( )
158
+ ? { color : "rgb(255, 0, 106)" , fontSize : "25px" }
159
+ : { fontSize : "25px" }
160
+ }
161
+ > </ i >
162
+ </ S . Flex >
163
+ </ S . Flex >
164
+ < S . Flex >
165
+ < S . Image
166
+ src = { post && `${ post . image } ` }
167
+ fallbackSrc = "https://i.ibb.co/RBT25fY/default-fallback-image.png"
168
+ alt = "post"
169
+ style = { { width : "100%" , height : "600px" } }
170
+ />
171
+ </ S . Flex >
172
+ < S . Flex mt = "30px" >
131
173
{ post . content && (
132
- < ParsedData draftJSRawData = { post . content . toString ( ) } />
174
+ < TurnIn >
175
+ < ParsedData draftJSRawData = { post . content . toString ( ) } />
176
+ </ TurnIn >
133
177
) }
134
- </ div >
135
- < div class = "post-comment-seperator" > </ div >
136
- < div className = "comment-tag" > Comments</ div >
178
+ </ S . Flex >
179
+ < S . Divider my = "60px" />
180
+ < S . Box fontSize = "24px" fontWeight = "600" mb = "15px" >
181
+ Comments
182
+ </ S . Box >
137
183
< Comment auth = { auth } post_id = { currentPost } />
138
- </ div >
184
+ < S . Box h = "100px" > </ S . Box >
185
+ </ S . Flex >
139
186
</ React . Fragment >
140
187
) ;
141
188
} ;
142
189
190
+ const TurnIn = styled . div `
191
+ div {
192
+ span {
193
+ font-size: 25px;
194
+ }
195
+ }
196
+ ` ;
197
+
143
198
const mapStateToProps = ( state ) => {
144
199
return {
145
200
post : state . post ,
0 commit comments