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