mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 06:10:31 +00:00
re-structure to monorepo.
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
// @ts-nocheck
|
||||
import intl from 'react-intl-universal';
|
||||
import { RESOURCES_TYPES } from '@/constants/resourcesTypes';
|
||||
import { AbilitySubject, ManualJournalAction } from '@/constants/abilityOption';
|
||||
import withDrawerActions from '@/containers/Drawer/withDrawerActions';
|
||||
|
||||
/**
|
||||
* Universal search manual journal item select action.
|
||||
*/
|
||||
function JournalUniversalSearchSelectComponent({
|
||||
// #ownProps
|
||||
resourceType,
|
||||
resourceId,
|
||||
onAction,
|
||||
|
||||
// #withDrawerActions
|
||||
openDrawer,
|
||||
}) {
|
||||
if (resourceType === RESOURCES_TYPES.MANUAL_JOURNAL) {
|
||||
openDrawer('journal-drawer', { manualJournalId: resourceId });
|
||||
onAction && onAction();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export const JournalUniversalSearchSelectAction = withDrawerActions(
|
||||
JournalUniversalSearchSelectComponent,
|
||||
);
|
||||
|
||||
/**
|
||||
* Mappes the manual journal item to search item.
|
||||
*/
|
||||
const manualJournalsToSearch = (manualJournal) => ({
|
||||
id: manualJournal.id,
|
||||
text: manualJournal.journal_number,
|
||||
subText: manualJournal.formatted_date,
|
||||
label: manualJournal.formatted_amount,
|
||||
reference: manualJournal,
|
||||
});
|
||||
|
||||
/**
|
||||
* Binds universal search invoice configure.
|
||||
*/
|
||||
export const universalSearchJournalBind = () => ({
|
||||
resourceType: RESOURCES_TYPES.MANUAL_JOURNAL,
|
||||
optionItemLabel: intl.get('manual_journals'),
|
||||
selectItemAction: JournalUniversalSearchSelectAction,
|
||||
itemSelect: manualJournalsToSearch,
|
||||
permission: {
|
||||
ability: ManualJournalAction.View,
|
||||
subject: AbilitySubject.ManualJournal,
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user