-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate/typescript: Project shifted to Typescript #251
base: integrate/typescript
Are you sure you want to change the base?
Changes from 19 commits
fe3050e
d36dae8
e5e3b5c
104119c
a524f92
8bf4a09
f7621e7
0bc5a95
44dfe08
41e6546
7fcfc88
0946314
5397e97
a6564cf
f2363ea
1952552
6e7cf5a
e03514d
83ce197
ea43df1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
import React, { Component } from 'react'; | ||
import CommentListItem from './CommentListItem'; | ||
const CommentList = props => { | ||
import { Comments } from '../../types/comments-types'; | ||
|
||
type Props = Comments; | ||
|
||
const CommentList = (props: Props) => { | ||
return ( | ||
<ul className="commentList"> | ||
{props.comments.map(comment => ( | ||
<CommentListItem comment={comment} key={comment.id} /> | ||
<CommentListItem comment={comment} /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does not this produce an error after removing key ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was duplicated. In the container and the component to be rendered. I kept it only in the component. Won't throw a warning. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accidentally removed the key. Should have removed from the Item. Done. |
||
))} | ||
</ul> | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,13 @@ import React, { Component } from 'react'; | |
import { Col, Row } from 'reactstrap'; | ||
import moment from 'moment'; | ||
import avatar from '../../../src/avatar.jpg'; | ||
import { Comment } from '../../types/comments-types'; | ||
|
||
class CommentListItem extends Component { | ||
type Props = { | ||
comment: Comment | ||
}; | ||
|
||
class CommentListItem extends Component<Props> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. make it functional component if does not have state |
||
render() { | ||
const comment = this.props.comment; | ||
return ( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,14 @@ import CommentBox from './CommentBox'; | |
import CommentList from './CommentList'; | ||
import { connect } from 'react-redux'; | ||
import { addComment } from '../../actions'; | ||
import { BaseReduxPropTypes, BaseReducerPropsTypes } from '../../types/base-props-types'; | ||
import { EventComments } from '../../types/comments-types'; | ||
|
||
class CommentsBlock extends Component { | ||
type Props = BaseReduxPropTypes & BaseReducerPropsTypes & EventComments & { | ||
eventID: string | ||
}; | ||
|
||
class CommentsBlock extends Component<Props> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. make it functional component if does not have state |
||
postComment = e => { | ||
e.preventDefault(); | ||
const { dispatch } = this.props; | ||
|
@@ -32,8 +38,8 @@ class CommentsBlock extends Component { | |
{this.props.userState.token ? ( | ||
<CommentBox onSubmit={this.postComment} /> | ||
) : ( | ||
<div>Sign in to comment here...</div> | ||
)} | ||
<div>Sign in to comment here...</div> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,11 @@ import React from 'react'; | |
import { Row, Col } from 'reactstrap'; | ||
import SocialShare from '../SocialShare/SocialShare'; | ||
|
||
const DescriptionContainer = props => { | ||
type Props = { | ||
description: string, | ||
}; | ||
|
||
const DescriptionContainer = (props: Props) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. its not logically correct container can not be stateless functional component There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the container doesn't require any state, why shouldn't it be a functional component? |
||
return ( | ||
<Row className="block-content text-justify"> | ||
<Col md="9"> | ||
|
@@ -21,9 +25,7 @@ const DescriptionContainer = props => { | |
</p> | ||
</Col> | ||
</Row> | ||
<center> | ||
<SocialShare /> | ||
</center> | ||
<SocialShare /> | ||
</Col> | ||
</Row> | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,8 +10,11 @@ import { | |
fetchTags, | ||
} from '../../actions'; | ||
import { OrganisationType } from '../../types/organisation-types'; | ||
import { BaseReduxPropTypes } from '../../types/base-props-types'; | ||
import { LocationType } from '../../types/location-types' | ||
import { EventType } from '../../types/event-types'; | ||
import { SponsorType } from '../../types/sponsor-types'; | ||
import { InputChange } from '../../types/dom-events-types'; | ||
import 'react-select/dist/react-select.min.css'; | ||
import './DropSearch.css'; | ||
|
||
|
@@ -26,17 +29,19 @@ type Props = BaseReduxPropTypes & { | |
locations: Array<LocationType>, | ||
sponsors: Array<SponsorType>, | ||
handleSearchChange: Function, | ||
sortBy: string, | ||
}; | ||
|
||
export type State = { | ||
filterOrganisation: Array<Object>, | ||
filterDateFrom: string, | ||
filterDateTo: string, | ||
filterLocation: Object, | ||
filterSponsers: Array<Object>, | ||
filterKeywords: string, | ||
filterTags: Array<Object>, | ||
filterTime: Array<Object>, | ||
filterOrganisation?: Array<Object>, | ||
filterDateFrom?: string, | ||
filterDateTo?: string, | ||
filterLocation?: Object, | ||
filterSponsers?: Array<Object>, | ||
filterKeywords?: string, | ||
filterTags?: Array<Object>, | ||
filterTime?: Array<Object>, | ||
sortBy?: string, | ||
}; | ||
class DropSearch extends Component<Props, State> { | ||
constructor(props) { | ||
|
@@ -51,6 +56,7 @@ class DropSearch extends Component<Props, State> { | |
filterKeywords: '', | ||
filterTags: [], | ||
filterTime: [], | ||
sortBy: '' | ||
}; | ||
this.fetchDependencies(); | ||
} | ||
|
@@ -63,18 +69,17 @@ class DropSearch extends Component<Props, State> { | |
dispatch(fetchTags()); | ||
} | ||
|
||
handleInputChange = e => { | ||
handleInputChange = (e: InputChange<HTMLInputElement>) => { | ||
const { name, value } = e.target; | ||
this.setState({ [name]: value }); | ||
console.log(''); | ||
}; | ||
|
||
handleSelect = e => { | ||
const { name, value } = e; | ||
this.setState({ [name]: value }); | ||
}; | ||
|
||
mapStateToOptions: (key: string) => Array<ReactSearchOptions> = key => { | ||
mapStateToOptions = key => { | ||
let target = this.props[key]; | ||
target = target ? target[key] : []; | ||
return target.map(opt => ({ label: opt.name, value: opt.id })); | ||
|
@@ -89,7 +94,7 @@ class DropSearch extends Component<Props, State> { | |
* - and pass either undefined or extracted object to prop (handleSearchChange method) | ||
* @returns undefined. | ||
*/ | ||
handleSearchChange = (e: SyntheticEvent<HTMLButtonElement>) => { | ||
handleSearchChange = e => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can not we add event type here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need to add types to everything in our app. Mostly the model should be restricted with types. Including redux logic and component state. |
||
e.preventDefault(); | ||
let { handleSearchChange } = this.props, | ||
state = { ...this.state }, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this component does not have a state we can change it to dump or stateless functional component. If it has state we need to define type for state