mirror of
https://github.com/actualbudget/actual.git
synced 2026-03-11 12:43:09 -05:00
37 lines
818 B
TypeScript
37 lines
818 B
TypeScript
import { useEffect } from 'react';
|
|
|
|
import {
|
|
getCommonPayees,
|
|
getPayees,
|
|
} from 'loot-core/client/queries/queriesSlice';
|
|
|
|
import { useAppSelector, useAppDispatch } from '../redux';
|
|
|
|
export function useCommonPayees() {
|
|
const dispatch = useAppDispatch();
|
|
const commonPayeesLoaded = useAppSelector(
|
|
state => state.queries.commonPayeesLoaded,
|
|
);
|
|
|
|
useEffect(() => {
|
|
if (!commonPayeesLoaded) {
|
|
dispatch(getCommonPayees());
|
|
}
|
|
}, []);
|
|
|
|
return useAppSelector(state => state.queries.commonPayees);
|
|
}
|
|
|
|
export function usePayees() {
|
|
const dispatch = useAppDispatch();
|
|
const payeesLoaded = useAppSelector(state => state.queries.payeesLoaded);
|
|
|
|
useEffect(() => {
|
|
if (!payeesLoaded) {
|
|
dispatch(getPayees());
|
|
}
|
|
}, []);
|
|
|
|
return useAppSelector(state => state.queries.payees);
|
|
}
|