diff --git a/fittrackee_client/src/components/User/UserProfile.jsx b/fittrackee_client/src/components/User/UserProfile.jsx
index 6cd0b0ae..f6ae46be 100644
--- a/fittrackee_client/src/components/User/UserProfile.jsx
+++ b/fittrackee_client/src/components/User/UserProfile.jsx
@@ -2,10 +2,19 @@ import React from 'react'
import { withTranslation } from 'react-i18next'
import { connect } from 'react-redux'
+import CustomModal from '../Common/CustomModal'
import ProfileDetail from './ProfileDetail'
import { getOrUpdateData } from '../../actions'
+import { deleteUser } from '../../actions/user'
class UserProfile extends React.Component {
+ constructor(props, context) {
+ super(props, context)
+ this.state = {
+ displayModal: false,
+ }
+ }
+
componentDidMount() {
this.props.loadUser(this.props.match.params.userName)
}
@@ -16,14 +25,40 @@ class UserProfile extends React.Component {
}
}
+ displayModal(value) {
+ this.setState(prevState => ({
+ ...prevState,
+ displayModal: value,
+ }))
+ }
+
render() {
- const { t, currentUser, users } = this.props
+ const { t, currentUser, onDeleteUser, users } = this.props
+ const { displayModal } = this.state
const [user] = users
+ const editable = user ? currentUser.username === user.username : false
return (
+ {displayModal && (
+
{
+ onDeleteUser(user.username)
+ this.displayModal(false)
+ }}
+ close={() => this.displayModal(false)}
+ />
+ )}
{user && (
this.displayModal(e)}
t={t}
user={user}
/>
@@ -40,6 +75,9 @@ export default withTranslation()(
users: state.users.data,
}),
dispatch => ({
+ onDeleteUser: username => {
+ dispatch(deleteUser(username, true))
+ },
loadUser: userName => {
dispatch(getOrUpdateData('getData', 'users', { username: userName }))
},
diff --git a/fittrackee_client/src/locales/en/user.json b/fittrackee_client/src/locales/en/user.json
index c7fd5e6a..405a484e 100644
--- a/fittrackee_client/src/locales/en/user.json
+++ b/fittrackee_client/src/locales/en/user.json
@@ -1,5 +1,6 @@
{
"Admin": "Admin",
+ "Are you sure you want to delete this account? All data will be deleted, this cannot be undone.": "Are you sure you want to delete this account? All data will be deleted, this cannot be undone.",
"Are you sure you want to delete your account? All data will be deleted, this cannot be undone.": "Are you sure you want to delete your account? All data will be deleted, this cannot be undone.",
"Bio": "Bio",
"Birth Date": "Birth Date",
diff --git a/fittrackee_client/src/locales/fr/user.json b/fittrackee_client/src/locales/fr/user.json
index aca5e2e1..e6b80497 100644
--- a/fittrackee_client/src/locales/fr/user.json
+++ b/fittrackee_client/src/locales/fr/user.json
@@ -1,5 +1,6 @@
{
"Admin": "Admin",
+ "Are you sure you want to delete this account? All data will be deleted, this cannot be undone.": "Etes-vous sûr de vouloir supprimer ce compte ? Toutes les données seront définitivement effacés.",
"Are you sure you want to delete your account? All data will be deleted, this cannot be undone.": "Etes-vous sûr de vouloir supprimer votre compte ? Toutes les données seront définitivement effacés.",
"Bio": "Bio",
"Birth Date": "Date de naissance",