diff --git a/src/components/Post.tsx b/src/components/Post.tsx index 030a11e8e9d9065ba9d12fb8aa3632cca5c40b3a..0637417ff24f1375a2795b431a49445350b19710 100644 --- a/src/components/Post.tsx +++ b/src/components/Post.tsx @@ -31,7 +31,6 @@ type PostProps = { username: string; location: string | null; time_post: string | null; - img: Media; caption?: string; isLiked: boolean; likes: number; @@ -43,7 +42,7 @@ type PostProps = { -const Post = ({ post, postid, username, location, time_post, img, caption, isLiked, likes, comments, comment_post, inFeed, comment_able }: PostProps) => { +const Post = ({ post, postid, username, location, time_post, caption, isLiked, likes, comments, comment_post, inFeed, comment_able }: PostProps) => { const { t,i18n } = useTranslation(); const dispatch = useAppDispatch(); const [dropdownOpen, setDropdownOpen] = useState(false); @@ -58,6 +57,7 @@ const Post = ({ post, postid, username, location, time_post, img, caption, isLik return document.execCommand('copy', true, text); } } + console.log(post) return <> {/* A POST */} @@ -153,7 +153,9 @@ const Post = ({ post, postid, username, location, time_post, img, caption, isLik </div> {/* IMAGE POST */} <div className="flex justify-center items-center"> - <img src={img.src} alt="" /> + {post.resources[0] && + <img src={post.resources[0].src} alt="" /> + } </div> {/* BIO POST */} <div className="p-4"> diff --git a/src/redux/post/reducer.ts b/src/redux/post/reducer.ts index 7cd7b915c15e1d7a2504a3697b77167b03839084..3aef4c319d68654840ce418671d755fdfa70894a 100644 --- a/src/redux/post/reducer.ts +++ b/src/redux/post/reducer.ts @@ -2,17 +2,49 @@ import { Instalike } from '@jmetterrothan/instalike'; import { Reducer } from 'redux'; import { PostAction, SET_POST, DELETE_POST, COMMENT_POST } from './actions'; -import { SetLikeFeedAction, SetUnlikeFeedAction, LIKE_POST_FEED, UNLIKE_POST_FEED, UNFOLLOW_USER_FEED, FOLLOW_USER_FEED } from '../feed/actions' +import { SetLikeFeedAction, SetUnlikeFeedAction, LIKE_POST_FEED, UNLIKE_POST_FEED, UNFOLLOW_USER_FEED, FOLLOW_USER_FEED, unfollowUserFeedAction, followUserFeedAction } from '../feed/actions' type PostState = { - data?: Instalike.Post; + data: Instalike.Post; }; const intialState: PostState = { - data: undefined, + data: { + id: -1, + caption: '', + accessibilityCaption: '', + location: '', + resources: [], + hasCommentsDisabled: false, + likesCount: 0, + previewLikes: [], + commentsCount: 0, + previewComments: [], + viewerHasLiked: false, + resourceType: 'Post', + createdAt: '', + owner: { + resourceType: 'User', + userName: '', + firstName: '', + lastName: '', + id: -1, + createdAt: '', + fullName: '', + avatar: '', + email: '', + biography: '', + followersCount: -1, + followingCount: -1, + postsCount: -1, + isFollowedByViewer: false, + isViewer: false, + updatedAt: '', + }, + }, }; -const postReducer: Reducer<PostState, PostAction | SetLikeFeedAction | SetUnlikeFeedAction > = (state = intialState, action) => { +const postReducer: Reducer<PostState, PostAction | SetLikeFeedAction | SetUnlikeFeedAction | unfollowUserFeedAction | followUserFeedAction > = (state = intialState, action) => { switch (action.type) { case SET_POST: return { ...state, data: action.payload };