Me learning react like an absolute chungus
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

103 rindas
2.7KB

  1. import Task from "../types/Task";
  2. import React from "react";
  3. import {
  4. FaTimes,
  5. FaLongArrowAltRight,
  6. FaLongArrowAltLeft,
  7. } from "react-icons/fa";
  8. type KBColumnProps = {
  9. color: string;
  10. title: string;
  11. tasks: Task[];
  12. id: number;
  13. onDelete?: (id: number) => void;
  14. progressTask?: (cId: number, tId: number) => void;
  15. regressTask?: (cId: number, tId: number) => void;
  16. deleteTask?: (cId: number, tId: number) => void;
  17. };
  18. let bgc = "hotpink";
  19. class KBColumn extends React.Component<KBColumnProps> {
  20. /* Creates the JSX for all the tasks in the tasks array
  21. @param None
  22. @return A JSX.Element[] containing each of the Divs for the task
  23. Bugs: None that I know of
  24. Last Edited: XXXX-XX-XX XX:XX
  25. */
  26. getTaskRender = () => {
  27. return this.props.tasks.map((task) => {
  28. if (task.priority === "urgent") {
  29. bgc = "red";
  30. } else if (task.priority === "important") {
  31. bgc = "yellow";
  32. } else if (task.priority === "normal") {
  33. bgc = "blue";
  34. }
  35. return (
  36. <div key={task.id} className="taskWrapper">
  37. <div
  38. style={{ backgroundColor: bgc, display: "inline" }}
  39. className="prioBlock"
  40. title={task.priority}
  41. ></div>
  42. <div className="taskText">
  43. <h3> {task.title} </h3>
  44. <p> {task.description} </p>
  45. </div>
  46. <div className="actionBlock">
  47. <FaTimes
  48. style={{ color: "red", cursor: "pointer" }}
  49. onClick={() =>
  50. this.props.deleteTask &&
  51. this.props.deleteTask(this.props.id, task.id)
  52. }
  53. />
  54. <FaLongArrowAltRight
  55. style={{ color: "red", cursor: "pointer", marginTop: "10px" }}
  56. onClick={() =>
  57. this.props.progressTask &&
  58. this.props.progressTask(this.props.id, task.id)
  59. }
  60. />
  61. <FaLongArrowAltLeft
  62. style={{ color: "red", cursor: "pointer", marginTop: "10px" }}
  63. onClick={() =>
  64. this.props.regressTask &&
  65. this.props.regressTask(this.props.id, task.id)
  66. }
  67. />
  68. </div>
  69. </div>
  70. );
  71. });
  72. };
  73. render() {
  74. return (
  75. <div
  76. className="KBColumn"
  77. style={{ backgroundColor: this.props.color }}
  78. key={this.props.id}
  79. >
  80. <h3>{this.props.title} </h3>
  81. {this.getTaskRender()}
  82. <button
  83. onClick={() => {
  84. this.props.onDelete && this.props.onDelete(this.props.id);
  85. }}
  86. >
  87. Delete Column
  88. </button>
  89. </div>
  90. );
  91. }
  92. }
  93. export default KBColumn;