mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-24 00:29:49 +00:00
48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
// @ts-nocheck
|
|
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.drawer.title', {
|
|
number: manualJournal?.journal_number,
|
|
})}
|
|
/>
|
|
<ManualJournalDrawerContext.Provider value={provider} {...props} />
|
|
</DrawerLoading>
|
|
);
|
|
}
|
|
|
|
const useManualJournalDrawerContext = () =>
|
|
React.useContext(ManualJournalDrawerContext);
|
|
|
|
export { ManualJournalDrawerProvider, useManualJournalDrawerContext };
|