Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: show product not found in products table #167

Merged
merged 3 commits into from
Jan 19, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 46 additions & 9 deletions imports/plugins/included/product-variant/components/productGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,24 @@ const styles = (theme) => ({
tableBody: {
"& tr:nth-child(odd)": {
backgroundColor: theme.palette.colors.black02
},
"& td": {
borderBottom: "none",
letterSpacing: "0.28px",
padding: 0,
color: theme.palette.colors.coolGrey500
},
"& td:first-child": {
padding: "4px",
width: "50px"
},
"& td:nth-child(2)": {
width: "60px"
}
},
textNotFound: {
textAlign: "right"
},
tableHead: {
"& tr th": {
borderBottom: "none",
Expand Down Expand Up @@ -192,6 +208,35 @@ class ProductGrid extends Component {
);
}

/**
* Render the not found component
* @access protected
* @returns {Node} React node containing the `NotFound` component.
*/
renderNotFound() {
const { classes } = this.props;

return (
<TableRow className={`product-table-row-item`}>
<TableCell>
</TableCell>
<TableCell>
</TableCell>
<TableCell>
</TableCell>
<TableCell className={classes.textNotFound}>
<Components.Translation defaultValue="No Products Found" i18nKey="app.noProductsFound" />
</TableCell>
<TableCell>
</TableCell>
<TableCell>
</TableCell>
<TableCell>
</TableCell>
</TableRow>
);
}

renderProductGridItems() {
const { productMediaById, products } = this.props;
const { classes, ...notClasses } = this.props;
Expand All @@ -208,15 +253,7 @@ class ProductGrid extends Component {
));
}

return (
<div className="row">
<div className="text-center">
<h3>
<Components.Translation defaultValue="No Products Found" i18nKey="app.noProductsFound" />
</h3>
</div>
</div>
);
return this.renderNotFound();
}

handleDisplayTagSelector = () => {
Expand Down
25 changes: 0 additions & 25 deletions imports/plugins/included/product-variant/components/products.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,21 +101,6 @@ class Products extends Component {
return null;
}

/**
* Render the not found component
* @access protected
* @returns {Node} React node containing the `NotFound` component.
*/
renderNotFound() {
return (
<Components.NotFound
i18nKeyTitle="productGrid.noProductsFound"
icon="fa fa-barcode"
title="No Products Found"
/>
);
}

/**
* Render component
* @access protected
Expand All @@ -124,22 +109,12 @@ class Products extends Component {
render() {
const { isProductsSubscriptionReady, isReady, showNotFound } = this.props;

// Force show the not-found view.
if (showNotFound) {
return this.renderNotFound();
}

if (!isProductsSubscriptionReady || !isReady) {
return (
<Components.Loading />
);
}

// Render not-found view if no products are available.
if (!this.hasProducts) {
return this.renderNotFound();
}

return (
<div id="container-main">
{this.renderProductGrid()}
Expand Down