on master help sign in
update invites store to show point details
0000e51Liam Fitzgerald
src/store/lib/useInvitesStore.js+15
@@ -1,6 +1,7 @@
1import { useCallback } from 'react';
1import { useCallback } from 'react';
2import { Just, Nothing } from 'folktale/maybe';
2import { Just, Nothing } from 'folktale/maybe';
3import * as azimuth from 'azimuth-js';
3import * as azimuth from 'azimuth-js';
4+import { chain } from 'lodash';
4
5
5import { useNetwork } from '../network';
6import { useNetwork } from '../network';
6import useSetState from 'lib/useSetState';
7import useSetState from 'lib/useSetState';
@@ -10,6 +11,8 @@ const EMPTY_INVITES = {
10 availableInvites: Nothing(),
11 availableInvites: Nothing(),
11 sentInvites: Nothing(),
12 sentInvites: Nothing(),
12 acceptedInvites: Nothing(),
13 acceptedInvites: Nothing(),
14+ acceptedPoints: Nothing(),
15+ pendingPoints: Nothing(),
13};
16};
14
17
15export default function useInvitesStore() {
18export default function useInvitesStore() {
@@ -42,11 +45,23 @@ export default function useInvitesStore() {
42 const sentInvites = invitedPoints.length;
45 const sentInvites = invitedPoints.length;
43 const acceptedInvites = activity.filter(i => !!i).length;
46 const acceptedInvites = activity.filter(i => !!i).length;
44
47
48+ console.log(invitedPoints);
49+
50+ const [acceptedPoints, pendingPoints] = chain(invitedPoints)
51+ .zipWith(activity, (point, active) => ({
52+ point,
53+ active: !!active,
54+ }))
55+ .partition('active')
56+ .map(arr => arr.map(x => x.point));
57+
45 addToInvitesCache({
58 addToInvitesCache({
46 [point]: {
59 [point]: {
47 availableInvites: Just(availableInvites),
60 availableInvites: Just(availableInvites),
48 sentInvites: Just(sentInvites),
61 sentInvites: Just(sentInvites),
49 acceptedInvites: Just(acceptedInvites),
62 acceptedInvites: Just(acceptedInvites),
63+ pendingPoints: Just(pendingPoints),
64+ acceptedPoints: Just(acceptedPoints),
50 },
65 },
51 });
66 });
52 },
67 },