Merge pull request #729 from mirumee/fix/showing-skeleton-for-price-in-product-list
Fix skeleton showing for price in product list
This commit is contained in:
commit
388c4c97ec
3 changed files with 10 additions and 20 deletions
|
@ -22,10 +22,7 @@ import {
|
||||||
isAttributeColumnValue
|
isAttributeColumnValue
|
||||||
} from "@saleor/products/components/ProductListPage/utils";
|
} from "@saleor/products/components/ProductListPage/utils";
|
||||||
import { GridAttributes_grid_edges_node } from "@saleor/products/types/GridAttributes";
|
import { GridAttributes_grid_edges_node } from "@saleor/products/types/GridAttributes";
|
||||||
import {
|
import { ProductList_products_edges_node } from "@saleor/products/types/ProductList";
|
||||||
ProductList_products_edges_node,
|
|
||||||
ProductList_products_edges_node_pricing_priceRangeUndiscounted
|
|
||||||
} from "@saleor/products/types/ProductList";
|
|
||||||
import { ProductListUrlSortField } from "@saleor/products/urls";
|
import { ProductListUrlSortField } from "@saleor/products/urls";
|
||||||
import { ListActions, ListProps, SortPage } from "@saleor/types";
|
import { ListActions, ListProps, SortPage } from "@saleor/types";
|
||||||
import TDisplayColumn, {
|
import TDisplayColumn, {
|
||||||
|
@ -106,6 +103,7 @@ interface ProductListProps
|
||||||
activeAttributeSortId: string;
|
activeAttributeSortId: string;
|
||||||
gridAttributes: GridAttributes_grid_edges_node[];
|
gridAttributes: GridAttributes_grid_edges_node[];
|
||||||
products: ProductList_products_edges_node[];
|
products: ProductList_products_edges_node[];
|
||||||
|
loading: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ProductList: React.FC<ProductListProps> = props => {
|
export const ProductList: React.FC<ProductListProps> = props => {
|
||||||
|
@ -118,6 +116,7 @@ export const ProductList: React.FC<ProductListProps> = props => {
|
||||||
pageInfo,
|
pageInfo,
|
||||||
products,
|
products,
|
||||||
selected,
|
selected,
|
||||||
|
loading,
|
||||||
sort,
|
sort,
|
||||||
toggle,
|
toggle,
|
||||||
toggleAll,
|
toggleAll,
|
||||||
|
@ -137,11 +136,11 @@ export const ProductList: React.FC<ProductListProps> = props => {
|
||||||
);
|
);
|
||||||
const numberOfColumns = 2 + settings.columns.length;
|
const numberOfColumns = 2 + settings.columns.length;
|
||||||
|
|
||||||
const getProductPrice = (
|
const getProductPrice = product => {
|
||||||
priceRangeUndiscounted: ProductList_products_edges_node_pricing_priceRangeUndiscounted
|
const priceRangeUndiscounted = product?.pricing?.priceRangeUndiscounted;
|
||||||
) => {
|
|
||||||
if (!priceRangeUndiscounted) {
|
if (!priceRangeUndiscounted) {
|
||||||
return null;
|
return "-";
|
||||||
}
|
}
|
||||||
|
|
||||||
const { start, stop } = priceRangeUndiscounted;
|
const { start, stop } = priceRangeUndiscounted;
|
||||||
|
@ -445,13 +444,7 @@ export const ProductList: React.FC<ProductListProps> = props => {
|
||||||
displayColumns={settings.columns}
|
displayColumns={settings.columns}
|
||||||
>
|
>
|
||||||
<TableCell className={classes.colPrice}>
|
<TableCell className={classes.colPrice}>
|
||||||
{product?.pricing?.priceRangeUndiscounted ? (
|
{loading ? <Skeleton /> : getProductPrice(product)}
|
||||||
getProductPrice(
|
|
||||||
product?.pricing?.priceRangeUndiscounted
|
|
||||||
)
|
|
||||||
) : (
|
|
||||||
<Skeleton />
|
|
||||||
)}
|
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</DisplayColumn>
|
</DisplayColumn>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
|
@ -185,6 +185,7 @@ export const ProductListPage: React.FC<ProductListPageProps> = props => {
|
||||||
/>
|
/>
|
||||||
<ProductList
|
<ProductList
|
||||||
{...listProps}
|
{...listProps}
|
||||||
|
loading={loading}
|
||||||
gridAttributes={gridAttributes}
|
gridAttributes={gridAttributes}
|
||||||
settings={settings}
|
settings={settings}
|
||||||
onUpdateListSettings={onUpdateListSettings}
|
onUpdateListSettings={onUpdateListSettings}
|
||||||
|
|
|
@ -164589,11 +164589,7 @@ exports[`Storyshots Views / Products / Product list loading 1`] = `
|
||||||
<td
|
<td
|
||||||
class="MuiTableCell-root-id MuiTableCell-body-id ProductList-colPrice-id"
|
class="MuiTableCell-root-id MuiTableCell-body-id ProductList-colPrice-id"
|
||||||
>
|
>
|
||||||
<span
|
-
|
||||||
class="Skeleton-skeleton-id"
|
|
||||||
>
|
|
||||||
|
|
||||||
</span>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
Loading…
Reference in a new issue