Pagina admin con creazione problemi e pagina utente personale
This commit is contained in:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user