mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
59 lines
1.4 KiB
TypeScript
59 lines
1.4 KiB
TypeScript
// @ts-nocheck
|
|
import React from 'react';
|
|
import { Alignment, NavbarGroup, Classes } from '@blueprintjs/core';
|
|
import { useSetPrimaryBranchToForm } from './utils';
|
|
import { useFeatureCan } from '@/hooks/state';
|
|
import { Features } from '@/constants';
|
|
import {
|
|
BranchSelect,
|
|
FeatureCan,
|
|
FormTopbar,
|
|
DetailsBarSkeletonBase,
|
|
FormBranchSelectButton,
|
|
} from '@/components';
|
|
import { useExpenseFormContext } from './ExpenseFormPageProvider';
|
|
|
|
/**
|
|
* Expenses form topbar.
|
|
* @returns
|
|
*/
|
|
export default function ExpenseFormTopBar() {
|
|
// Features guard.
|
|
const { featureCan } = useFeatureCan();
|
|
|
|
// Sets the primary branch to form.
|
|
useSetPrimaryBranchToForm();
|
|
|
|
// Can't display the navigation bar if branches feature is not enabled.
|
|
if (!featureCan(Features.Branches)) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<FormTopbar>
|
|
<NavbarGroup align={Alignment.LEFT}>
|
|
<FeatureCan feature={Features.Branches}>
|
|
<ExpenseFormSelectBranch />
|
|
</FeatureCan>
|
|
</NavbarGroup>
|
|
</FormTopbar>
|
|
);
|
|
}
|
|
|
|
function ExpenseFormSelectBranch() {
|
|
// Invoice form context.
|
|
const { branches, isBranchesLoading } = useExpenseFormContext();
|
|
|
|
return isBranchesLoading ? (
|
|
<DetailsBarSkeletonBase className={Classes.SKELETON} />
|
|
) : (
|
|
<BranchSelect
|
|
name={'branch_id'}
|
|
branches={branches}
|
|
input={FormBranchSelectButton}
|
|
popoverProps={{ minimal: true }}
|
|
fill={false}
|
|
/>
|
|
);
|
|
}
|