Contribute page imporvements, minor site imporvements

This commit is contained in:
mrfry 2020-11-28 16:46:56 +01:00
parent c68a445117
commit cc3def0e6f
9 changed files with 78 additions and 138 deletions

View file

@ -3,9 +3,8 @@ import React from 'react'
import styles from './todoCard.module.css' import styles from './todoCard.module.css'
export default function TodoCard(props) { export default function TodoCard(props) {
const { categories, type, onClick, userId, clickableTypes } = props const { categories, onClick, userId, clickable } = props
const { name, description, category, points, votes, id } = props.cardData const { name, description, category, points, votes, id } = props.cardData
const clickable = clickableTypes.includes(type)
const voted = votes.includes(userId) const voted = votes.includes(userId)
return ( return (

View file

@ -1,90 +1,35 @@
import React, { useState, useEffect } from 'react' import React from 'react'
import LoadingIndicator from '../LoadingIndicator.js' import TodoRow from './todoRow.js'
import TodoCard from './todoCard.js'
import constants from '../../constants.json'
import styles from './todoTable.module.css' import styles from './todoTable.module.css'
export default function TodoTable() { export default function TodoBoard(props) {
const [cards, setCards] = useState(null) const { tables, cards, userId, categories } = props
const [columns, setColumns] = 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) => {
setCards(
data.todos.cards.sort((a, b) => {
return b.votes.length - a.votes.length
})
)
setColumns(data.todos.columns)
setCategories(data.todos.categories)
setUserId(data.userId)
}
const onCardClick = (id) => {
fetch(`${constants.apiUrl}todos?id=${id}`, {
credentials: 'include',
})
.then((resp) => {
return resp.json()
})
.then((data) => {
setTodos(data)
})
}
if (!cards || !columns || !categories) {
return <LoadingIndicator />
}
return ( return (
<div className={styles.tableContainer}> <div className={styles.tableContainer}>
<div className={styles.table}> <div className={styles.table}>
{Object.keys(columns).map((key) => { {Object.keys(tables).map((key) => {
const category = columns[key] const table = tables[key]
const tableCards = cards.filter((card) => {
return card.state === key
})
return ( return (
<div className={styles.tableCol} key={key}> <div className={styles.container} key={key}>
<div className={styles.categoryName}>{category.name}</div> <div className={styles.title}>{table.name}</div>
{cards.map((card, i) => { {tableCards.map((card, i) => {
if (card.state === key) { return (
return ( <TodoRow
<TodoCard key={i}
key={i} type={key}
type={key} rowData={card}
cardData={card} userId={userId}
userId={userId} categories={categories}
categories={categories} />
onClick={onCardClick} )
clickableTypes={Object.keys(columns).reduce(
(acc, key) => {
const col = columns[key]
if (col.clickable) {
acc.push(key)
}
return acc
},
[]
)}
/>
)
} else {
return null
}
})} })}
</div> </div>
) )

View file

@ -1,23 +1,17 @@
.table {
display: flex;
min-width: 800px;
max-height: 600px;
}
.categoryName {
text-align: center;
margin: 5px 0px;
font-size: 16px;
font-weight: bold;
color: white;
white-space: nowrap;
}
.tableCol {
flex: 1;
}
.tableContainer { .tableContainer {
overflow-x: scroll; margin: 5px 0px;
overflow-y: scroll; }
.table {
justify-content: center;
}
.container {
flex-direction: column;
}
.title {
text-align: center;
font-size: 20px;
font-weight: bold;
} }

View file

@ -10,5 +10,13 @@
"data": { "data": {
"href": "/data.json", "href": "/data.json",
"text": "Összes kérdés JSON" "text": "Összes kérdés JSON"
},
"irc": {
"href": "/irc",
"text": "IRC chat"
},
"dataeditor": {
"href": "/dataeditor",
"text": "Dataeditor"
} }
} }

View file

@ -25,7 +25,7 @@
}, },
"contribute": { "contribute": {
"href": "/contribute", "href": "/contribute",
"text": "Contribute / Todos" "text": "Todos, contribute"
}, },
"ranklist": { "ranklist": {
"href": "/ranklist", "href": "/ranklist",

View file

@ -1,8 +1,8 @@
import React, { useState } from 'react' import React, { useState } from 'react'
import Button from '../components/Button.js'
import Sleep from '../components/sleep' import Sleep from '../components/sleep'
import TodoTable from '../components/todoStuff/todoTable' import Todos from '../components/todoStuff/todos'
import Button from '../components/Button.js'
import constants from '../constants.json' import constants from '../constants.json'
import styles from './contribute.module.css' import styles from './contribute.module.css'
@ -68,39 +68,26 @@ export default function contribute() {
annál nehezebb a feladat. Tartsd egeret kártyán részletesebb leírásért annál nehezebb a feladat. Tartsd egeret kártyán részletesebb leírásért
(ha van hozzá) (ha van hozzá)
</div> </div>
<TodoTable /> <Todos />
<div className={styles.description}>Itt írhatsz todo-ra ötleteket </div> <div className={styles.description}>Itt írhatsz todo-ra ötleteket </div>
{renderNewTaskArea()} {renderNewTaskArea()}
<Sleep /> <Sleep />
<hr /> <hr />
<div className={styles.description}> <div className={styles.title}>Git repos</div>
Csak álnévvel commitolj git repókhoz! <hr />
</div> <hr />
<div className={styles.repos}> <div className={styles.repos}>
<div>Git repo links</div> <ul>
{Object.keys(repos.repos).map((key) => { {Object.keys(repos.repos).map((key) => {
let repo = repos.repos[key] let repo = repos.repos[key]
return ( return (
<div key={key}> <li key={key}>
<a href={repo.href}>{repo.description}</a> <a href={repo.href}>{repo.description}</a>
</div> </li>
) )
})} })}
</ul>
</div> </div>
<hr />
<div className={styles.description}>
IRC chat: egy IRC chatszoba van létrehozva egy random szerveren, ahol
tudsz azonnal üzenni, és ha épp fent vagyok akkor azonnal válaszolok
</div>
<Button text="IRC chat" href="/irc" />
<hr />
<div className={styles.description}>
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!
</div>
<Button text="Data Editor" href="/dataeditor" />
</div> </div>
) )
} }

View file

@ -1,9 +1,3 @@
.repos {
display: flex;
flex-direction: column;
align-items: center;
}
.description { .description {
font-size: 15px; font-size: 15px;
color: white; color: white;
@ -39,3 +33,9 @@
.inputArea { .inputArea {
display: flex; display: flex;
} }
.title {
color: #9999ff;
font-size: 30px;
text-align: center;
}

View file

@ -163,6 +163,7 @@ export default function Index({ router }) {
{renderMotd()} {renderMotd()}
{userSpecificMotd && renderUserSpecificMotd()} {userSpecificMotd && renderUserSpecificMotd()}
<hr /> <hr />
<hr />
<Sleep /> <Sleep />
{renderNews()} {renderNews()}
</div> </div>

View file

@ -7,10 +7,11 @@
color: white; color: white;
background-color: #303030; background-color: #303030;
margin: 2px; margin: 2px;
padding: 15px 32px; padding: 10px 5px;
text-align: center; text-align: center;
font-size: 16px; font-size: 16px;
cursor: pointer; cursor: pointer;
word-wrap: break-word;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -69,3 +70,8 @@
margin: 0px 5px; margin: 0px 5px;
font-size: 24px; font-size: 24px;
} }
.repos {
display: flex;
flex-direction: column;
}