Remove unused imports and add some types

This commit is contained in:
riggraz
2019-09-26 11:00:32 +02:00
parent e38027f9ae
commit 322c8e51cf
19 changed files with 27 additions and 45 deletions

View File

@@ -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<Props> {
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<Props> {
<PostList
posts={posts.items}
postStatuses={postStatuses.items}
page={posts.page}
hasMore={posts.haveMore}
areLoading={posts.areLoading}
error={posts.error}

View File

@@ -3,7 +3,6 @@ import * as React from 'react';
import NewPostForm from './NewPostForm';
import Spinner from '../shared/Spinner';
import {
TitleText,
MutedText,
DangerText,
SuccessText,
@@ -29,7 +28,7 @@ interface State {
}
class NewPost extends React.Component<Props, State> {
constructor(props) {
constructor(props: Props) {
super(props);
this.state = {
@@ -57,20 +56,20 @@ class NewPost extends React.Component<Props, State> {
});
}
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({

View File

@@ -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) => (
<div className="postList">

View File

@@ -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';

View File

@@ -24,7 +24,7 @@ const PostStatusListItem = ({
}>
<a onClick={handleClick} className="postStatusListItemLink">
<div className="postStatusListItem">
<PostStatusLabel id={undefined} name={name} color={color} />
<PostStatusLabel name={name} color={color} />
</div>
</a>
{

View File

@@ -12,6 +12,7 @@ const SearchFilter = ({ searchQuery, handleChange }: Props) => (
<TitleText>Search:</TitleText>
<input
type="search"
value={searchQuery}
onChange={e => handleChange(e.target.value)}
id="searchPostInput"
className="form-control"

View File

@@ -15,7 +15,7 @@ interface Props {
class BoardRoot extends React.Component<Props> {
store: any;
constructor(props) {
constructor(props: Props) {
super(props);
this.store = createStoreHelper();

View File

@@ -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,

View File

@@ -1,5 +1,4 @@
import * as React from 'react';
import { FormEvent } from 'react';
import Comment from './Comment';
@@ -39,11 +38,10 @@ const CommentList = ({
return (
<div className="commentList" key={i}>
<Comment
level={level}
reply={replies.find(reply => reply.commentId === comment.id)}
handleToggleCommentReply={() => toggleCommentReply(comment.id)}
handleCommentReplyBodyChange={
(e: FormEvent) => (
(e: React.FormEvent) => (
setCommentReplyBody(comment.id, (e.target as HTMLTextAreaElement).value)
)
}

View File

@@ -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<Props> {
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<Props> {
toggleCommentReply,
setCommentReplyBody,
submitComment,
} = this.props;
const postReply = replies.find(reply => reply.commentId === -1);
@@ -69,7 +67,7 @@ class CommentsP extends React.Component<Props> {
parentId={null}
isSubmitting={postReply && postReply.isSubmitting}
handleChange={
(e: FormEvent) => (
(e: React.FormEvent) => (
setCommentReplyBody(-1, (e.target as HTMLTextAreaElement).value)
)
}

View File

@@ -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;

View File

@@ -1,5 +1,4 @@
import * as React from 'react';
import { FormEvent } from 'react';
import IBoard from '../../interfaces/IBoard';
@@ -20,7 +19,7 @@ const PostBoardSelect = ({
<select
value={selectedBoardId || 'Loading...'}
onChange={
(e: FormEvent) => (
(e: React.FormEvent) => (
handleChange(parseInt((e.target as HTMLSelectElement).value))
)}
id="selectPickerBoard"

View File

@@ -1,5 +1,4 @@
import * as React from 'react';
import { FormEvent } from 'react';
import IPostStatus from '../../interfaces/IPostStatus';
@@ -22,7 +21,7 @@ const PostStatusSelect = ({
<select
value={selectedPostStatusId || NO_POST_STATUS_VALUE}
onChange={
(e: FormEvent) => (
(e: React.FormEvent) => (
handleChange(parseInt((e.target as HTMLSelectElement).value))
)}
id="selectPickerStatus"

View File

@@ -20,7 +20,7 @@ interface Props {
class PostRoot extends React.Component<Props> {
store: any;
constructor(props) {
constructor(props: Props) {
super(props);
this.store = createStoreHelper();

View File

@@ -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;
}

View File

@@ -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) => (
<span className="badge" style={{backgroundColor: color, color: 'white'}}>{name}</span>
);

View File

@@ -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';

View File

@@ -3,7 +3,6 @@ import {
} from '../actions/requestComment';
import {
HandleCommentRepliesType,
TOGGLE_COMMENT_REPLY,
SET_COMMENT_REPLY_BODY,
} from '../actions/handleCommentReplies';

View File

@@ -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: '',