Pagina admin con creazione problemi e pagina utente personale

This commit is contained in:
2022-11-09 02:49:54 +01:00
parent 484c21d606
commit 48d1b3b4ed
21 changed files with 633 additions and 299 deletions
+18
View File
@@ -112,6 +112,24 @@ export const getUser = (db, id) =>
// Problems
//
export const createProblem = (db, { content, createdBy }) =>
withDatabase(db, state => {
const nextId = (
Object.keys(state.problems)
.map(k => parseInt(k))
.reduce((acc, id) => Math.max(acc, id)) + 1
).toString()
state.problems[nextId] = {
id: nextId,
content,
createdBy,
createdAt: new Date().toJSON(),
}
return nextId
})
export const getProblem = (db, id) =>
withDatabase(db, state => {
return state.problems[id]