Skip to content

Commit

Permalink
Fix enabled filters on mount
Browse files Browse the repository at this point in the history
Signed-off-by: Tomás Castillo <[email protected]>
  • Loading branch information
tomrndom committed Jul 24, 2024
1 parent a53830d commit 8bdb582
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions src/pages/orders/purchase-order-list-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ import { getPurchaseOrders } from "../../actions/order-actions";
import QrReaderInput from "../../components/inputs/qr-reader-input";
import { getTicket } from "../../actions/ticket-actions";
import { handleDDLSortByLabel } from "../../utils/methods";
import { DATE_FILTER_ARRAY_SIZE } from "../../utils/constants";
import {
DATE_FILTER_ARRAY_SIZE,
DEFAULT_CURRENT_PAGE,
DEFAULT_PER_PAGE
} from "../../utils/constants";

const defaultFilters = {
amount_paid_filter: null,
Expand Down Expand Up @@ -59,18 +63,28 @@ class PurchaseOrderListPage extends React.Component {
}

componentDidMount() {
const {
currentSummit,
term,
currentPage,
perPage,
order,
orderDir,
filters,
getPurchaseOrders
} = this.props;
const { currentSummit, term, order, orderDir, filters, getPurchaseOrders } =
this.props;
if (currentSummit) {
getPurchaseOrders(term, currentPage, perPage, order, orderDir, filters);
const { purchaseOrderFilters } = this.state;
const enabledFilters = Object.keys(filters).filter((e) =>
Array.isArray(filters[e])
? filters[e]?.some((e) => e !== null && e !== 0)
: filters[e]?.length > 0
);
this.setState((prevState) => ({
...prevState,
enabledFilters,
purchaseOrderFilters: { ...purchaseOrderFilters, ...filters }
}));
getPurchaseOrders(
term,
DEFAULT_CURRENT_PAGE,
DEFAULT_PER_PAGE,
order,
orderDir,
filters
);
}
}

Expand Down

0 comments on commit 8bdb582

Please sign in to comment.