// @ts-nocheck import React from 'react'; import moment from 'moment'; import styled from 'styled-components'; import { Formik, Form } from 'formik'; import { Tabs, Tab, Button, Intent } from '@blueprintjs/core'; import { FormattedMessage as T } from '@/components'; import FinancialStatementHeader from '@/containers/FinancialStatements/FinancialStatementHeader'; import InventoryValuationHeaderGeneralPanel from './InventoryValuationHeaderGeneralPanel'; import InventoryValuationHeaderDimensionsPanel from './InventoryValuationHeaderDimensionsPanel'; import withInventoryValuation from './withInventoryValuation'; import withInventoryValuationActions from './withInventoryValuationActions'; import { compose, transformToForm } from '@/utils'; import { useFeatureCan } from '@/hooks/state'; import { Features } from '@/constants'; import { getInventoryValuationQuery, getInventoryValuationQuerySchema, } from './utils'; /** * inventory valuation header. */ function InventoryValuationHeader({ // #ownProps pageFilter, onSubmitFilter, // #withInventoryValuation isFilterDrawerOpen, // #withInventoryValuationActions toggleInventoryValuationFilterDrawer, }) { // Form validation schema. const validationSchema = getInventoryValuationQuerySchema(); const defaultQuery = getInventoryValuationQuery(); // Initial values. const initialValues = transformToForm( { ...defaultQuery, ...pageFilter, asDate: moment(pageFilter.asDate).toDate(), }, defaultQuery, ); // Handle the form of header submit. const handleSubmit = (values, { setSubmitting }) => { onSubmitFilter(values); toggleInventoryValuationFilterDrawer(false); setSubmitting(false); }; // Handle drawer close action. const handleDrawerClose = () => { toggleInventoryValuationFilterDrawer(false); }; // Handle cancel button click. const handleCancelClick = () => { toggleInventoryValuationFilterDrawer(false); }; // Detarmines the given feature whether is enabled. const { featureCan } = useFeatureCan(); // Detarmine if these feature are enabled. const isBranchesFeatureCan = featureCan(Features.Branches); const isWarehousesFeatureCan = featureCan(Features.Warehouses); return (
} panel={} /> {(isBranchesFeatureCan || isWarehousesFeatureCan) && ( } panel={} /> )}
); } export default compose( withInventoryValuation(({ inventoryValuationDrawerFilter }) => ({ isFilterDrawerOpen: inventoryValuationDrawerFilter, })), withInventoryValuationActions, )(InventoryValuationHeader); const InventoryValuationDrawerHeader = styled(FinancialStatementHeader)` .bp4-drawer { max-height: 450px; } `;