Skip to content

Commit

Permalink
fix: show archived product categories
Browse files Browse the repository at this point in the history
  • Loading branch information
munkhsaikhan committed Mar 13, 2024
1 parent a5ddd7f commit ade8d51
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
Expand Up @@ -64,15 +64,15 @@ const generateFilter = async (
}

if (categoryId) {
const category = await models.ProductCategories.getProductCategory({
_id: categoryId,
status: { $in: [null, 'active'] },
});
const category = await models.ProductCategories.findOne({
_id: categoryId
}).lean();

const productCategoryIds = await models.ProductCategories.find(
const productCategoryIds = category ? await models.ProductCategories.find(
{ order: { $regex: new RegExp(`^${escapeRegExp(category.order)}`) } },
{ _id: 1 },
);
) : [];

filter.categoryId = { $in: productCategoryIds };
} else {
const notActiveCategories = await models.ProductCategories.find({
Expand Down Expand Up @@ -327,7 +327,7 @@ const productQueries = {
(similarityGroups[cm].rules || [])
.map((sg) => sg.fieldId)
.filter((sgf) => customFieldIds.includes(sgf)).length ===
(similarityGroups[cm].rules || []).length,
(similarityGroups[cm].rules || []).length,
);

if (!matchedMasks.length) {
Expand Down
Expand Up @@ -2,7 +2,6 @@ import React from 'react';
import { withRouter } from 'react-router-dom';

import Box from '@erxes/ui/src/components/Box';
import Icon from '@erxes/ui/src/components/Icon';
import { IRouterProps } from '@erxes/ui/src/types';
import { __, router } from '@erxes/ui/src/utils';
import { FieldStyle, SidebarList } from '@erxes/ui/src/layout/styles';
Expand All @@ -20,7 +19,7 @@ class CategoryStatusFilter extends React.Component<IProps> {

const onClick = (key, value) => {
router.setParams(history, { [key]: value });
router.setParams(history, { categoryId: null });
router.removeParams(history, 'categoryId');
};

return (
Expand Down
Expand Up @@ -93,7 +93,7 @@ class List extends React.Component<IProps> {
};

renderContent() {
const { productCategories, loading, queryParams } = this.props;
const { productCategories, loading, queryParams, history } = this.props;

return (
<CollapsibleList
Expand All @@ -104,7 +104,7 @@ class List extends React.Component<IProps> {
loading={loading}
onClick={this.onClick}
queryParams={queryParams}
treeView={true}
treeView={!['disabled', 'archived'].includes(router.getParam(history, ['status']))}
keyCount="productCount"
/>
);
Expand Down

0 comments on commit ade8d51

Please sign in to comment.