import React from 'react'; import { FastField } from 'formik'; import { Alignment, Navbar, NavbarGroup, NavbarDivider, } from '@blueprintjs/core'; import { useFeatureCan } from 'hooks/state'; import { Icon, FormattedMessage as T, CustomSelectList, FeatureCan, } from 'components'; import { useInvoiceFormContext } from './InvoiceFormProvider'; import { Features } from 'common'; export default function InvoiceFormTopBar() { const { warehouses, branches } = useInvoiceFormContext(); const { featureCan } = useFeatureCan(); // Can't display the navigation bar if warehouses or branches feature is not enabled. if (!featureCan(Features.Warehouses) || !featureCan(Features.Branches)) { return null; } return ( {({ form, field: { value }, meta: { error, touched } }) => ( { form.setFieldValue('branch_id', id); }} selectedItemId={value} buttonProps={{ icon: , }} /> )} {featureCan(Features.Warehouses) && featureCan(Features.Branches) && ( )} {({ form, field: { value }, meta: { error, touched } }) => ( { form.setFieldValue('warehouse_id', id); }} selectedItemId={value} buttonProps={{ icon: , }} /> )} ); }