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