diff --git a/src/App.tsx b/src/App.tsx index 701f6684b..10ac93ace 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -27,7 +27,7 @@ export const App = () => { const [comments, setComments] = useState([]); const [loadingComments, setLoadingComments] = useState(false); const [errorLoadComments, setErrorLoadComments] = useState(false); - const [writeCommen, setWriteCommen] = useState(false); + const [writeComment, setWriteComment] = useState(false); useEffect(() => { getUsers().then(setUsers); @@ -39,9 +39,6 @@ export const App = () => { .then(setPosts) .catch(() => { setErrorLoadPosts(true); - setInterval(() => { - setErrorLoadPosts(false); - }, 3000); }) .finally(() => setLoadingPosts(false)); } @@ -52,9 +49,6 @@ export const App = () => { .then(setComments) .catch(() => { setErrorLoadComments(true); - setInterval(() => { - setErrorLoadComments(false); - }, 3000); }) .finally(() => setLoadingComments(false)); } @@ -78,7 +72,7 @@ export const App = () => { setUserSelected={setUserSelected} getPostUser={getPostsUser} setOpenPostDetails={setOpenPostDetails} - setWriteCommen={setWriteCommen} + setWriteComment={setWriteComment} setPosts={setPosts} setPost={setPost} /> @@ -113,7 +107,7 @@ export const App = () => { openPostDetails={openPostDetails} setOpenPostDetails={setOpenPostDetails} getCommentsPost={getCommentsPost} - setWriteCommen={setWriteCommen} + setWriteComment={setWriteComment} /> )} @@ -138,8 +132,8 @@ export const App = () => { setComments={setComments} loadingComments={loadingComments} errorLoadComments={errorLoadComments} - writeCommen={writeCommen} - setWriteCommen={setWriteCommen} + writeComment={writeComment} + setWriteComment={setWriteComment} /> )} diff --git a/src/components/PostDetails.tsx b/src/components/PostDetails.tsx index 8efe0d8d2..d176806cd 100644 --- a/src/components/PostDetails.tsx +++ b/src/components/PostDetails.tsx @@ -11,8 +11,8 @@ type Props = { setComments: (comments: Comment[]) => void; loadingComments: boolean; errorLoadComments: boolean; - writeCommen: boolean; - setWriteCommen: (writeCommen: boolean) => void; + writeComment: boolean; + setWriteComment: (writeCommen: boolean) => void; }; export const PostDetails: React.FC = ({ @@ -21,10 +21,10 @@ export const PostDetails: React.FC = ({ setComments, loadingComments, errorLoadComments, - writeCommen, - setWriteCommen, + writeComment, + setWriteComment, }) => { - function removeDelete(comment: Comment) { + function removeComment(comment: Comment) { setComments([...comments.filter(commentary => commentary !== comment)]); deleteComment(comment.id).catch(() => setComments([...comments])); } @@ -79,7 +79,7 @@ export const PostDetails: React.FC = ({ type="button" className="delete is-small" aria-label="delete" - onClick={() => removeDelete(comment)} + onClick={() => removeComment(comment)} /> @@ -90,19 +90,19 @@ export const PostDetails: React.FC = ({ ); })} - {!writeCommen && !errorLoadComments && !loadingComments && ( + {!writeComment && !errorLoadComments && !loadingComments && ( )} - {writeCommen && ( + {writeComment && ( void; getCommentsPost: (post: Post) => void; - setWriteCommen: (writeCommen: boolean) => void; + setWriteComment: (writeComment: boolean) => void; }; export const PostsList: React.FC = ({ @@ -15,7 +15,7 @@ export const PostsList: React.FC = ({ openPostDetails, setOpenPostDetails, getCommentsPost, - setWriteCommen, + setWriteComment, }) => (

Posts:

@@ -48,7 +48,7 @@ export const PostsList: React.FC = ({ className="button is-link" onClick={() => { setOpenPostDetails(0); - setWriteCommen(false); + setWriteComment(false); }} > Close @@ -62,7 +62,7 @@ export const PostsList: React.FC = ({ setOpenPostDetails(id); getCommentsPost(post); setPost(post); - setWriteCommen(false); + setWriteComment(false); }} > Open diff --git a/src/components/UserSelector.tsx b/src/components/UserSelector.tsx index f918017b2..7c7bb214e 100644 --- a/src/components/UserSelector.tsx +++ b/src/components/UserSelector.tsx @@ -1,6 +1,7 @@ import React, { useState } from 'react'; import { User } from '../types/User'; import classNames from 'classnames'; +import { Post } from '../types/Post'; type Props = { users: User[]; @@ -8,9 +9,9 @@ type Props = { setUserSelected: (userSelected: User) => void; getPostUser: (user: User) => void; setOpenPostDetails: (openPostDetails: number) => void; - setWriteCommen: (writeCommen: boolean) => void; - setPosts: ([]) => void; - setPost: (post: null) => void; + setWriteComment: (writeComment: boolean) => void; + setPosts: (posts: Post[]) => void; + setPost: (post: Post | null) => void; }; export const UserSelector: React.FC = ({ @@ -19,7 +20,7 @@ export const UserSelector: React.FC = ({ setUserSelected, getPostUser, setOpenPostDetails, - setWriteCommen, + setWriteComment, setPosts, setPost, }) => { @@ -65,7 +66,7 @@ export const UserSelector: React.FC = ({ setClickedDropdown(false); getPostUser(user); setOpenPostDetails(0); - setWriteCommen(false); + setWriteComment(false); setPosts([]); setPost(null); }}