mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 06:10:31 +00:00
chrone: sperate client and server to different repos.
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import { useJournal } from 'hooks/query';
|
||||
import { DrawerLoading, DrawerHeaderContent } from 'components';
|
||||
|
||||
const ManualJournalDrawerContext = React.createContext();
|
||||
|
||||
/**
|
||||
* Manual journal drawer provider.
|
||||
*/
|
||||
function ManualJournalDrawerProvider({ manualJournalId, ...props }) {
|
||||
// Fetch the specific manual journal details.
|
||||
const {
|
||||
data: manualJournal,
|
||||
isLoading: isJournalLoading,
|
||||
isFetching: isJournalFetching,
|
||||
} = useJournal(manualJournalId, {
|
||||
enabled: !!manualJournalId,
|
||||
});
|
||||
|
||||
// Provider.
|
||||
const provider = {
|
||||
manualJournalId,
|
||||
manualJournal,
|
||||
|
||||
isJournalFetching,
|
||||
isJournalLoading,
|
||||
};
|
||||
|
||||
return (
|
||||
<DrawerLoading loading={isJournalLoading}>
|
||||
<DrawerHeaderContent
|
||||
name={'journal-drawer'}
|
||||
title={intl.get('manual_journal_number', {
|
||||
number: manualJournal?.journal_number,
|
||||
})}
|
||||
/>
|
||||
<ManualJournalDrawerContext.Provider value={provider} {...props} />
|
||||
</DrawerLoading>
|
||||
);
|
||||
}
|
||||
|
||||
const useManualJournalDrawerContext = () =>
|
||||
React.useContext(ManualJournalDrawerContext);
|
||||
|
||||
export { ManualJournalDrawerProvider, useManualJournalDrawerContext };
|
||||
Reference in New Issue
Block a user