Add ability to load user votes on frontend

This commit is contained in:
Jerko Steiner 2019-04-08 13:34:19 +08:00
parent e509c32f79
commit 65f1703089
4 changed files with 11 additions and 1 deletions

6
package-lock.json generated
View File

@ -4457,6 +4457,12 @@
"whatwg-url": "^7.0.0"
}
},
"date-fns": {
"version": "2.0.0-alpha.27",
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.0.0-alpha.27.tgz",
"integrity": "sha512-cqfVLS+346P/Mpj2RpDrBv0P4p2zZhWWvfY5fuWrXNR/K38HaAGEkeOwb47hIpQP9Jr/TIxjZ2/sNMQwdXuGMg==",
"dev": true
},
"date-now": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz",

View File

@ -40,6 +40,7 @@
"buildfile": "^1.2.22",
"bulma": "^0.7.4",
"cookie-parser": "^1.4.4",
"date-fns": "^2.0.0-alpha.27",
"deep-object-diff": "^1.1.0",
"history": "^4.9.0",
"jest": "^24.5.0",

View File

@ -137,6 +137,7 @@ export class CRUDReducer<
...state,
ids: [...state.ids, payload.id],
byId: {
...state.byId,
[payload.id]: payload,
},
status: {
@ -160,6 +161,7 @@ export class CRUDReducer<
}
handleRemove = (state: ICRUDState<T>, payload: T): ICRUDState<T> => {
// FIXME site does not get removed because payload looks different!
return {
...state,
ids: state.ids.filter(id => id !== payload.id),

View File

@ -3,7 +3,8 @@ export function without<T, R extends Record<string, T>, K extends keyof R>(
key: K,
): Pick<R, Exclude<keyof R, K>> {
return Object.keys(items).reduce((obj, k) => {
if (key === k) {
/* tslint:disable-next-line */
if (key == k) {
return obj
}
(obj as any)[k] = items[k]