mirror of
https://github.com/astuto/astuto.git
synced 2025-12-16 11:47:56 +01:00
Remove unused imports and add some types
This commit is contained in:
@@ -6,7 +6,6 @@ import PostStatusFilter from './PostStatusFilter';
|
|||||||
import PostList from './PostList';
|
import PostList from './PostList';
|
||||||
|
|
||||||
import IBoard from '../../interfaces/IBoard';
|
import IBoard from '../../interfaces/IBoard';
|
||||||
import IPost from '../../interfaces/IPost';
|
|
||||||
|
|
||||||
import { PostsState } from '../../reducers/postsReducer';
|
import { PostsState } from '../../reducers/postsReducer';
|
||||||
import { PostStatusesState } from '../../reducers/postStatusesReducer';
|
import { PostStatusesState } from '../../reducers/postStatusesReducer';
|
||||||
@@ -37,7 +36,7 @@ class BoardP extends React.Component<Props> {
|
|||||||
this.props.requestPostStatuses();
|
this.props.requestPostStatuses();
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate(prevProps) {
|
componentDidUpdate(prevProps: Props) {
|
||||||
const { searchQuery } = this.props.posts.filters;
|
const { searchQuery } = this.props.posts.filters;
|
||||||
const prevSearchQuery = prevProps.posts.filters.searchQuery;
|
const prevSearchQuery = prevProps.posts.filters.searchQuery;
|
||||||
|
|
||||||
@@ -98,7 +97,6 @@ class BoardP extends React.Component<Props> {
|
|||||||
<PostList
|
<PostList
|
||||||
posts={posts.items}
|
posts={posts.items}
|
||||||
postStatuses={postStatuses.items}
|
postStatuses={postStatuses.items}
|
||||||
page={posts.page}
|
|
||||||
hasMore={posts.haveMore}
|
hasMore={posts.haveMore}
|
||||||
areLoading={posts.areLoading}
|
areLoading={posts.areLoading}
|
||||||
error={posts.error}
|
error={posts.error}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import * as React from 'react';
|
|||||||
import NewPostForm from './NewPostForm';
|
import NewPostForm from './NewPostForm';
|
||||||
import Spinner from '../shared/Spinner';
|
import Spinner from '../shared/Spinner';
|
||||||
import {
|
import {
|
||||||
TitleText,
|
|
||||||
MutedText,
|
MutedText,
|
||||||
DangerText,
|
DangerText,
|
||||||
SuccessText,
|
SuccessText,
|
||||||
@@ -29,7 +28,7 @@ interface State {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class NewPost extends React.Component<Props, State> {
|
class NewPost extends React.Component<Props, State> {
|
||||||
constructor(props) {
|
constructor(props: Props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
@@ -57,20 +56,20 @@ class NewPost extends React.Component<Props, State> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onTitleChange(title) {
|
onTitleChange(title: string) {
|
||||||
this.setState({
|
this.setState({
|
||||||
title,
|
title,
|
||||||
error: '',
|
error: '',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onDescriptionChange(description) {
|
onDescriptionChange(description: string) {
|
||||||
this.setState({
|
this.setState({
|
||||||
description,
|
description,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async submitForm(e) {
|
async submitForm(e: React.FormEvent) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ interface Props {
|
|||||||
error: string;
|
error: string;
|
||||||
|
|
||||||
handleLoadMore(): void;
|
handleLoadMore(): void;
|
||||||
page: number;
|
|
||||||
hasMore: boolean;
|
hasMore: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,7 +28,6 @@ const PostList = ({
|
|||||||
areLoading,
|
areLoading,
|
||||||
error,
|
error,
|
||||||
handleLoadMore,
|
handleLoadMore,
|
||||||
page,
|
|
||||||
hasMore
|
hasMore
|
||||||
}: Props) => (
|
}: Props) => (
|
||||||
<div className="postList">
|
<div className="postList">
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|||||||
|
|
||||||
import CommentsNumber from '../shared/CommentsNumber';
|
import CommentsNumber from '../shared/CommentsNumber';
|
||||||
import PostStatusLabel from '../shared/PostStatusLabel';
|
import PostStatusLabel from '../shared/PostStatusLabel';
|
||||||
import { TitleText, DescriptionText } from '../shared/CustomTexts';
|
import { DescriptionText } from '../shared/CustomTexts';
|
||||||
|
|
||||||
import IPostStatus from '../../interfaces/IPostStatus';
|
import IPostStatus from '../../interfaces/IPostStatus';
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ const PostStatusListItem = ({
|
|||||||
}>
|
}>
|
||||||
<a onClick={handleClick} className="postStatusListItemLink">
|
<a onClick={handleClick} className="postStatusListItemLink">
|
||||||
<div className="postStatusListItem">
|
<div className="postStatusListItem">
|
||||||
<PostStatusLabel id={undefined} name={name} color={color} />
|
<PostStatusLabel name={name} color={color} />
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ const SearchFilter = ({ searchQuery, handleChange }: Props) => (
|
|||||||
<TitleText>Search:</TitleText>
|
<TitleText>Search:</TitleText>
|
||||||
<input
|
<input
|
||||||
type="search"
|
type="search"
|
||||||
|
value={searchQuery}
|
||||||
onChange={e => handleChange(e.target.value)}
|
onChange={e => handleChange(e.target.value)}
|
||||||
id="searchPostInput"
|
id="searchPostInput"
|
||||||
className="form-control"
|
className="form-control"
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ interface Props {
|
|||||||
class BoardRoot extends React.Component<Props> {
|
class BoardRoot extends React.Component<Props> {
|
||||||
store: any;
|
store: any;
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props: Props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
this.store = createStoreHelper();
|
this.store = createStoreHelper();
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { FormEvent } from 'react';
|
|
||||||
|
|
||||||
import NewComment from './NewComment';
|
import NewComment from './NewComment';
|
||||||
import Separator from '../shared/Separator';
|
import Separator from '../shared/Separator';
|
||||||
@@ -12,14 +11,12 @@ import friendlyDate from '../../helpers/friendlyDate';
|
|||||||
interface Props {
|
interface Props {
|
||||||
id: number;
|
id: number;
|
||||||
body: string;
|
body: string;
|
||||||
parentId: number;
|
|
||||||
userFullName: string;
|
userFullName: string;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
|
|
||||||
level: number;
|
|
||||||
reply: CommentRepliesState;
|
reply: CommentRepliesState;
|
||||||
handleToggleCommentReply(): void;
|
handleToggleCommentReply(): void;
|
||||||
handleCommentReplyBodyChange(e: FormEvent): void;
|
handleCommentReplyBodyChange(e: React.FormEvent): void;
|
||||||
handleSubmitComment(body: string, parentId: number): void;
|
handleSubmitComment(body: string, parentId: number): void;
|
||||||
|
|
||||||
isLoggedIn: boolean;
|
isLoggedIn: boolean;
|
||||||
@@ -29,11 +26,9 @@ interface Props {
|
|||||||
const Comment = ({
|
const Comment = ({
|
||||||
id,
|
id,
|
||||||
body,
|
body,
|
||||||
parentId,
|
|
||||||
userFullName,
|
userFullName,
|
||||||
updatedAt,
|
updatedAt,
|
||||||
|
|
||||||
level,
|
|
||||||
reply,
|
reply,
|
||||||
handleToggleCommentReply,
|
handleToggleCommentReply,
|
||||||
handleCommentReplyBodyChange,
|
handleCommentReplyBodyChange,
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { FormEvent } from 'react';
|
|
||||||
|
|
||||||
import Comment from './Comment';
|
import Comment from './Comment';
|
||||||
|
|
||||||
@@ -39,11 +38,10 @@ const CommentList = ({
|
|||||||
return (
|
return (
|
||||||
<div className="commentList" key={i}>
|
<div className="commentList" key={i}>
|
||||||
<Comment
|
<Comment
|
||||||
level={level}
|
|
||||||
reply={replies.find(reply => reply.commentId === comment.id)}
|
reply={replies.find(reply => reply.commentId === comment.id)}
|
||||||
handleToggleCommentReply={() => toggleCommentReply(comment.id)}
|
handleToggleCommentReply={() => toggleCommentReply(comment.id)}
|
||||||
handleCommentReplyBodyChange={
|
handleCommentReplyBodyChange={
|
||||||
(e: FormEvent) => (
|
(e: React.FormEvent) => (
|
||||||
setCommentReplyBody(comment.id, (e.target as HTMLTextAreaElement).value)
|
setCommentReplyBody(comment.id, (e.target as HTMLTextAreaElement).value)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { FormEvent } from 'react';
|
|
||||||
|
|
||||||
import NewComment from './NewComment';
|
import NewComment from './NewComment';
|
||||||
import CommentList from './CommentList';
|
import CommentList from './CommentList';
|
||||||
import Spinner from '../shared/Spinner';
|
import Spinner from '../shared/Spinner';
|
||||||
import { DangerText, UppercaseText } from '../shared/CustomTexts';
|
import { DangerText } from '../shared/CustomTexts';
|
||||||
|
|
||||||
import IComment from '../../interfaces/IComment';
|
import IComment from '../../interfaces/IComment';
|
||||||
import { CommentRepliesState } from '../../reducers/commentRepliesReducer';
|
import { CommentRepliesState } from '../../reducers/commentRepliesReducer';
|
||||||
@@ -36,7 +35,7 @@ class CommentsP extends React.Component<Props> {
|
|||||||
this.props.requestComments(this.props.postId);
|
this.props.requestComments(this.props.postId);
|
||||||
}
|
}
|
||||||
|
|
||||||
_handleSubmitComment = (body, parentId) => {
|
_handleSubmitComment = (body: string, parentId: number) => {
|
||||||
this.props.submitComment(
|
this.props.submitComment(
|
||||||
this.props.postId,
|
this.props.postId,
|
||||||
body,
|
body,
|
||||||
@@ -57,7 +56,6 @@ class CommentsP extends React.Component<Props> {
|
|||||||
|
|
||||||
toggleCommentReply,
|
toggleCommentReply,
|
||||||
setCommentReplyBody,
|
setCommentReplyBody,
|
||||||
submitComment,
|
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
const postReply = replies.find(reply => reply.commentId === -1);
|
const postReply = replies.find(reply => reply.commentId === -1);
|
||||||
@@ -69,7 +67,7 @@ class CommentsP extends React.Component<Props> {
|
|||||||
parentId={null}
|
parentId={null}
|
||||||
isSubmitting={postReply && postReply.isSubmitting}
|
isSubmitting={postReply && postReply.isSubmitting}
|
||||||
handleChange={
|
handleChange={
|
||||||
(e: FormEvent) => (
|
(e: React.FormEvent) => (
|
||||||
setCommentReplyBody(-1, (e.target as HTMLTextAreaElement).value)
|
setCommentReplyBody(-1, (e.target as HTMLTextAreaElement).value)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { FormEvent } from 'react';
|
|
||||||
|
|
||||||
import Button from '../shared/Button';
|
import Button from '../shared/Button';
|
||||||
import Spinner from '../shared/Spinner';
|
import Spinner from '../shared/Spinner';
|
||||||
@@ -8,7 +7,7 @@ interface Props {
|
|||||||
body: string;
|
body: string;
|
||||||
parentId: number;
|
parentId: number;
|
||||||
isSubmitting: boolean;
|
isSubmitting: boolean;
|
||||||
handleChange(e: FormEvent): void;
|
handleChange(e: React.FormEvent): void;
|
||||||
handleSubmit(body: string, parentId: number): void;
|
handleSubmit(body: string, parentId: number): void;
|
||||||
|
|
||||||
isLoggedIn: boolean;
|
isLoggedIn: boolean;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { FormEvent } from 'react';
|
|
||||||
|
|
||||||
import IBoard from '../../interfaces/IBoard';
|
import IBoard from '../../interfaces/IBoard';
|
||||||
|
|
||||||
@@ -20,7 +19,7 @@ const PostBoardSelect = ({
|
|||||||
<select
|
<select
|
||||||
value={selectedBoardId || 'Loading...'}
|
value={selectedBoardId || 'Loading...'}
|
||||||
onChange={
|
onChange={
|
||||||
(e: FormEvent) => (
|
(e: React.FormEvent) => (
|
||||||
handleChange(parseInt((e.target as HTMLSelectElement).value))
|
handleChange(parseInt((e.target as HTMLSelectElement).value))
|
||||||
)}
|
)}
|
||||||
id="selectPickerBoard"
|
id="selectPickerBoard"
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { FormEvent } from 'react';
|
|
||||||
|
|
||||||
import IPostStatus from '../../interfaces/IPostStatus';
|
import IPostStatus from '../../interfaces/IPostStatus';
|
||||||
|
|
||||||
@@ -22,7 +21,7 @@ const PostStatusSelect = ({
|
|||||||
<select
|
<select
|
||||||
value={selectedPostStatusId || NO_POST_STATUS_VALUE}
|
value={selectedPostStatusId || NO_POST_STATUS_VALUE}
|
||||||
onChange={
|
onChange={
|
||||||
(e: FormEvent) => (
|
(e: React.FormEvent) => (
|
||||||
handleChange(parseInt((e.target as HTMLSelectElement).value))
|
handleChange(parseInt((e.target as HTMLSelectElement).value))
|
||||||
)}
|
)}
|
||||||
id="selectPickerStatus"
|
id="selectPickerStatus"
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ interface Props {
|
|||||||
class PostRoot extends React.Component<Props> {
|
class PostRoot extends React.Component<Props> {
|
||||||
store: any;
|
store: any;
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props: Props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
this.store = createStoreHelper();
|
this.store = createStoreHelper();
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { FormEvent } from 'react';
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
children: any;
|
children: any;
|
||||||
onClick(e: FormEvent): void;
|
onClick(e: React.FormEvent): void;
|
||||||
className?: string;
|
className?: string;
|
||||||
outline?: boolean;
|
outline?: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
|
|
||||||
import IPostStatus from '../../interfaces/IPostStatus';
|
interface Props {
|
||||||
|
name: string;
|
||||||
|
color: string;
|
||||||
|
}
|
||||||
|
|
||||||
const PostStatusLabel = ({
|
const PostStatusLabel = ({
|
||||||
id,
|
|
||||||
name,
|
name,
|
||||||
color,
|
color,
|
||||||
}: IPostStatus) => (
|
}: Props) => (
|
||||||
<span className="badge" style={{backgroundColor: color, color: 'white'}}>{name}</span>
|
<span className="badge" style={{backgroundColor: color, color: 'white'}}>{name}</span>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
import { requestPost } from '../actions/requestPost';
|
import { requestPost } from '../actions/requestPost';
|
||||||
import { requestComments } from '../actions/requestComments';
|
|
||||||
import { changePostBoard } from '../actions/changePostBoard';
|
import { changePostBoard } from '../actions/changePostBoard';
|
||||||
import { changePostStatus } from '../actions/changePostStatus';
|
import { changePostStatus } from '../actions/changePostStatus';
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import {
|
|||||||
} from '../actions/requestComment';
|
} from '../actions/requestComment';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
HandleCommentRepliesType,
|
|
||||||
TOGGLE_COMMENT_REPLY,
|
TOGGLE_COMMENT_REPLY,
|
||||||
SET_COMMENT_REPLY_BODY,
|
SET_COMMENT_REPLY_BODY,
|
||||||
} from '../actions/handleCommentReplies';
|
} from '../actions/handleCommentReplies';
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import {
|
import {
|
||||||
CommentsRequestActionTypes,
|
|
||||||
COMMENTS_REQUEST_START,
|
COMMENTS_REQUEST_START,
|
||||||
COMMENTS_REQUEST_SUCCESS,
|
COMMENTS_REQUEST_SUCCESS,
|
||||||
COMMENTS_REQUEST_FAILURE,
|
COMMENTS_REQUEST_FAILURE,
|
||||||
@@ -8,7 +7,6 @@ import {
|
|||||||
import { commentRequestSuccess } from '../actions/requestComment';
|
import { commentRequestSuccess } from '../actions/requestComment';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
HandleCommentRepliesType,
|
|
||||||
TOGGLE_COMMENT_REPLY,
|
TOGGLE_COMMENT_REPLY,
|
||||||
SET_COMMENT_REPLY_BODY,
|
SET_COMMENT_REPLY_BODY,
|
||||||
} from '../actions/handleCommentReplies';
|
} from '../actions/handleCommentReplies';
|
||||||
@@ -23,6 +21,7 @@ import commentReducer from './commentReducer';
|
|||||||
import commentRepliesReducer from './commentRepliesReducer';
|
import commentRepliesReducer from './commentRepliesReducer';
|
||||||
|
|
||||||
import IComment from '../interfaces/IComment';
|
import IComment from '../interfaces/IComment';
|
||||||
|
import ICommentJSON from '../interfaces/json/IComment';
|
||||||
import { CommentRepliesState } from './commentRepliesReducer';
|
import { CommentRepliesState } from './commentRepliesReducer';
|
||||||
|
|
||||||
export interface CommentsState {
|
export interface CommentsState {
|
||||||
@@ -54,11 +53,11 @@ const commentsReducer = (
|
|||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
items: action.comments.map(
|
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 } }),
|
replies: [commentRepliesReducer(undefined, {type: 'COMMENT_REQUEST_SUCCESS', comment: { id: -1 } }),
|
||||||
...action.comments.map(
|
...action.comments.map(
|
||||||
comment => commentRepliesReducer(undefined, commentRequestSuccess(comment))
|
(comment: ICommentJSON) => commentRepliesReducer(undefined, commentRequestSuccess(comment))
|
||||||
)],
|
)],
|
||||||
areLoading: false,
|
areLoading: false,
|
||||||
error: '',
|
error: '',
|
||||||
|
|||||||
Reference in New Issue
Block a user