Example
Example
const statuses = [
{ id: 'todo', title: 'To Do', color: '#FF6347' },
{ id: 'progress', title: 'On Progress', color: '#FFA500' },
{ id: 'done', title: 'Done', color: '#32CD32' },
{ id: 'archived', title: 'Archived', color: '#A9A9A9' },
];
function App() {
// Data state
const [tasks, setTasks] = useState([]);
const [pics, setPics] = useState([]);
const [taskOptions, setTaskOptions] = useState([]);
// Form states
const [newTaskContent, setNewTaskContent] = useState('');
const [newTaskPic, setNewTaskPic] = useState('');
const [newTaskStatus, setNewTaskStatus] = useState('todo');
const [newTaskDetail, setNewTaskDetail] = useState('');
const updatedTask = {
...task,
status: newStatus,
timestamps: newTimestamps,
};
axios
.post(`${API_BASE_URL}/api/tasks/update`, updatedTask)
.catch((err) => console.error('Error updating task:', err));
};
try {
await axios.post(`${API_BASE_URL}/api/tasks`, newTask);
fetchData();
closeModal();
resetTaskForm();
} catch (error) {
alert('Failed to add task');
console.error(error);
}
};
// Modal component
const Modal = ({ children }) => (
<div
style={{
position: 'fixed',
top: 0, left: 0, right: 0, bottom: 0,
backgroundColor: 'rgba(0,0,0,0.5)',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
zIndex: 1000,
}}
onClick={closeModal}
>
<div
style={{
backgroundColor: 'white',
padding: 20,
borderRadius: 8,
minWidth: 320,
maxWidth: '90%',
boxShadow: '0 2px 10px rgba(0,0,0,0.3)',
}}
onClick={(e) => e.stopPropagation()}
>
{children}
</div>
</div>
);
return (
<div>
{/* Navbar */}
<nav
style={{
backgroundColor: '#333',
color: 'white',
padding: '10px 20px',
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
}}
>
<div style={{ fontWeight: 'bold', fontSize: 20 }}>Kanban App</div>
<div>
<button
style={navButtonStyle}
onClick={() => setModalOpen('task')}
>
Add Task
</button>
<button
style={navButtonStyle}
onClick={() => setModalOpen('pic')}
>
Add PIC
</button>
<button
style={navButtonStyle}
onClick={() => setModalOpen('activity')}
>
Add Activity
</button>
</div>
</nav>
const navButtonStyle = {
backgroundColor: '#555',
color: 'white',
border: 'none',
padding: '8px 12px',
marginLeft: 10,
borderRadius: 4,
cursor: 'pointer',
};