on 1cfc674 help sign in
bridge/src/store/lib/usePointStore.js
41 lines 1.2 kB history raw
1import { useCallback } from 'react';
3import useDetailsStore from './useDetailsStore';
4import useBirthdaysStore from './useBirthdaysStore';
5import useInvitesStore from './useInvitesStore';
6import useControlledPointsStore from './useControlledPointsStore';
8export default function usePointStore() {
9 const { syncDetails, ...details } = useDetailsStore();
10 const { syncBirthday, ...birthdays } = useBirthdaysStore();
11 const { syncInvites, ...invites } = useInvitesStore();
12 const {
13 syncControlledPoints,
14 ...controlledPoints
15 } = useControlledPointsStore();
17 // sync all of the on-chain info required to display a foreign point
18 const syncForeignPoint = useCallback(async point => Promise.all([]), []);
20 // sync all of the on-chain info required for a point that the user owns
21 const syncOwnedPoint = useCallback(
22 async point =>
23 Promise.all([
24 syncDetails(point),
25 syncBirthday(point),
26 syncInvites(point),
27 ]),
28 [syncDetails, syncBirthday, syncInvites]
29 );
31 return {
32 ...details,
33 ...birthdays,
34 ...invites,
35 ...controlledPoints,
36 syncInvites,
37 syncControlledPoints,
38 syncOwnedPoint,
39 syncForeignPoint,
40 };