File tree 4 files changed +28
-15
lines changed
4 files changed +28
-15
lines changed Original file line number Diff line number Diff line change @@ -218,6 +218,11 @@ export const updateProfile = async (
218
218
return response . data
219
219
}
220
220
221
+ export const activateUser = async ( userId : TypesGen . User [ "id" ] ) : Promise < TypesGen . User > => {
222
+ const response = await axios . put < TypesGen . User > ( `/api/v2/users/${ userId } /status/active` )
223
+ return response . data
224
+ }
225
+
221
226
export const suspendUser = async ( userId : TypesGen . User [ "id" ] ) : Promise < TypesGen . User > => {
222
227
const response = await axios . put < TypesGen . User > ( `/api/v2/users/${ userId } /status/suspend` )
223
228
return response . data
Original file line number Diff line number Diff line change @@ -65,9 +65,7 @@ export const UsersTable: React.FC<UsersTableProps> = ({
65
65
< TableCell >
66
66
< AvatarData title = { u . username } subtitle = { u . email } />
67
67
</ TableCell >
68
- < TableCell >
69
- { u . status }
70
- </ TableCell >
68
+ < TableCell > { u . status } </ TableCell >
71
69
< TableCell >
72
70
{ canEditUsers ? (
73
71
< RoleSelect
@@ -86,16 +84,25 @@ export const UsersTable: React.FC<UsersTableProps> = ({
86
84
data = { u }
87
85
menuItems = {
88
86
// Return either suspend or activate depending on status
89
- ( u . status == "active" ? [ {
90
- label : Language . suspendMenuItem ,
91
- onClick : onSuspendUser ,
92
- } ] : [ {
93
- label : Language . activateMenuItem ,
94
- onClick : onSuspendUser ,
95
- } ] ) . concat ( {
87
+ ( u . status == "active"
88
+ ? [
89
+ {
90
+ label : Language . suspendMenuItem ,
91
+ onClick : onSuspendUser ,
92
+ } ,
93
+ ]
94
+ : [
95
+ {
96
+ label : Language . activateMenuItem ,
97
+ // TODO: Activate user
98
+ onClick : function ( ) { } ,
99
+ } ,
100
+ ]
101
+ ) . concat ( {
96
102
label : Language . resetPasswordMenuItem ,
97
103
onClick : onResetUserPassword ,
98
- } ) }
104
+ } )
105
+ }
99
106
/>
100
107
</ TableCell >
101
108
) }
Original file line number Diff line number Diff line change @@ -2,12 +2,11 @@ import { makeStyles } from "@material-ui/core/styles"
2
2
import { useActor } from "@xstate/react"
3
3
import React , { useContext } from "react"
4
4
import { Navigate , useLocation } from "react-router-dom"
5
+ import { isApiError } from "../../api/errors"
5
6
import { Footer } from "../../components/Footer/Footer"
6
7
import { SignInForm } from "../../components/SignInForm/SignInForm"
7
8
import { retrieveRedirect } from "../../util/redirect"
8
9
import { XServiceContext } from "../../xServices/StateContext"
9
- import { AxiosError } from "axios"
10
- import { isApiError } from "../../api/errors" ;
11
10
12
11
export const useStyles = makeStyles ( ( theme ) => ( {
13
12
root : {
@@ -35,7 +34,9 @@ export const LoginPage: React.FC = () => {
35
34
const [ authState , authSend ] = useActor ( xServices . authXService )
36
35
const isLoading = authState . hasTag ( "loading" )
37
36
const redirectTo = retrieveRedirect ( location . search )
38
- const authErrorMessage = isApiError ( authState . context . authError ) ? authState . context . authError . response . data . message : undefined
37
+ const authErrorMessage = isApiError ( authState . context . authError )
38
+ ? authState . context . authError . response . data . message
39
+ : undefined
39
40
const getMethodsError = authState . context . getMethodsError
40
41
? ( authState . context . getMethodsError as Error ) . message
41
42
: undefined
Original file line number Diff line number Diff line change
1
+ import { AxiosError } from "axios"
1
2
import { assign , createMachine } from "xstate"
2
3
import * as API from "../../api/api"
3
4
import * as TypesGen from "../../api/typesGenerated"
4
5
import { displayError , displaySuccess } from "../../components/GlobalSnackbar/utils"
5
- import { AxiosError } from "axios"
6
6
7
7
export const Language = {
8
8
successProfileUpdate : "Updated settings." ,
You can’t perform that action at this time.
0 commit comments