Skip to content

Commit 391e443

Browse files
authored
Clean unnecessary comments and variables (#28)
1 parent 2345997 commit 391e443

File tree

3 files changed

+10
-38
lines changed

3 files changed

+10
-38
lines changed

frontend/src/components/dashboard/AdminView.js

+9-10
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default function AdminView() {
3636
password: '',
3737
isAdmin: false,
3838
});
39-
const [error, setError] = useState(''); // Hata mesajı için state
39+
const [error, setError] = useState('');
4040

4141
useEffect(() => {
4242
fetchUsers();
@@ -46,7 +46,7 @@ export default function AdminView() {
4646
try {
4747
const response = await axios.get('http://localhost:8080/adminView/users', {
4848
headers: {
49-
Authorization: `Bearer ${localStorage.getItem('token')}`, // Attach the token to the Authorization header
49+
Authorization: `Bearer ${localStorage.getItem('token')}`,
5050
}});
5151
setUsers(response.data);
5252
} catch (error) {
@@ -64,7 +64,7 @@ export default function AdminView() {
6464
password: '',
6565
isAdmin: false,
6666
});
67-
setError(''); // Modal kapandığında hatayı temizle
67+
setError('');
6868
};
6969

7070
const handleChange = (e) => {
@@ -80,22 +80,21 @@ export default function AdminView() {
8080
};
8181

8282
const handleSave = async () => {
83-
// E-posta validasyonunu kontrol et
8483
if (!validateEmail(selectedUser.email)) {
85-
setError('Invalid email address'); // Hata mesajını set et
84+
setError('Invalid email address');
8685
return;
8786
}
8887

8988
try {
9089
if (editMode) {
9190
await axios.put(`http://localhost:8080/adminView/users/${selectedUser.id}`, selectedUser, {
9291
headers: {
93-
Authorization: `Bearer ${localStorage.getItem('token')}`, // Attach the token to the Authorization header
92+
Authorization: `Bearer ${localStorage.getItem('token')}`,
9493
}});
9594
} else {
9695
await axios.post('http://localhost:8080/adminView/users', selectedUser, {
9796
headers: {
98-
Authorization: `Bearer ${localStorage.getItem('token')}`, // Attach the token to the Authorization header
97+
Authorization: `Bearer ${localStorage.getItem('token')}`,
9998
}});
10099
}
101100
fetchUsers();
@@ -120,7 +119,7 @@ export default function AdminView() {
120119
try {
121120
await axios.delete(`http://localhost:8080/adminView/users/${id}`, {
122121
headers: {
123-
Authorization: `Bearer ${localStorage.getItem('token')}`, // Attach the token to the Authorization header
122+
Authorization: `Bearer ${localStorage.getItem('token')}`,
124123
}});
125124
fetchUsers();
126125
} catch (error) {
@@ -180,15 +179,15 @@ export default function AdminView() {
180179
<Typography variant="h6" component="h2" gutterBottom>
181180
{editMode ? 'Edit User' : 'Add User'}
182181
</Typography>
183-
{error && <Typography color="error" gutterBottom>{error}</Typography>} {/* Hata mesajını göster */}
182+
{error && <Typography color="error" gutterBottom>{error}</Typography>} {}
184183
<TextField
185184
label="Email"
186185
name="email"
187186
value={selectedUser.email}
188187
onChange={handleChange}
189188
fullWidth
190189
sx={{ marginBottom: 2 }}
191-
error={Boolean(error)} // TextField üzerinde hata olduğunda kırmızı çizgi göstermek için
190+
error={Boolean(error)}
192191
/>
193192
<TextField
194193
label="Password"

frontend/src/components/dashboard/Dashboard.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import Paper from '@mui/material/Paper';
1616
import Link from '@mui/material/Link';
1717
import MenuIcon from '@mui/icons-material/Menu';
1818
import ChevronLeftIcon from '@mui/icons-material/ChevronLeft';
19-
import { mainListItems, secondaryListItems } from './listItems';
19+
import { mainListItems} from './listItems';
2020
import TrackingHistory from '../trackingHistory/TrackingHistory';
2121
import DefectConfig from '../defectConfig/DefectConfig';
2222
import AdminView from './AdminView';
@@ -144,7 +144,6 @@ export default function Dashboard({ view, onLogout }) {
144144
<List component="nav">
145145
{mainListItems}
146146
<Divider sx={{ my: 1 }} />
147-
{secondaryListItems}
148147
</List>
149148
</Drawer>
150149
<Box

frontend/src/components/dashboard/listItems.js

-26
Original file line numberDiff line numberDiff line change
@@ -37,30 +37,4 @@ export const mainListItems = (
3737
<ListItemText primary="Test" />
3838
</ListItemButton>
3939
</React.Fragment>
40-
);
41-
42-
export const secondaryListItems = (
43-
<React.Fragment>
44-
<ListSubheader component="div" inset>
45-
Saved reports
46-
</ListSubheader>
47-
<ListItemButton>
48-
<ListItemIcon>
49-
<AssignmentIcon />
50-
</ListItemIcon>
51-
<ListItemText primary="Current month" />
52-
</ListItemButton>
53-
<ListItemButton>
54-
<ListItemIcon>
55-
<AssignmentIcon />
56-
</ListItemIcon>
57-
<ListItemText primary="Last test" />
58-
</ListItemButton>
59-
<ListItemButton>
60-
<ListItemIcon>
61-
<AssignmentIcon />
62-
</ListItemIcon>
63-
<ListItemText primary="Year-end sale" />
64-
</ListItemButton>
65-
</React.Fragment>
6640
);

0 commit comments

Comments
 (0)