on b953e8e help sign in
bridge/src/store/lib/usePointStore.js
53 lines 1.5 kB history raw
1import { useCallback } from 'react';
3import useDetailsStore from './useDetailsStore';
4import useRekeyDateStore from './useRekeyDateStore';
5import useInvitesStore from './useInvitesStore';
6import useControlledPointsStore from './useControlledPointsStore';
7import useEclipticOwnerStore from './useEclipticOwnerStore';
8import useResidents from './useResidentsStore';
10export default function usePointStore() {
11 const { syncDetails, ...details } = useDetailsStore();
12 const { syncRekeyDate, ...rekeyDates } = useRekeyDateStore();
13 const { syncInvites, ...invites } = useInvitesStore();
14 const {
15 syncControlledPoints,
16 ...controlledPoints
17 } = useControlledPointsStore();
18 const { syncResidents, syncResidentCount, ...residents } = useResidents();
19 const ecliptic = useEclipticOwnerStore();
21 const syncDates = useCallback(
22 async point => Promise.all([syncRekeyDate(point)]),
23 [syncRekeyDate]
24 );
26 const syncExtras = useCallback(
27 async point =>
28 Promise.all([
29 syncDetails(point),
30 //
31 syncDates(point),
32 syncResidentCount(point),
33 syncInvites(point),
34 ]),
35 [syncDates, syncDetails, syncInvites, syncResidentCount]
36 );
38 return {
39 ...details,
40 ...rekeyDates,
41 ...invites,
42 ...controlledPoints,
43 ...ecliptic,
44 ...residents,
45 syncDetails,
46 syncRekeyDate,
47 syncInvites,
48 syncControlledPoints,
49 syncDates,
50 syncResidents,
51 syncExtras,
52 };