- {Object.keys(columns).map((key) => {
- const category = columns[key]
+ {Object.keys(tables).map((key) => {
+ const table = tables[key]
+
+ const tableCards = cards.filter((card) => {
+ return card.state === key
+ })
+
return (
-
-
{category.name}
- {cards.map((card, i) => {
- if (card.state === key) {
- return (
-
- )
- } else {
- return null
- }
+
+
{table.name}
+ {tableCards.map((card, i) => {
+ return (
+
+ )
})}
)
diff --git a/src/components/todoStuff/todoTable.module.css b/src/components/todoStuff/todoTable.module.css
index 91625be..eecc804 100644
--- a/src/components/todoStuff/todoTable.module.css
+++ b/src/components/todoStuff/todoTable.module.css
@@ -1,16 +1,17 @@
-.table {
- display: flex;
-}
-
-.categoryName {
- text-align: center;
+.tableContainer {
margin: 5px 0px;
- font-size: 16px;
- font-weight: bold;
- color: white;
- white-space: nowrap;
}
-.tableCol {
- flex: 1;
+.table {
+ justify-content: center;
+}
+
+.container {
+ flex-direction: column;
+}
+
+.title {
+ text-align: center;
+ font-size: 20px;
+ font-weight: bold;
}
diff --git a/src/components/todoStuff/todos.js b/src/components/todoStuff/todos.js
new file mode 100644
index 0000000..27956bf
--- /dev/null
+++ b/src/components/todoStuff/todos.js
@@ -0,0 +1,107 @@
+import React, { useState, useEffect } from 'react'
+
+import LoadingIndicator from '../LoadingIndicator.js'
+import TodoBoard from './todoBoard.js'
+import TodoTable from './todoTable.js'
+
+import constants from '../../constants.json'
+
+const byVotes = (a, b) => {
+ return b.votes.length - a.votes.length
+}
+
+export default function Todos() {
+ const [loaded, setLoaded] = useState(false)
+ const [columns, setColumns] = useState(null)
+ const [boardCards, setBoardCards] = useState(null)
+ const [tables, setTables] = useState(null)
+ const [tableCards, setTableCards] = useState(null)
+ const [categories, setCategories] = useState(null)
+ const [userId, setUserId] = useState(null)
+
+ useEffect(() => {
+ console.info('Fetching todos')
+ fetch(`${constants.apiUrl}todos`, {
+ credentials: 'include',
+ })
+ .then((resp) => {
+ return resp.json()
+ })
+ .then((data) => {
+ setTodos(data)
+ })
+ }, [])
+
+ const setTodos = (data) => {
+ setCategories(data.todos.categories)
+ setUserId(data.userId)
+
+ let bCards = []
+ let tCards = []
+ data.todos.cards.forEach((card) => {
+ if (data.todos.columns[card.state].type === 'table') {
+ tCards.push(card)
+ } else {
+ bCards.push(card)
+ }
+ })
+
+ setTableCards(tCards.sort(byVotes))
+ setBoardCards(bCards.sort(byVotes))
+
+ let cols = {}
+ let tables = {}
+ Object.keys(data.todos.columns).forEach((key) => {
+ const col = data.todos.columns[key]
+ if (col.type !== 'table') {
+ cols = {
+ ...cols,
+ [key]: col,
+ }
+ } else {
+ tables = {
+ ...tables,
+ [key]: col,
+ }
+ }
+ })
+ setColumns(cols)
+ setTables(tables)
+
+ setLoaded(true)
+ }
+
+ const onCardClick = (id) => {
+ fetch(`${constants.apiUrl}todos?id=${id}`, {
+ credentials: 'include',
+ })
+ .then((resp) => {
+ return resp.json()
+ })
+ .then((data) => {
+ setTodos(data)
+ })
+ }
+
+ if (!loaded) {
+ return
+ }
+
+ return (
+
+
+
+
+ )
+}
diff --git a/src/data/links.json b/src/data/links.json
index 2f5c064..d5e8e08 100644
--- a/src/data/links.json
+++ b/src/data/links.json
@@ -10,5 +10,13 @@
"data": {
"href": "/data.json",
"text": "Összes kérdés JSON"
+ },
+ "irc": {
+ "href": "/irc",
+ "text": "IRC chat"
+ },
+ "dataeditor": {
+ "href": "/dataeditor",
+ "text": "Dataeditor"
}
}
diff --git a/src/data/tabs.json b/src/data/tabs.json
index 1b08897..5179dbe 100644
--- a/src/data/tabs.json
+++ b/src/data/tabs.json
@@ -25,7 +25,7 @@
},
"contribute": {
"href": "/contribute",
- "text": "Contribute / Todos"
+ "text": "Todos, contribute"
},
"ranklist": {
"href": "/ranklist",
diff --git a/src/pages/contribute.js b/src/pages/contribute.js
index db67079..8c195f2 100644
--- a/src/pages/contribute.js
+++ b/src/pages/contribute.js
@@ -1,9 +1,8 @@
import React, { useState } from 'react'
import Head from 'next/head'
-import Button from '../components/Button.js'
import Sleep from '../components/sleep'
-import TodoTable from '../components/todoStuff/todoTable'
+import Todos from '../components/todoStuff/todos'
import constants from '../constants.json'
import styles from './contribute.module.css'
@@ -72,39 +71,26 @@ export default function contribute() {
annál nehezebb a feladat. Tartsd egeret kártyán részletesebb leírásért
(ha van hozzá)
- IRC chat: egy IRC chatszoba van létrehozva egy random szerveren, ahol
- tudsz azonnal üzenni, és ha épp fent vagyok akkor azonnal válaszolok
-
- Kérdés szerkesztő: Ezen az oldalon lehet szerkeszteni az összes kérdést,
- duplikációkat eltávolítani vagy helytelen válaszokat kijavítani kézzel.
- Ha van hozzá jelszavad, akkor ezt azonnal el tudod menteni, ha nincs és
- úgy érzed szeretnél akkor kattints a fenti IRC chat gombra!
-