44 */
55
66import { NERButton } from '../../components/NERButton' ;
7- import { Grid , Typography , useTheme } from '@mui/material' ;
8- import PageBlock from '../../layouts/PageBlock' ;
7+ import { Box , Grid , Typography , useTheme } from '@mui/material' ;
98import Select , { SelectChangeEvent } from '@mui/material/Select' ;
109import MenuItem from '@mui/material/MenuItem' ;
1110import { useState } from 'react' ;
@@ -21,7 +20,6 @@ const AdminToolsUserManagement: React.FC = () => {
2120 const [ role , setRole ] = useState ( '' ) ;
2221 const [ user , setUser ] = useState < User | null > ( null ) ;
2322 const [ isDisabled , setIsDisabled ] = useState ( true ) ;
24- const [ hideSuccessLabel , setHideSuccessLabel ] = useState ( true ) ;
2523 const { isLoading, isError, error, data : users } = useAllUsers ( ) ;
2624 const updateUserRole = useUpdateUserRole ( ) ;
2725 const theme = useTheme ( ) ;
@@ -52,7 +50,6 @@ const AdminToolsUserManagement: React.FC = () => {
5250 if ( user ) {
5351 setUser ( user ) ;
5452 setRole ( user . role ) ;
55- setHideSuccessLabel ( true ) ;
5653 }
5754 } else {
5855 setUser ( null ) ;
@@ -69,11 +66,10 @@ const AdminToolsUserManagement: React.FC = () => {
6966 } ;
7067
7168 const handleClick = async ( ) => {
72- setHideSuccessLabel ( true ) ;
7369 if ( ! user ) return ;
7470 try {
7571 await updateUserRole . mutateAsync ( { userId : user . userId , role } ) ;
76- setHideSuccessLabel ( false ) ;
72+ toast . success ( 'Role updated successfully!' ) ;
7773 setUser ( null ) ;
7874 } catch ( e ) {
7975 if ( e instanceof Error ) {
@@ -87,9 +83,12 @@ const AdminToolsUserManagement: React.FC = () => {
8783 } ;
8884
8985 return (
90- < PageBlock title = { 'Role Management' } >
86+ < Box >
87+ < Typography variant = "h5" gutterBottom borderBottom = { 1 } color = "red" borderColor = { 'white' } marginBottom = { '20px' } >
88+ Role Management
89+ </ Typography >
9190 < Grid container spacing = { 2 } >
92- < Grid item xs = { 12 } md = { 8 } >
91+ < Grid item xs = { 12 } md = { 7 } >
9392 < NERAutocomplete
9493 id = "users-autocomplete"
9594 onChange = { usersSearchOnChange }
@@ -99,7 +98,7 @@ const AdminToolsUserManagement: React.FC = () => {
9998 value = { user ? userToAutocompleteOptionWithRole ( user ) : null }
10099 />
101100 </ Grid >
102- < Grid item xs = { 12 } md = { 4 } >
101+ < Grid item xs = { 12 } md = { 3 } mt = { 1 } >
103102 < Select
104103 displayEmpty = { true }
105104 renderValue = { ( value ) => ( value ? value : user ? user . role : 'Current Role' ) }
@@ -126,19 +125,18 @@ const AdminToolsUserManagement: React.FC = () => {
126125 ) ) }
127126 </ Select >
128127 </ Grid >
128+ < Grid item xs = { 12 } md = { 'auto' } mt = { - 1.5 } >
129+ < NERButton
130+ sx = { { mt : '20px' , float : 'right' } }
131+ variant = "contained"
132+ disabled = { isDisabled || ! user }
133+ onClick = { handleClick }
134+ >
135+ Confirm
136+ </ NERButton >
137+ </ Grid >
129138 </ Grid >
130- < NERButton
131- sx = { { mt : '20px' , float : 'right' } }
132- variant = "contained"
133- disabled = { isDisabled || ! user }
134- onClick = { handleClick }
135- >
136- Confirm
137- </ NERButton >
138- < Typography hidden = { hideSuccessLabel } style = { { color : theme . palette . primary . main , marginTop : '20px' } } >
139- Successfully Updated User
140- </ Typography >
141- </ PageBlock >
139+ </ Box >
142140 ) ;
143141} ;
144142
0 commit comments