mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 14:20:31 +00:00
feat(inventory item & valuation): warehouse multi select.
This commit is contained in:
@@ -7,6 +7,7 @@ import { Tabs, Tab, Button, Intent } from '@blueprintjs/core';
|
||||
|
||||
import FinancialStatementHeader from 'containers/FinancialStatements/FinancialStatementHeader';
|
||||
import InventoryValuationHeaderGeneralPanel from './InventoryValuationHeaderGeneralPanel';
|
||||
import InventoryValuationHeaderDimensionsPanel from './InventoryValuationHeaderDimensionsPanel';
|
||||
import withInventoryValuation from './withInventoryValuation';
|
||||
import withInventoryValuationActions from './withInventoryValuationActions';
|
||||
|
||||
@@ -36,13 +37,18 @@ function InventoryValuationHeader({
|
||||
...pageFilter,
|
||||
asDate: moment().toDate(),
|
||||
itemsIds: [],
|
||||
warehousesIds: [],
|
||||
};
|
||||
// Initial values.
|
||||
const initialValues = transformToForm({
|
||||
...pageFilter,
|
||||
...defaultValues,
|
||||
asDate: moment(pageFilter.asDate).toDate(),
|
||||
}, defaultValues);
|
||||
const initialValues = transformToForm(
|
||||
{
|
||||
...pageFilter,
|
||||
...defaultValues,
|
||||
asDate: moment(pageFilter.asDate).toDate(),
|
||||
warehousesIds: [],
|
||||
},
|
||||
defaultValues,
|
||||
);
|
||||
|
||||
// Handle the form of header submit.
|
||||
const handleSubmit = (values, { setSubmitting }) => {
|
||||
@@ -78,6 +84,11 @@ function InventoryValuationHeader({
|
||||
title={<T id={'general'} />}
|
||||
panel={<InventoryValuationHeaderGeneralPanel />}
|
||||
/>
|
||||
<Tab
|
||||
id="dimensions"
|
||||
title={'Dimensions'}
|
||||
panel={<InventoryValuationHeaderDimensionsPanel />}
|
||||
/>
|
||||
</Tabs>
|
||||
<div class="financial-header-drawer__footer">
|
||||
<Button className={'mr1'} intent={Intent.PRIMARY} type={'submit'}>
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import { FormGroup, Classes } from '@blueprintjs/core';
|
||||
import { WarehouseMultiSelect, Row, Col } from 'components';
|
||||
import {
|
||||
InventoryValuationHeaderDimensionsProvider,
|
||||
useInventoryValuationHeaderDimensionsPanelContext,
|
||||
} from './InventoryValuationHeaderDimensionsPanelProvider';
|
||||
|
||||
/**
|
||||
* Inventory Valuation header dismension panel.
|
||||
* @returns
|
||||
*/
|
||||
export default function InventoryValuationHeaderDimensionsPanel() {
|
||||
return (
|
||||
<InventoryValuationHeaderDimensionsProvider>
|
||||
<InventoryValuationHeaderDimensionsPanelContent />
|
||||
</InventoryValuationHeaderDimensionsProvider>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inventory Valuation header dismension panel content.
|
||||
* @returns
|
||||
*/
|
||||
function InventoryValuationHeaderDimensionsPanelContent() {
|
||||
const { warehouses } = useInventoryValuationHeaderDimensionsPanelContext();
|
||||
|
||||
return (
|
||||
<Row>
|
||||
<Col xs={4}>
|
||||
<FormGroup
|
||||
label={intl.get('warehouses_multi_select.label')}
|
||||
className={Classes.FILL}
|
||||
>
|
||||
<WarehouseMultiSelect
|
||||
name={'warehousesIds'}
|
||||
warehouses={warehouses}
|
||||
/>
|
||||
</FormGroup>
|
||||
</Col>
|
||||
</Row>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
import React from 'react';
|
||||
|
||||
import { useWarehouses } from 'hooks/query';
|
||||
import { FinancialHeaderLoadingSkeleton } from '../FinancialHeaderLoadingSkeleton';
|
||||
|
||||
const InventoryValuationHeaderDimensionsPanelContext = React.createContext();
|
||||
|
||||
/**
|
||||
* Inventory valuation header provider.
|
||||
* @returns
|
||||
*/
|
||||
function InventoryValuationHeaderDimensionsProvider({ ...props }) {
|
||||
// Fetch warehouses list.
|
||||
const { data: warehouses, isLoading: isWarehouesLoading } = useWarehouses();
|
||||
|
||||
// Provider
|
||||
const provider = {
|
||||
warehouses,
|
||||
isWarehouesLoading,
|
||||
};
|
||||
|
||||
return isWarehouesLoading ? (
|
||||
<FinancialHeaderLoadingSkeleton />
|
||||
) : (
|
||||
<InventoryValuationHeaderDimensionsPanelContext.Provider
|
||||
value={provider}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
const useInventoryValuationHeaderDimensionsPanelContext = () =>
|
||||
React.useContext(InventoryValuationHeaderDimensionsPanelContext);
|
||||
|
||||
export {
|
||||
InventoryValuationHeaderDimensionsProvider,
|
||||
useInventoryValuationHeaderDimensionsPanelContext,
|
||||
};
|
||||
Reference in New Issue
Block a user