-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add route and component for deleteUser * Invert isAdmin before handing it to DeleteUserForm Because the form is stupid, it's "impossible" to let it handle isActive as an inverted toggle. Instead we now invert the value, then hand it to the form. When it comes back we handle it the same way as before, but in its inverted state. I.e. true means that `isActive` is `false`. See DIH-399
- Loading branch information
Showing
3 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import React, { PropTypes } from 'react'; | ||
import { reduxForm } from 'redux-form'; | ||
|
||
import Form from '../Form'; | ||
import ToggleField from '../Form/ToggleField'; | ||
import Button from '../Button'; | ||
import Segment from '../Segment'; | ||
|
||
const fields = ['isActive']; | ||
|
||
|
||
function DeleteUser(props) { | ||
const { | ||
fields: { isActive }, | ||
handleSubmit, | ||
errorMessage, | ||
isFetching | ||
} = props; | ||
return ( | ||
<Segment> | ||
<Form | ||
id="deleteUserForm" | ||
errorMessage={errorMessage} | ||
handleSubmit={handleSubmit} | ||
> | ||
<ToggleField | ||
name="I confirm that I want to delete my account" | ||
label={`Deleting your account means that you will have to register again | ||
if you want to go on a new trip. Toggling this button and confirming will | ||
delete your account, and log you out.`} | ||
id="isActive" | ||
> | ||
{isActive} | ||
</ToggleField> | ||
<Button | ||
type="submit" | ||
color="red" | ||
fluid | ||
disabled={!isActive.value} | ||
loading={isFetching} | ||
id="submit" | ||
> | ||
Confirm deletion | ||
</Button> | ||
</Form> | ||
</Segment> | ||
); | ||
} | ||
|
||
DeleteUser.propTypes = { | ||
errorMessage: PropTypes.string, | ||
fields: PropTypes.object.isRequired, | ||
handleSubmit: PropTypes.func.isRequired, | ||
isFetching: PropTypes.bool, | ||
submitting: PropTypes.bool.isRequired, | ||
showAdminFields: PropTypes.bool, | ||
disableValidation: PropTypes.bool, | ||
user: PropTypes.object | ||
}; | ||
|
||
export default reduxForm({ | ||
form: 'deleteUserForm', | ||
fields | ||
})(DeleteUser); |
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
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