Skip to content

Commit

Permalink
fix: Fix use settings modal restore
Browse files Browse the repository at this point in the history
Signed-off-by: leoliu <leoliu@yunify.com>
  • Loading branch information
leoliu committed Aug 7, 2020
1 parent 8b1e2db commit 8b0e894
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions src/components/Modals/UserSetting/BaseInfo/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import React from 'react'
import PropTypes from 'prop-types'
import { Input, Select, Columns, Column } from '@pitrix/lego-ui'
import { cloneDeep } from 'lodash'
import { Form } from 'components/Base'
import { getBrowserLang } from 'utils'
import cookie from 'utils/cookie'
Expand All @@ -30,10 +31,28 @@ export default class BaseInfo extends React.Component {
registerUpdate: PropTypes.func,
}

constructor(props) {
super(props)

this.state = {
formData: this.getInitialData(),
}
}

componentDidUpdate(prevProps) {
if (prevProps.formData !== this.props.formData) {
this.setState({ formData: this.getInitialData() })
}
}

get name() {
return 'basicInfo'
}

getInitialData() {
return cloneDeep(this.props.formData)
}

resetData = () => {
this.setState({
formData: this.getInitialData(),
Expand All @@ -45,11 +64,15 @@ export default class BaseInfo extends React.Component {
}

render() {
const { formRef, formData } = this.props
const { formRef } = this.props
return (
<div className={styles.wrapper}>
<div className="h4">{t('Basic Info')}</div>
<Form data={formData} ref={formRef} onChange={this.handleFormChange}>
<Form
ref={formRef}
data={this.state.formData}
onChange={this.handleFormChange}
>
<Columns>
<Column>
<Form.Item label={t('User Name')}>
Expand Down

0 comments on commit 8b0e894

Please sign in to comment.