-
-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Front: Fix eslint "components as pure function" warning (#1798)
- Loading branch information
Showing
7 changed files
with
95 additions
and
122 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,68 @@ | ||
import { Component } from 'preact'; | ||
import { connect } from 'unistore/preact'; | ||
import get from 'get-value'; | ||
|
||
import validateEmail from '../../utils/validateEmail'; | ||
import { ForgotPasswordStatus, RequestStatus } from '../../utils/consts'; | ||
import ForgotPasswordPage from './ForgotPasswordPage'; | ||
import actions from '../../actions/forgotPassword'; | ||
|
||
class ForgotPassword extends Component { | ||
render(props, {}) { | ||
return <ForgotPasswordPage {...props} />; | ||
forgotPassword = async e => { | ||
const { forgotPasswordEmail } = this.state; | ||
if (e) { | ||
e.preventDefault(); | ||
} | ||
|
||
if (!validateEmail(forgotPasswordEmail)) { | ||
return this.setState({ | ||
forgotPasswordStatus: ForgotPasswordStatus.WrongEmailError | ||
}); | ||
} | ||
|
||
this.setState({ | ||
forgotPasswordStatus: RequestStatus.Getting | ||
}); | ||
|
||
try { | ||
await this.props.httpClient.post('/api/v1/forgot_password', { | ||
email: forgotPasswordEmail, | ||
origin: window.location.origin | ||
}); | ||
|
||
this.setState({ | ||
forgotPasswordStatus: RequestStatus.Success | ||
}); | ||
} catch (e) { | ||
const status = get(e, 'response.status'); | ||
if (!status) { | ||
this.setState({ | ||
forgotPasswordStatus: RequestStatus.NetworkError | ||
}); | ||
} else if (status === 404) { | ||
this.setState({ | ||
forgotPasswordStatus: ForgotPasswordStatus.UserNotFound | ||
}); | ||
} else if (status === 429) { | ||
this.setState({ | ||
forgotPasswordStatus: RequestStatus.RateLimitError | ||
}); | ||
} else { | ||
this.setState({ | ||
forgotPasswordStatus: RequestStatus.Error | ||
}); | ||
} | ||
} | ||
}; | ||
|
||
updateEmail = e => { | ||
this.setState({ | ||
forgotPasswordEmail: e.target.value | ||
}); | ||
}; | ||
|
||
render({}, state) { | ||
return <ForgotPasswordPage {...state} updateEmail={this.updateEmail} forgotPassword={this.forgotPassword} />; | ||
} | ||
} | ||
|
||
export default connect('forgotPasswordStatus,forgotPasswordEmail', actions)(ForgotPassword); | ||
export default connect('httpClient')(ForgotPassword); |
25 changes: 10 additions & 15 deletions
25
front/src/routes/integration/all/bluetooth/edit-page/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,18 @@ | ||
import { Component } from 'preact'; | ||
import { connect } from 'unistore/preact'; | ||
import BluetoothPage from '../BluetoothPage'; | ||
import UpdateDevice from '../../../../../components/device'; | ||
|
||
const BLUETOOTH_PAGE_PATH = '/dashboard/integration/device/bluetooth'; | ||
|
||
class BluetoothEditDevicePage extends Component { | ||
render(props, {}) { | ||
return ( | ||
<BluetoothPage> | ||
<UpdateDevice | ||
{...props} | ||
integrationName="bluetooth" | ||
allowModifyFeatures={false} | ||
previousPage={BLUETOOTH_PAGE_PATH} | ||
/> | ||
</BluetoothPage> | ||
); | ||
} | ||
} | ||
const BluetoothEditDevicePage = props => ( | ||
<BluetoothPage> | ||
<UpdateDevice | ||
{...props} | ||
integrationName="bluetooth" | ||
allowModifyFeatures={false} | ||
previousPage={BLUETOOTH_PAGE_PATH} | ||
/> | ||
</BluetoothPage> | ||
); | ||
|
||
export default connect('user,session,httpClient,currentIntegration,houses', {})(BluetoothEditDevicePage); |
15 changes: 5 additions & 10 deletions
15
front/src/routes/integration/all/bluetooth/settings-page/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,13 @@ | ||
import { Component } from 'preact'; | ||
import { connect } from 'unistore/preact'; | ||
|
||
import BluetoothPage from '../BluetoothPage'; | ||
import BluetoothSettingsTab from './BluetoothSettingsTab'; | ||
import actions from '../commons/actions'; | ||
|
||
class BluetoothSettingsPage extends Component { | ||
render(props) { | ||
return ( | ||
<BluetoothPage> | ||
<BluetoothSettingsTab {...props} /> | ||
</BluetoothPage> | ||
); | ||
} | ||
} | ||
const BluetoothSettingsPage = props => ( | ||
<BluetoothPage> | ||
<BluetoothSettingsTab {...props} /> | ||
</BluetoothPage> | ||
); | ||
|
||
export default connect('user,httpClient,bluetoothStatus', actions)(BluetoothSettingsPage); |
25 changes: 10 additions & 15 deletions
25
front/src/routes/integration/all/ewelink/edit-page/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,16 @@ | ||
import { Component } from 'preact'; | ||
import { connect } from 'unistore/preact'; | ||
import EweLinkPage from '../EweLinkPage'; | ||
import UpdateDevice from '../../../../../components/device'; | ||
|
||
class EditEweLinkDevice extends Component { | ||
render(props, {}) { | ||
return ( | ||
<EweLinkPage user={props.user}> | ||
<UpdateDevice | ||
{...props} | ||
integrationName="ewelink" | ||
allowModifyFeatures={false} | ||
previousPage="/dashboard/integration/device/ewelink" | ||
/> | ||
</EweLinkPage> | ||
); | ||
} | ||
} | ||
const EditEweLinkDevice = props => ( | ||
<EweLinkPage user={props.user}> | ||
<UpdateDevice | ||
{...props} | ||
integrationName="ewelink" | ||
allowModifyFeatures={false} | ||
previousPage="/dashboard/integration/device/ewelink" | ||
/> | ||
</EweLinkPage> | ||
); | ||
|
||
export default connect('user,session,httpClient,currentIntegration,houses', {})(EditEweLinkDevice); |
15 changes: 5 additions & 10 deletions
15
front/src/routes/integration/all/lan-manager/settings-page/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,12 @@ | ||
import { Component } from 'preact'; | ||
import { connect } from 'unistore/preact'; | ||
|
||
import LANManagerPage from '../LANManagerPage'; | ||
import LANManagerSettingsTab from './LANManagerSettingsTab'; | ||
|
||
class LANManagerSettingsPage extends Component { | ||
render(props) { | ||
return ( | ||
<LANManagerPage> | ||
<LANManagerSettingsTab {...props} /> | ||
</LANManagerPage> | ||
); | ||
} | ||
} | ||
const LANManagerSettingsPage = props => ( | ||
<LANManagerPage> | ||
<LANManagerSettingsTab {...props} /> | ||
</LANManagerPage> | ||
); | ||
|
||
export default connect('user,httpClient')(LANManagerSettingsPage); |
15 changes: 5 additions & 10 deletions
15
front/src/routes/integration/all/xiaomi/edit-page/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,14 @@ | ||
import { Component } from 'preact'; | ||
import { connect } from 'unistore/preact'; | ||
import actions from '../actions'; | ||
import XiaomiLayout from '../XiaomiLayout'; | ||
import EditPage from './EditPage'; | ||
|
||
const XIAOMI_PAGE_PATH = '/dashboard/integration/device/xiaomi'; | ||
|
||
class EditXiaomiDevice extends Component { | ||
render(props, {}) { | ||
return ( | ||
<XiaomiLayout> | ||
<EditPage integrationName="xiaomi" allowModifyFeatures={false} previousPage={XIAOMI_PAGE_PATH} {...props} /> | ||
</XiaomiLayout> | ||
); | ||
} | ||
} | ||
const EditXiaomiDevice = props => ( | ||
<XiaomiLayout> | ||
<EditPage integrationName="xiaomi" allowModifyFeatures={false} previousPage={XIAOMI_PAGE_PATH} {...props} /> | ||
</XiaomiLayout> | ||
); | ||
|
||
export default connect('user,session,httpClient,currentIntegration,houses', actions)(EditXiaomiDevice); |