diff --git a/app/javascript/components/Board/BoardP.tsx b/app/javascript/components/Board/BoardP.tsx index 708fe837..ded16311 100644 --- a/app/javascript/components/Board/BoardP.tsx +++ b/app/javascript/components/Board/BoardP.tsx @@ -6,7 +6,6 @@ import PostStatusFilter from './PostStatusFilter'; import PostList from './PostList'; import IBoard from '../../interfaces/IBoard'; -import IPost from '../../interfaces/IPost'; import { PostsState } from '../../reducers/postsReducer'; import { PostStatusesState } from '../../reducers/postStatusesReducer'; @@ -37,7 +36,7 @@ class BoardP extends React.Component { this.props.requestPostStatuses(); } - componentDidUpdate(prevProps) { + componentDidUpdate(prevProps: Props) { const { searchQuery } = this.props.posts.filters; const prevSearchQuery = prevProps.posts.filters.searchQuery; @@ -98,7 +97,6 @@ class BoardP extends React.Component { { - constructor(props) { + constructor(props: Props) { super(props); this.state = { @@ -57,20 +56,20 @@ class NewPost extends React.Component { }); } - onTitleChange(title) { + onTitleChange(title: string) { this.setState({ title, error: '', }); } - onDescriptionChange(description) { + onDescriptionChange(description: string) { this.setState({ description, }); } - async submitForm(e) { + async submitForm(e: React.FormEvent) { e.preventDefault(); this.setState({ diff --git a/app/javascript/components/Board/PostList.tsx b/app/javascript/components/Board/PostList.tsx index 261a1bd5..4d862296 100644 --- a/app/javascript/components/Board/PostList.tsx +++ b/app/javascript/components/Board/PostList.tsx @@ -19,7 +19,6 @@ interface Props { error: string; handleLoadMore(): void; - page: number; hasMore: boolean; } @@ -29,7 +28,6 @@ const PostList = ({ areLoading, error, handleLoadMore, - page, hasMore }: Props) => (
diff --git a/app/javascript/components/Board/PostListItem.tsx b/app/javascript/components/Board/PostListItem.tsx index 6487e2a5..ab46a3b4 100644 --- a/app/javascript/components/Board/PostListItem.tsx +++ b/app/javascript/components/Board/PostListItem.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import CommentsNumber from '../shared/CommentsNumber'; import PostStatusLabel from '../shared/PostStatusLabel'; -import { TitleText, DescriptionText } from '../shared/CustomTexts'; +import { DescriptionText } from '../shared/CustomTexts'; import IPostStatus from '../../interfaces/IPostStatus'; diff --git a/app/javascript/components/Board/PostStatusListItem.tsx b/app/javascript/components/Board/PostStatusListItem.tsx index 7f918f6b..9cdc573b 100644 --- a/app/javascript/components/Board/PostStatusListItem.tsx +++ b/app/javascript/components/Board/PostStatusListItem.tsx @@ -24,7 +24,7 @@ const PostStatusListItem = ({ }>
- +
{ diff --git a/app/javascript/components/Board/SearchFilter.tsx b/app/javascript/components/Board/SearchFilter.tsx index d48a79e7..caae7079 100644 --- a/app/javascript/components/Board/SearchFilter.tsx +++ b/app/javascript/components/Board/SearchFilter.tsx @@ -12,6 +12,7 @@ const SearchFilter = ({ searchQuery, handleChange }: Props) => ( Search: handleChange(e.target.value)} id="searchPostInput" className="form-control" diff --git a/app/javascript/components/Board/index.tsx b/app/javascript/components/Board/index.tsx index e111c90a..ac8194bf 100644 --- a/app/javascript/components/Board/index.tsx +++ b/app/javascript/components/Board/index.tsx @@ -15,7 +15,7 @@ interface Props { class BoardRoot extends React.Component { store: any; - constructor(props) { + constructor(props: Props) { super(props); this.store = createStoreHelper(); diff --git a/app/javascript/components/Comments/Comment.tsx b/app/javascript/components/Comments/Comment.tsx index 4626e778..30cc1dd1 100644 --- a/app/javascript/components/Comments/Comment.tsx +++ b/app/javascript/components/Comments/Comment.tsx @@ -1,5 +1,4 @@ import * as React from 'react'; -import { FormEvent } from 'react'; import NewComment from './NewComment'; import Separator from '../shared/Separator'; @@ -12,14 +11,12 @@ import friendlyDate from '../../helpers/friendlyDate'; interface Props { id: number; body: string; - parentId: number; userFullName: string; updatedAt: string; - level: number; reply: CommentRepliesState; handleToggleCommentReply(): void; - handleCommentReplyBodyChange(e: FormEvent): void; + handleCommentReplyBodyChange(e: React.FormEvent): void; handleSubmitComment(body: string, parentId: number): void; isLoggedIn: boolean; @@ -29,11 +26,9 @@ interface Props { const Comment = ({ id, body, - parentId, userFullName, updatedAt, - level, reply, handleToggleCommentReply, handleCommentReplyBodyChange, diff --git a/app/javascript/components/Comments/CommentList.tsx b/app/javascript/components/Comments/CommentList.tsx index 2b085424..2551a8a2 100644 --- a/app/javascript/components/Comments/CommentList.tsx +++ b/app/javascript/components/Comments/CommentList.tsx @@ -1,5 +1,4 @@ import * as React from 'react'; -import { FormEvent } from 'react'; import Comment from './Comment'; @@ -39,11 +38,10 @@ const CommentList = ({ return (
reply.commentId === comment.id)} handleToggleCommentReply={() => toggleCommentReply(comment.id)} handleCommentReplyBodyChange={ - (e: FormEvent) => ( + (e: React.FormEvent) => ( setCommentReplyBody(comment.id, (e.target as HTMLTextAreaElement).value) ) } diff --git a/app/javascript/components/Comments/CommentsP.tsx b/app/javascript/components/Comments/CommentsP.tsx index 096d6909..77072770 100644 --- a/app/javascript/components/Comments/CommentsP.tsx +++ b/app/javascript/components/Comments/CommentsP.tsx @@ -1,10 +1,9 @@ import * as React from 'react'; -import { FormEvent } from 'react'; import NewComment from './NewComment'; import CommentList from './CommentList'; import Spinner from '../shared/Spinner'; -import { DangerText, UppercaseText } from '../shared/CustomTexts'; +import { DangerText } from '../shared/CustomTexts'; import IComment from '../../interfaces/IComment'; import { CommentRepliesState } from '../../reducers/commentRepliesReducer'; @@ -36,7 +35,7 @@ class CommentsP extends React.Component { this.props.requestComments(this.props.postId); } - _handleSubmitComment = (body, parentId) => { + _handleSubmitComment = (body: string, parentId: number) => { this.props.submitComment( this.props.postId, body, @@ -57,7 +56,6 @@ class CommentsP extends React.Component { toggleCommentReply, setCommentReplyBody, - submitComment, } = this.props; const postReply = replies.find(reply => reply.commentId === -1); @@ -69,7 +67,7 @@ class CommentsP extends React.Component { parentId={null} isSubmitting={postReply && postReply.isSubmitting} handleChange={ - (e: FormEvent) => ( + (e: React.FormEvent) => ( setCommentReplyBody(-1, (e.target as HTMLTextAreaElement).value) ) } diff --git a/app/javascript/components/Comments/NewComment.tsx b/app/javascript/components/Comments/NewComment.tsx index e50f3043..128324b8 100644 --- a/app/javascript/components/Comments/NewComment.tsx +++ b/app/javascript/components/Comments/NewComment.tsx @@ -1,5 +1,4 @@ import * as React from 'react'; -import { FormEvent } from 'react'; import Button from '../shared/Button'; import Spinner from '../shared/Spinner'; @@ -8,7 +7,7 @@ interface Props { body: string; parentId: number; isSubmitting: boolean; - handleChange(e: FormEvent): void; + handleChange(e: React.FormEvent): void; handleSubmit(body: string, parentId: number): void; isLoggedIn: boolean; diff --git a/app/javascript/components/Post/PostBoardSelect.tsx b/app/javascript/components/Post/PostBoardSelect.tsx index 7c3a88cc..f4c05009 100644 --- a/app/javascript/components/Post/PostBoardSelect.tsx +++ b/app/javascript/components/Post/PostBoardSelect.tsx @@ -1,5 +1,4 @@ import * as React from 'react'; -import { FormEvent } from 'react'; import IBoard from '../../interfaces/IBoard'; @@ -20,7 +19,7 @@ const PostBoardSelect = ({ ( + (e: React.FormEvent) => ( handleChange(parseInt((e.target as HTMLSelectElement).value)) )} id="selectPickerStatus" diff --git a/app/javascript/components/Post/index.tsx b/app/javascript/components/Post/index.tsx index 5dd20660..3c00c38d 100644 --- a/app/javascript/components/Post/index.tsx +++ b/app/javascript/components/Post/index.tsx @@ -20,7 +20,7 @@ interface Props { class PostRoot extends React.Component { store: any; - constructor(props) { + constructor(props: Props) { super(props); this.store = createStoreHelper(); diff --git a/app/javascript/components/shared/Button.tsx b/app/javascript/components/shared/Button.tsx index 43a74b74..4d0039ac 100644 --- a/app/javascript/components/shared/Button.tsx +++ b/app/javascript/components/shared/Button.tsx @@ -1,9 +1,8 @@ import * as React from 'react'; -import { FormEvent } from 'react'; interface Props { children: any; - onClick(e: FormEvent): void; + onClick(e: React.FormEvent): void; className?: string; outline?: boolean; } diff --git a/app/javascript/components/shared/PostStatusLabel.tsx b/app/javascript/components/shared/PostStatusLabel.tsx index 58bc801e..831e4947 100644 --- a/app/javascript/components/shared/PostStatusLabel.tsx +++ b/app/javascript/components/shared/PostStatusLabel.tsx @@ -1,12 +1,14 @@ import * as React from 'react'; -import IPostStatus from '../../interfaces/IPostStatus'; +interface Props { + name: string; + color: string; +} const PostStatusLabel = ({ - id, name, color, -}: IPostStatus) => ( +}: Props) => ( {name} ); diff --git a/app/javascript/containers/Post.tsx b/app/javascript/containers/Post.tsx index e6e18a5a..aefdf247 100644 --- a/app/javascript/containers/Post.tsx +++ b/app/javascript/containers/Post.tsx @@ -1,7 +1,6 @@ import { connect } from 'react-redux'; import { requestPost } from '../actions/requestPost'; -import { requestComments } from '../actions/requestComments'; import { changePostBoard } from '../actions/changePostBoard'; import { changePostStatus } from '../actions/changePostStatus'; diff --git a/app/javascript/reducers/commentRepliesReducer.ts b/app/javascript/reducers/commentRepliesReducer.ts index 31033942..e11e8108 100644 --- a/app/javascript/reducers/commentRepliesReducer.ts +++ b/app/javascript/reducers/commentRepliesReducer.ts @@ -3,7 +3,6 @@ import { } from '../actions/requestComment'; import { - HandleCommentRepliesType, TOGGLE_COMMENT_REPLY, SET_COMMENT_REPLY_BODY, } from '../actions/handleCommentReplies'; diff --git a/app/javascript/reducers/commentsReducer.ts b/app/javascript/reducers/commentsReducer.ts index bb363774..1df52aa0 100644 --- a/app/javascript/reducers/commentsReducer.ts +++ b/app/javascript/reducers/commentsReducer.ts @@ -1,5 +1,4 @@ import { - CommentsRequestActionTypes, COMMENTS_REQUEST_START, COMMENTS_REQUEST_SUCCESS, COMMENTS_REQUEST_FAILURE, @@ -8,7 +7,6 @@ import { import { commentRequestSuccess } from '../actions/requestComment'; import { - HandleCommentRepliesType, TOGGLE_COMMENT_REPLY, SET_COMMENT_REPLY_BODY, } from '../actions/handleCommentReplies'; @@ -23,6 +21,7 @@ import commentReducer from './commentReducer'; import commentRepliesReducer from './commentRepliesReducer'; import IComment from '../interfaces/IComment'; +import ICommentJSON from '../interfaces/json/IComment'; import { CommentRepliesState } from './commentRepliesReducer'; export interface CommentsState { @@ -54,11 +53,11 @@ const commentsReducer = ( return { ...state, items: action.comments.map( - comment => commentReducer(undefined, commentRequestSuccess(comment)) + (comment: ICommentJSON) => commentReducer(undefined, commentRequestSuccess(comment)) ), replies: [commentRepliesReducer(undefined, {type: 'COMMENT_REQUEST_SUCCESS', comment: { id: -1 } }), ...action.comments.map( - comment => commentRepliesReducer(undefined, commentRequestSuccess(comment)) + (comment: ICommentJSON) => commentRepliesReducer(undefined, commentRequestSuccess(comment)) )], areLoading: false, error: '',