Updated Switch to return boolean instead of event

• Updated:
- Switch to return boolean instead of event
- all components usage
This commit is contained in:
mgabdev 2020-09-01 14:54:17 -05:00
parent fe0429d36b
commit 147f7ed878
5 changed files with 15 additions and 12 deletions

View File

@ -71,8 +71,8 @@ class EditProfileModal extends ImmutablePureComponent {
this.setState({ bioValue: value }) this.setState({ bioValue: value })
} }
handleLockedChange = ({ target }) => { handleLockedChange = (locked) => {
this.setState({ locked: target.checked }) this.setState({ locked })
} }
handleOnClose = () => { handleOnClose = () => {

View File

@ -14,8 +14,8 @@ class SettingSwitch extends ImmutablePureComponent {
'label', 'label',
] ]
onChange = ({ target }) => { onChange = (checked) => {
this.props.onChange(this.props.settingPath, target.checked) this.props.onChange(this.props.settingPath, checked)
} }
render () { render () {
@ -39,7 +39,6 @@ class SettingSwitch extends ImmutablePureComponent {
id={id} id={id}
checked={checked} checked={checked}
onChange={this.onChange} onChange={this.onChange}
onKeyDown={this.onKeyDown}
/> />
) )
} }

View File

@ -74,8 +74,8 @@ const mapStateToProps = (state, { id }) => ({
}) })
const mapDispatchToProps = (dispatch, { id }) => ({ const mapDispatchToProps = (dispatch, { id }) => ({
onToggle(e) { onToggle(checked) {
dispatch(toggleStatusReport(id, e.target.checked)) dispatch(toggleStatusReport(id, checked))
}, },
}) })

View File

@ -5,6 +5,10 @@ import Text from './text'
class Switch extends React.PureComponent { class Switch extends React.PureComponent {
handleOnChange = (e) => {
this.props.onChange(e.currentTarget.checked)
}
render() { render() {
const { const {
id, id,
@ -51,7 +55,7 @@ class Switch extends React.PureComponent {
<label className={checkboxContainerClasses} htmlFor={id}> <label className={checkboxContainerClasses} htmlFor={id}>
<span className={checkboxLabelClasses} /> <span className={checkboxLabelClasses} />
<input type='checkbox' id={id} onChange={onChange} disabled={disabled} className={[_s.visibilityHidden].join(' ')} /> <input type='checkbox' id={id} onChange={this.handleOnChange} disabled={disabled} className={[_s.visibilityHidden].join(' ')} />
</label> </label>
</div> </div>
) )

View File

@ -320,11 +320,11 @@ const mapDispatchToProps = (dispatch) => ({
onChangeGroupCategory(e) { onChangeGroupCategory(e) {
dispatch(changeGroupCategory(e.target.value)) dispatch(changeGroupCategory(e.target.value))
}, },
onChangeGroupIsPrivate(value) { onChangeGroupIsPrivate(checked) {
dispatch(changeGroupIsPrivate(value)) dispatch(changeGroupIsPrivate(checked))
}, },
onChangeGroupIsVisible(value) { onChangeGroupIsVisible(checked) {
dispatch(changeGroupIsVisible(value)) dispatch(changeGroupIsVisible(checked))
}, },
onResetEditor() { onResetEditor() {
dispatch(resetEditor()) dispatch(resetEditor())