API & Client - update registration activation on user register/delete
+ minor refactor on administration (fix #15)
This commit is contained in:
@ -3,6 +3,7 @@ import FitTrackeeApi from '../fitTrackeeApi/auth'
|
||||
import { history } from '../index'
|
||||
import { generateIds } from '../utils'
|
||||
import { getOrUpdateData, setError, updateLanguage } from './index'
|
||||
import { getAppData } from './application'
|
||||
|
||||
const AuthError = message => ({ type: 'AUTH_ERROR', message })
|
||||
|
||||
@ -50,6 +51,9 @@ export const loginOrRegister = (target, formData) => dispatch =>
|
||||
.then(ret => {
|
||||
if (ret.status === 'success') {
|
||||
window.localStorage.setItem('authToken', ret.auth_token)
|
||||
if (target === 'register') {
|
||||
dispatch(getAppData('config'))
|
||||
}
|
||||
return dispatch(getProfile())
|
||||
}
|
||||
return dispatch(AuthError(ret.message))
|
||||
@ -138,6 +142,7 @@ export const deleteUser = (username, isAdmin = false) => dispatch =>
|
||||
FitTrackeeGenericApi.deleteData('users', username)
|
||||
.then(ret => {
|
||||
if (ret.status === 204) {
|
||||
dispatch(getAppData('config'))
|
||||
if (isAdmin) {
|
||||
history.push('/admin/users')
|
||||
} else {
|
||||
|
@ -82,8 +82,15 @@ class AdminApplication extends React.Component {
|
||||
>
|
||||
{t(
|
||||
// eslint-disable-next-line max-len
|
||||
'administration:Max. number of active users (if 0, no limitation)'
|
||||
'administration:Max. number of active users'
|
||||
)}
|
||||
<sup>
|
||||
<i
|
||||
className="fa fa-question-circle"
|
||||
aria-hidden="true"
|
||||
title={t('administration:if 0, no limitation')}
|
||||
/>
|
||||
</sup>
|
||||
:
|
||||
</label>
|
||||
<input
|
||||
@ -197,7 +204,6 @@ class AdminApplication extends React.Component {
|
||||
|
||||
export default connect(
|
||||
state => ({
|
||||
appConfig: state.application.config,
|
||||
message: state.message,
|
||||
}),
|
||||
dispatch => ({
|
||||
|
@ -4,7 +4,7 @@ import { Link } from 'react-router-dom'
|
||||
import AdminStats from './AdminStats'
|
||||
|
||||
export default function AdminDashboard(props) {
|
||||
const { t } = props
|
||||
const { appConfig, t } = props
|
||||
return (
|
||||
<div className="card activity-card">
|
||||
<div className="card-header">
|
||||
@ -27,7 +27,15 @@ export default function AdminDashboard(props) {
|
||||
{t(
|
||||
'administration:Update application configuration ' +
|
||||
'(maximum number of registered users, maximum files size).'
|
||||
)}{' '}
|
||||
)}
|
||||
<br />
|
||||
<strong>
|
||||
{t(
|
||||
`administration:Registration is currently ${
|
||||
appConfig.is_registration_enabled ? 'enabled' : 'disabled'
|
||||
}.`
|
||||
)}
|
||||
</strong>
|
||||
</dd>
|
||||
<br />
|
||||
<dt>
|
||||
|
@ -11,7 +11,7 @@ import AdminUsers from './AdminUsers'
|
||||
import NotFound from './../Others/NotFound'
|
||||
|
||||
function Admin(props) {
|
||||
const { t, user } = props
|
||||
const { appConfig, t, user } = props
|
||||
return (
|
||||
<>
|
||||
<Helmet>
|
||||
@ -23,12 +23,12 @@ function Admin(props) {
|
||||
<Route
|
||||
exact
|
||||
path="/admin"
|
||||
render={() => <AdminDashboard t={t} />}
|
||||
render={() => <AdminDashboard appConfig={appConfig} t={t} />}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path="/admin/application"
|
||||
render={() => <AdminApplication t={t} />}
|
||||
render={() => <AdminApplication appConfig={appConfig} t={t} />}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
@ -52,6 +52,7 @@ function Admin(props) {
|
||||
|
||||
export default withTranslation()(
|
||||
connect(state => ({
|
||||
appConfig: state.application.config,
|
||||
user: state.user,
|
||||
}))(Admin)
|
||||
)
|
||||
|
@ -13,14 +13,17 @@
|
||||
"Enable/disable sports.": "Enable/disable sports.",
|
||||
"FitTrackee administration": "FitTrackee administration",
|
||||
"id": "id",
|
||||
"if 0, no limitation": "if 0, no limitation",
|
||||
"Image": "Image",
|
||||
"Label": "Label",
|
||||
"Max. number of active users (if 0, no limitation)": "Max. number of active users",
|
||||
"Max. number of active users": "Max. number of active users",
|
||||
"Max. files of zip archive": "Max. files of zip archive",
|
||||
"Max. size of uploaded files": "Max. size of uploaded files",
|
||||
"Max. size of uploaded files (in Mb)": "Max. size of uploaded files (in Mb)",
|
||||
"Max. size of zip archive": "Max. size of zip archive",
|
||||
"Max. size of zip archive (in Mb)": "Max. size of zip archive (in Mb)",
|
||||
"Registration is currently disabled.": "Registration is currently disabled.",
|
||||
"Registration is currently enabled.": "Registration is currently enabled.",
|
||||
"Remove admin rights": "Remove admin rights",
|
||||
"Sports": "Sports",
|
||||
"Update application configuration (maximum number of registered users, maximum files size).": "Update application configuration (maximum number of registered users, maximum files size).",
|
||||
|
@ -13,14 +13,17 @@
|
||||
"Enable/disable sports.": "Activer/désactiver des sports.",
|
||||
"FitTrackee administration": "Administration de FitTrackee",
|
||||
"id": "id",
|
||||
"if 0, no limitation": "si égal à 0, pas limite d'inscription",
|
||||
"Image": "Image",
|
||||
"Label": "Label",
|
||||
"Max. number of active users (if 0, no limitation)": "Nombre maximum d'utilisateurs actifs",
|
||||
"Max. number of active users": "Nombre maximum d'utilisateurs actifs",
|
||||
"Max. files of zip archive": "Nombre max. de fichiers dans une archive zip",
|
||||
"Max. size of uploaded files": "Taille max. des fichiers",
|
||||
"Max. size of uploaded files (in Mb)": "Taille max. des fichiers (en Mo)",
|
||||
"Max. size of zip archive": "Taille max. des archives zip",
|
||||
"Max. size of zip archive (in Mb)": "Taille max. des archives zip (en Mo)",
|
||||
"Registration is currently disabled.": "Les inscriptions sont actuellement désactivées",
|
||||
"Registration is currently enabled.": "Les inscriptions sont actuellement activées",
|
||||
"Remove admin rights": "Retirer des droits d'admin",
|
||||
"Sports": "Sports",
|
||||
"Update application configuration (maximum number of registered users, maximum files size).": "Configurer l'application (nombre maximum d'utilisateurs inscrits, taille maximale des fichers).",
|
||||
|
Reference in New Issue
Block a user