@@ -36,7 +36,7 @@ export default function AdminView() {
36
36
password : '' ,
37
37
isAdmin : false ,
38
38
} ) ;
39
- const [ error , setError ] = useState ( '' ) ; // Hata mesajı için state
39
+ const [ error , setError ] = useState ( '' ) ;
40
40
41
41
useEffect ( ( ) => {
42
42
fetchUsers ( ) ;
@@ -46,7 +46,7 @@ export default function AdminView() {
46
46
try {
47
47
const response = await axios . get ( 'http://localhost:8080/adminView/users' , {
48
48
headers : {
49
- Authorization : `Bearer ${ localStorage . getItem ( 'token' ) } ` , // Attach the token to the Authorization header
49
+ Authorization : `Bearer ${ localStorage . getItem ( 'token' ) } ` ,
50
50
} } ) ;
51
51
setUsers ( response . data ) ;
52
52
} catch ( error ) {
@@ -64,7 +64,7 @@ export default function AdminView() {
64
64
password : '' ,
65
65
isAdmin : false ,
66
66
} ) ;
67
- setError ( '' ) ; // Modal kapandığında hatayı temizle
67
+ setError ( '' ) ;
68
68
} ;
69
69
70
70
const handleChange = ( e ) => {
@@ -80,22 +80,21 @@ export default function AdminView() {
80
80
} ;
81
81
82
82
const handleSave = async ( ) => {
83
- // E-posta validasyonunu kontrol et
84
83
if ( ! validateEmail ( selectedUser . email ) ) {
85
- setError ( 'Invalid email address' ) ; // Hata mesajını set et
84
+ setError ( 'Invalid email address' ) ;
86
85
return ;
87
86
}
88
87
89
88
try {
90
89
if ( editMode ) {
91
90
await axios . put ( `http://localhost:8080/adminView/users/${ selectedUser . id } ` , selectedUser , {
92
91
headers : {
93
- Authorization : `Bearer ${ localStorage . getItem ( 'token' ) } ` , // Attach the token to the Authorization header
92
+ Authorization : `Bearer ${ localStorage . getItem ( 'token' ) } ` ,
94
93
} } ) ;
95
94
} else {
96
95
await axios . post ( 'http://localhost:8080/adminView/users' , selectedUser , {
97
96
headers : {
98
- Authorization : `Bearer ${ localStorage . getItem ( 'token' ) } ` , // Attach the token to the Authorization header
97
+ Authorization : `Bearer ${ localStorage . getItem ( 'token' ) } ` ,
99
98
} } ) ;
100
99
}
101
100
fetchUsers ( ) ;
@@ -120,7 +119,7 @@ export default function AdminView() {
120
119
try {
121
120
await axios . delete ( `http://localhost:8080/adminView/users/${ id } ` , {
122
121
headers : {
123
- Authorization : `Bearer ${ localStorage . getItem ( 'token' ) } ` , // Attach the token to the Authorization header
122
+ Authorization : `Bearer ${ localStorage . getItem ( 'token' ) } ` ,
124
123
} } ) ;
125
124
fetchUsers ( ) ;
126
125
} catch ( error ) {
@@ -180,15 +179,15 @@ export default function AdminView() {
180
179
< Typography variant = "h6" component = "h2" gutterBottom >
181
180
{ editMode ? 'Edit User' : 'Add User' }
182
181
</ Typography >
183
- { error && < Typography color = "error" gutterBottom > { error } </ Typography > } { /* Hata mesajını göster */ }
182
+ { error && < Typography color = "error" gutterBottom > { error } </ Typography > } { }
184
183
< TextField
185
184
label = "Email"
186
185
name = "email"
187
186
value = { selectedUser . email }
188
187
onChange = { handleChange }
189
188
fullWidth
190
189
sx = { { marginBottom : 2 } }
191
- error = { Boolean ( error ) } // TextField üzerinde hata olduğunda kırmızı çizgi göstermek için
190
+ error = { Boolean ( error ) }
192
191
/>
193
192
< TextField
194
193
label = "Password"
0 commit comments