Me learning react like an absolute chungus
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
833B

  1. import * as react from "react";
  2. import Task from "../types/Task"
  3. type KBColumnProps = {
  4. color?: string;
  5. title?: string;
  6. tasks: Task[];
  7. id: number;
  8. onDelete?: (id: number) => void
  9. };
  10. const defaultProps: KBColumnProps = {
  11. color: "#00cc00",
  12. title: "waah",
  13. tasks: [],
  14. id: -1,
  15. onDelete: (id: number) => {}
  16. };
  17. const KBColumn = (props: KBColumnProps) => {
  18. const { color, title, tasks, onDelete, id } = { ...defaultProps, ...props };
  19. return (
  20. <div className="KBColumn" style={{ backgroundColor: color, height: 200 }}>
  21. <h3>{title}</h3>
  22. {tasks.map((task) => (
  23. <div>
  24. <p> {task.title} </p>
  25. <p> {task.description} </p>
  26. </div>
  27. ))}
  28. <button onClick={() => {onDelete && onDelete(id)}}>Deleete</button>
  29. </div>
  30. );
  31. };
  32. export default KBColumn;