diff --git a/src/components/AddComment.tsx b/src/components/AddComment.tsx index abde85ffaad6e9d19b108316edbf7fb986e42964..823d9a589a0a471cb24638f5bc9732f62f889dc2 100644 --- a/src/components/AddComment.tsx +++ b/src/components/AddComment.tsx @@ -34,7 +34,7 @@ const AddComment = ({ idPost }: commentProps) => { } }} className="border border-gray-400 dark:bg-darkblue p-2 rounded-md w-full" - placeholder={t('addcomment_view.add_comment')} + placeholder="Add a comment" ></input> <button onClick={() => { diff --git a/src/components/Post.tsx b/src/components/Post.tsx index b06339baf10a4f5731e00c9258a01897c8c736e7..030a11e8e9d9065ba9d12fb8aa3632cca5c40b3a 100644 --- a/src/components/Post.tsx +++ b/src/components/Post.tsx @@ -16,7 +16,7 @@ import { faLocationDot, faHeart, faCommentDots, faEllipsisVertical } from '@fort import useAppDispatch from '../hooks/useAppDispatch'; import { likepostAsync, unlikePostAsync, followUserFeedAsync, unfollowUserFeedAsync } from '../redux/feed/thunks'; import { followUserPostAction } from '../redux/post/actions'; -import { addLikePostAsync, deleteLikePostAsync, followUserPostAsync, unfollowUserPostAsync, deletePostAsync } from '../redux/post/thunks'; +import { followUserPostAsync, unfollowUserPostAsync, deletePostAsync } from '../redux/post/thunks'; diff --git a/src/redux/post/reducer.ts b/src/redux/post/reducer.ts index bcee9bab142ffa2c998a1c097c9b1e45cc955b08..7cd7b915c15e1d7a2504a3697b77167b03839084 100644 --- a/src/redux/post/reducer.ts +++ b/src/redux/post/reducer.ts @@ -12,7 +12,7 @@ const intialState: PostState = { data: undefined, }; -const postReducer: Reducer<PostState, PostAction | SetLikeFeedAction | SetUnlikeFeedAction | unfollowUserFeedAction | followUserFeedAction | commentPostAction> = (state = intialState, action) => { +const postReducer: Reducer<PostState, PostAction | SetLikeFeedAction | SetUnlikeFeedAction > = (state = intialState, action) => { switch (action.type) { case SET_POST: return { ...state, data: action.payload }; @@ -40,7 +40,7 @@ const postReducer: Reducer<PostState, PostAction | SetLikeFeedAction | SetUnlike return { ...state, data: { ...state.data, id: -1 } }; case COMMENT_POST: if (state.data) { - return { ...state, previewComments: state.data.previewComments.push(action.payload), }; + return { ...state, previewComments: state.data.previewComments }; } return state; default: diff --git a/src/redux/post/thunks.ts b/src/redux/post/thunks.ts index 153ef1a9b71363194e35fc9e52623a838ffb55db..837aaeff1844ffa92928a86dbaef4a0d84d4f479 100644 --- a/src/redux/post/thunks.ts +++ b/src/redux/post/thunks.ts @@ -3,7 +3,7 @@ import { data } from 'autoprefixer'; // AUTRES FICHIERS import { AppThunkAction } from '../types'; -import { failurePostAction, loadPostAction, setPost, sucessPostAction, followUserPostAction, unfollowUserPostAction, postCommentAction } from './actions'; +import { failurePostAction, loadPostAction, setPost, sucessPostAction, followUserPostAction, unfollowUserPostAction, postCommentAction, deletePostAction } from './actions'; // Calcul temps de publication d'un post / commentaire @@ -48,13 +48,14 @@ export const fetchPost = (postid: number): AppThunkAction<Promise<void>> => { // Ajouter un post -export const addPost = (resources: File[], location: string, caption: string, hasCommentsDisabled: boolean): AppThunkAction<Promise<void>> => { //ajouter les autres éléments (accessibilityCaption, hasCommentsDisabled) ? +export const addPost = (resources: File[], location: string, caption: string, accessibilityCaption: string, hasCommentsDisabled: boolean): AppThunkAction<Promise<void>> => { return async (dispatch, getState, api) => { try { //laisser le try/catch wrapper sinon bug const { data } = await api.posts.create({ resources: resources, location: location, caption: caption, + accessibilityCaption: accessibilityCaption, hasCommentsDisabled: hasCommentsDisabled, }); dispatch(setPost(data)); diff --git a/src/views/AddPostView.tsx b/src/views/AddPostView.tsx index c43d1cc1249f21d78dd962d000cf5d59d5d871c4..3cdb318749c914274a373087c687f8e1cc0de658 100644 --- a/src/views/AddPostView.tsx +++ b/src/views/AddPostView.tsx @@ -21,6 +21,7 @@ const AddPostView = () => { const [selectedImg, setSelectedImg] = useState<File[]>([]); const [location, setLocation] = useState(""); const [caption, setCaption] = useState(""); + const [accessibilityCaption, setAccessibilityCaption] = useState(""); const [hasCommentsDisabled, setComment] = useState(false); const [redirect, setRedirect] = useState(false); const post = usePost().items || { id: -1 }; // Initialisation de post avec un objet par défaut @@ -45,7 +46,7 @@ const AddPostView = () => { <p className="text-center font-bold text-2xl">{t('addpost_view.title')}</p> <form className="flex flex-col gap-4 mt-6" onSubmit={(event)=> { event.preventDefault(); - dispatch(addPost(selectedImg, location, caption, hasCommentsDisabled)); //ajouter les autres éléments (accessibilityCaption, hasCommentsDisabled) ? + dispatch(addPost(selectedImg, location, caption, accessibilityCaption, hasCommentsDisabled)); //ajouter les autres éléments (accessibilityCaption, hasCommentsDisabled) ? }}> {/* IMAGE */} <div className="flex flex-col gap-1"> @@ -60,13 +61,13 @@ const AddPostView = () => { {/* LOCATION */} <div className="flex flex-col gap-1"> <label htmlFor="location-input" className="font-bold">{t('addpost_view.place')} :</label> - <input className="h-10 p-2 rounded-sm border dark:text-darkblue" id="location-input" placeholder={t('addpost_view.place_placeholder')} value={location} onChange={(e)=> + <input className="h-10 p-2 rounded-sm border dark:text-darkblue" id="location-input" placeholder="Place" value={location} onChange={(e)=> setLocation(e.target.value)} /> </div> {/* DESCRIPTION */} <div className="flex flex-col gap-1"> <label htmlFor="caption-input" className="font-bold">{t('addpost_view.caption')} :</label> - <input className="h-10 p-2 rounded-sm border dark:text-darkblue" id="caption-input" placeholder={t('addpost_view.caption_placeholder')} value={caption} onChange={(e)=> + <input className="h-10 p-2 rounded-sm border dark:text-darkblue" id="caption-input" placeholder="Caption" value={caption} onChange={(e)=> setCaption(e.target.value)} /> </div> {/* POSSIBILITE DE COMMENTER */} diff --git a/src/views/FeedView.tsx b/src/views/FeedView.tsx index bf3c597420cbfab4ce2126afff3f604f730ce85b..027928e29fe86ec1caeda99c6d07b9296e798a94 100644 --- a/src/views/FeedView.tsx +++ b/src/views/FeedView.tsx @@ -88,6 +88,7 @@ return <> comments={post.commentsCount} comment_post={post.previewComments} inFeed={true} + comment_able={post.hasCommentsDisabled} ></Post> ); })} diff --git a/src/views/LoginView2.tsx b/src/views/LoginView2.tsx deleted file mode 100644 index fa3093f113e1a9fd28ba392fcf12df45c282b309..0000000000000000000000000000000000000000 --- a/src/views/LoginView2.tsx +++ /dev/null @@ -1,64 +0,0 @@ -import { useState } from 'react'; -import { Navigate, useNavigate } from 'react-router-dom'; -import useAppDispatch from '../hooks/useAppDispatch'; -import useAuthInterceptors from '../hooks/useAuthInterceptors'; -import { loginAsync } from '../redux/auth/thunks'; -import useIsAuth from '../hooks/useIsAuth'; - -const LoginView = () => { - const dispatch = useAppDispatch(); - const [email, setEmail] = useState(''); - const [password, setPassword] = useState(''); - const [message, setMessage] = useState(''); - const navigate = useNavigate(); - - const isAuth = useIsAuth(); - - if (isAuth) { - return <Navigate to="feed" /> - } - - const handleSubmit = (e) => { - e.preventDefault(); - dispatch(loginAsync(email, password)) - .then((userInfo) => { - // Store user session info in localStorage - // localStorage.setItem('userSession', JSON.stringify(userInfo)); -> il faut que dans le localstorage on mette les infos du user connecté - // Redirect to home page or other page - navigate('/home'); - }) - .catch((e) => setMessage(e.response.data.message)); - }; - - return ( - <div className="flex flex-col items-center justify-center h-screen"> - <h1 className="instalike_title text-[64px] leading-[76px]">Instalike</h1> - <p className="text-red-500">Faire afficher un message d'erreur ici si les id/mdp ne sont pas bon</p> - <form className="flex flex-col gap-4 w-[348px] mt-4" onSubmit={handleSubmit}> - <p className="text-lg">Welcom back <span className="font-bold">Chloé</span> !</p> - <input - id="email" - className="px-4 bg-gray-200 h-12 rounded-md" - type="email" - name="email" - placeholder="Adresse mail" - required - onChange={(e) => setEmail(e.target.value)} - /> - <input - id="password" - className="px-4 bg-gray-200 h-12 rounded-md" - type="password" - name="password" - placeholder="Mot de passe" - required - onChange={(e) => setPassword(e.target.value)} - /> - <p className="text-sm">Not Chloé ? <a className="font-bold text-blue-400" href="#">Change account</a></p> - <button type="submit" className="bg-blue-400 text-white font-bold h-10 rounded-md mt-2">Login</button> - </form> - </div> - ); -}; - -export default LoginView; diff --git a/src/views/Profile.tsx b/src/views/Profile.tsx index aa413b4056ccbbca61033e978964c391e8af0117..29c0fb170e46b31cd4e8580b033a48dce53bef74 100644 --- a/src/views/Profile.tsx +++ b/src/views/Profile.tsx @@ -13,12 +13,13 @@ import DiscoverPost from '../components/DiscoverPost'; // AUTRES FICHIERS import useAppDispatch from '../hooks/useAppDispatch'; import useFeedItems from '../hooks/useFeedItems'; -import { fetchProfileAsync, fetchProfileDataAsync } from '../redux/feed/thunks'; +import { fetchProfileAsync } from '../redux/feed/thunks'; // ICONS import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faCompass } from '@fortawesome/free-regular-svg-icons'; import { useEffect } from 'react'; +import { Instalike } from '@jmetterrothan/instalike'; const Profile = () => { @@ -32,10 +33,6 @@ const Profile = () => { const feedItems = useFeedItems(); - // console.log("Before calling fetchProfileDataAsync"); - //dispatch(fetchProfileDataAsync()); - // console.log("After calling fetchProfileDataAsync"); - return <>