mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 06:10:31 +00:00
fix(webapp): filter by customers, vendors and items in reports do not work
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
// @ts-nocheck
|
||||
import React from 'react';
|
||||
import * as Yup from 'yup';
|
||||
import moment from 'moment';
|
||||
import styled from 'styled-components';
|
||||
import { Formik, Form } from 'formik';
|
||||
@@ -17,6 +16,10 @@ 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.
|
||||
@@ -33,25 +36,17 @@ function InventoryValuationHeader({
|
||||
toggleInventoryValuationFilterDrawer,
|
||||
}) {
|
||||
// Form validation schema.
|
||||
const validationSchema = Yup.object().shape({
|
||||
asDate: Yup.date().required().label('asDate'),
|
||||
});
|
||||
const validationSchema = getInventoryValuationQuerySchema();
|
||||
const defaultQuery = getInventoryValuationQuery();
|
||||
|
||||
// Default values.
|
||||
const defaultValues = {
|
||||
...pageFilter,
|
||||
asDate: moment().toDate(),
|
||||
itemsIds: [],
|
||||
warehousesIds: [],
|
||||
};
|
||||
// Initial values.
|
||||
const initialValues = transformToForm(
|
||||
{
|
||||
...defaultValues,
|
||||
...defaultQuery,
|
||||
...pageFilter,
|
||||
asDate: moment(pageFilter.asDate).toDate(),
|
||||
},
|
||||
defaultValues,
|
||||
defaultQuery,
|
||||
);
|
||||
|
||||
// Handle the form of header submit.
|
||||
@@ -71,6 +66,7 @@ function InventoryValuationHeader({
|
||||
// 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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user