Me learning react like an absolute chungus
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

84 рядки
1.7KB

  1. import Task from "../types/Task";
  2. import React from 'react';
  3. import { FaTimes } from 'react-icons/fa'
  4. type KBColumnProps = {
  5. color: string;
  6. title: string;
  7. tasks: Task[];
  8. id: number;
  9. onDelete?: (id: number) => void;
  10. deleteTask?: (cId: number, tId: number) => void;
  11. };
  12. let bgc = "hotpink";
  13. class KBColumn extends React.Component<KBColumnProps> {
  14. getTaskRender = () =>{
  15. return this.props.tasks.map((task) => {
  16. if (task.priority === "urgent") {
  17. bgc = "red";
  18. } else if (task.priority === "important") {
  19. bgc = "yellow";
  20. } else if (task.priority === "normal") {
  21. bgc = "blue";
  22. }
  23. return (
  24. <div
  25. style={{
  26. borderColor: "#ccc",
  27. borderWidth: "1px",
  28. borderStyle: "solid",
  29. margin: "10px",
  30. }}
  31. className="taskWrapper"
  32. >
  33. <div
  34. style={{ backgroundColor: bgc, display: "inline" }}
  35. className="prioBlock"
  36. title={task.priority}
  37. ></div>
  38. <div className="taskText">
  39. <h3> {task.title} </h3>
  40. <p> {task.description} </p>
  41. </div>
  42. <div className="actionBlock">
  43. <FaTimes style={{color: 'red', cursor: 'pointer'}} onClick={() => this.props.deleteTask && this.props.deleteTask(this.props.id, task.id)} />
  44. </div>
  45. </div>
  46. );
  47. });
  48. };
  49. render() {
  50. return (
  51. <div className="KBColumn" style={{ backgroundColor: this.props.color }}>
  52. <h3>{this.props.title} </h3>
  53. {this.getTaskRender()}
  54. <button
  55. onClick={() => {
  56. this.props.onDelete && this.props.onDelete(this.props.id);
  57. }}
  58. >
  59. Delete
  60. </button>
  61. </div>
  62. );
  63. }
  64. }
  65. export default KBColumn;