mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-24 00:29:49 +00:00
33 lines
841 B
TypeScript
33 lines
841 B
TypeScript
import React, { createContext, useContext } from 'react';
|
|
|
|
import { useAccounts } from '@/hooks/query';
|
|
import { FinancialHeaderLoadingSkeleton } from '../FinancialHeaderLoadingSkeleton';
|
|
|
|
const GLHeaderGeneralPanelContext = createContext();
|
|
|
|
/**
|
|
* General ledger provider.
|
|
*/
|
|
function GLHeaderGeneralPanelProvider({ ...props }) {
|
|
// Accounts list.
|
|
const { data: accounts, isLoading: isAccountsLoading } = useAccounts();
|
|
|
|
// Provider
|
|
const provider = {
|
|
accounts,
|
|
isAccountsLoading,
|
|
};
|
|
|
|
const loading = isAccountsLoading;
|
|
|
|
return loading ? (
|
|
<FinancialHeaderLoadingSkeleton />
|
|
) : (
|
|
<GLHeaderGeneralPanelContext.Provider value={provider} {...props} />
|
|
);
|
|
}
|
|
|
|
const useGLGeneralPanelContext = () => useContext(GLHeaderGeneralPanelContext);
|
|
|
|
export { GLHeaderGeneralPanelProvider, useGLGeneralPanelContext };
|