-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTaskManagement.jsx
More file actions
74 lines (68 loc) · 2.23 KB
/
Copy pathTaskManagement.jsx
File metadata and controls
74 lines (68 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// src/components/TaskManagement.jsx
import React, { useEffect, useState } from 'react';
import axios from 'axios';
import { Box, Button, Typography, TextField, Grid } from '@mui/material';
const TaskManagement = () => {
const [tasks, setTasks] = useState([]);
const [title, setTitle] = useState('');
const [assignedTo, setAssignedTo] = useState('');
const [status, setStatus] = useState('');
useEffect(() => {
axios.get('http://localhost:5000/api/tasks')
.then(response => setTasks(response.data))
.catch(err => console.error(err));
}, []);
const addTask = () => {
const newTask = { title, assignedTo, status, rating: 0 };
axios.post('http://localhost:5000/api/tasks', newTask)
.then(() => setTasks([...tasks, newTask]))
.catch(err => console.error(err));
};
return (
<Box>
<Typography variant="h5">Task Management</Typography>
<Grid container spacing={2}>
<Grid item xs={6}>
<TextField
label="Task Title"
variant="outlined"
fullWidth
value={title}
onChange={(e) => setTitle(e.target.value)}
/>
</Grid>
<Grid item xs={6}>
<TextField
label="Assigned To"
variant="outlined"
fullWidth
value={assignedTo}
onChange={(e) => setAssignedTo(e.target.value)}
/>
</Grid>
<Grid item xs={6}>
<TextField
label="Status"
variant="outlined"
fullWidth
value={status}
onChange={(e) => setStatus(e.target.value)}
/>
</Grid>
<Grid item xs={6}>
<Button onClick={addTask} variant="contained">Add Task</Button>
</Grid>
</Grid>
<Box sx={{ marginTop: 4 }}>
{tasks.map((task, index) => (
<Box key={index} sx={{ marginBottom: 2 }}>
<Typography variant="h6">{task.title}</Typography>
<Typography>Assigned to: {task.assignedTo}</Typography>
<Typography>Status: {task.status}</Typography>
</Box>
))}
</Box>
</Box>
);
};
export default TaskManagement;