diff --git a/ReactLearning/kanban-board/src/App.tsx b/ReactLearning/kanban-board/src/App.tsx
index 2c44adf..21d1361 100644
--- a/ReactLearning/kanban-board/src/App.tsx
+++ b/ReactLearning/kanban-board/src/App.tsx
@@ -1,36 +1,45 @@
import React from "react";
-import { useState } from "react";
import KBColumn from "./components/KBColumn";
import "./App.css";
import Header from "./components/Header";
+import Task from "./types/Task"
+
type Column = {
id: number;
name: string;
color: string;
+ tasks: Task[];
};
+
+
type State = {
columns: Column[];
- iterator: number;
+ columnIterator: number;
+ taskIterator: number;
};
class App extends React.Component<{}, State> {
constructor(props: any) {
super(props);
this.deleteColumn = this.deleteColumn.bind(this);
- this.addColumn = this.addColumn.bind(this)
+ this.addColumn = this.addColumn.bind(this);
+ this.addTask = this.addTask.bind(this);
this.state = {
- iterator: 3,
+ taskIterator: 1,
+ columnIterator: 3,
columns: [
{
id: 1,
name: "Harry",
color: "green",
+ tasks: []
},
{
id: 2,
name: "Potter",
color: "red",
+ tasks: []
},
],
};
@@ -42,20 +51,37 @@ class App extends React.Component<{}, State> {
this.setState({ columns: filteredColumns });
console.log(this.state.columns);
}
+
addColumn() {
- let columnId = this.state.iterator;
- this.setState({ iterator: columnId + 1 });
+ let columnId = this.state.columnIterator;
+ this.setState({ columnIterator: columnId + 1 });
this.state.columns.push({
id: columnId,
name: "tempName" + columnId,
color: "red",
+ tasks: []
});
}
+ addTask(){
+
+ if (this.state.columns.length > 0){
+ let taskId = this.state.taskIterator;
+ this.setState({ taskIterator: taskId + 1})
+ this.state.columns[0].tasks.push(
+ { id: taskId,
+ title: "Task "+ taskId,
+ description: "foo",
+ priority: 'normal'
+ }
+ )
+ }
+ }
+
render() {
return (
-
+
{this.state.columns.map((column, index) => (
{
key={index}
onDelete={this.deleteColumn}
id={column.id}
+ tasks={column.tasks}
/>
))}
);
}
}
-
-export default App;
+export default App;
\ No newline at end of file
diff --git a/ReactLearning/kanban-board/src/components/Header.tsx b/ReactLearning/kanban-board/src/components/Header.tsx
index bb601e9..00572df 100644
--- a/ReactLearning/kanban-board/src/components/Header.tsx
+++ b/ReactLearning/kanban-board/src/components/Header.tsx
@@ -1,7 +1,8 @@
import * as react from 'react'
type HeaderProps = {
- addColumn: () => void
+ addColumn: () => void,
+ addTask: () => void
}
const Header = ( props: HeaderProps ) => {
@@ -9,7 +10,8 @@ const Header = ( props: HeaderProps ) => {
return(
-
+
Kango Bango
+
)
diff --git a/ReactLearning/kanban-board/src/components/KBColumn.tsx b/ReactLearning/kanban-board/src/components/KBColumn.tsx
index 17396fb..77b5e91 100644
--- a/ReactLearning/kanban-board/src/components/KBColumn.tsx
+++ b/ReactLearning/kanban-board/src/components/KBColumn.tsx
@@ -1,8 +1,9 @@
import * as react from "react";
+import Task from "../types/Task"
type KBColumnProps = {
color?: string;
title?: string;
- tasks?: string[];
+ tasks: Task[];
id: number;
onDelete?: (id: number) => void
};
@@ -17,7 +18,16 @@ const KBColumn = (props: KBColumnProps) => {
const { color, title, tasks, onDelete, id } = { ...defaultProps, ...props };
return (
-
{title}
+
{title}
+
+ {tasks.map((task) => (
+
+
{task.title}
+
+
{task.description}
+
+ ))}
+
);
diff --git a/ReactLearning/kanban-board/src/types/Task.ts b/ReactLearning/kanban-board/src/types/Task.ts
new file mode 100644
index 0000000..760d30c
--- /dev/null
+++ b/ReactLearning/kanban-board/src/types/Task.ts
@@ -0,0 +1,8 @@
+type Task = {
+ id: number,
+ title: string,
+ description: string,
+ priority: 'normal'|'important'|'urgent'
+ }
+
+export default Task
\ No newline at end of file