fix(admin-ui): Fix issue with null product categories (#5707)

* fix(admin-ui): If categories is null on a product the details page should not crash

* cleanup variant warning to reflect pricing changes
This commit is contained in:
Kasper Fabricius Kristensen
2023-11-24 12:51:32 +00:00
committed by GitHub
parent 712c4496ce
commit f4c489fb85
4 changed files with 9 additions and 14 deletions

View File

@@ -0,0 +1,5 @@
---
"@medusajs/admin-ui": patch
---
fix(admin-ui): Fix an issue where if product.categories was null the details page would crash

View File

@@ -157,7 +157,7 @@ const ProductDetails = ({ product }: Props) => {
{isFeatureEnabled(FeatureFlag.PRODUCT_CATEGORIES) && (
<Detail
title={t("product-general-section-category", "Category")}
value={product.categories.map((c) => c.name)}
value={product.categories?.map((c) => c.name)}
/>
)}
<Detail

View File

@@ -175,7 +175,7 @@ const NewVariant = ({
ref={preview}
data-handler-id={handlerId}
className={clsx(
"rounded-rounded py-xsmall pl-xsmall pr-base focus-within:bg-grey-5 hover:bg-grey-5 grid h-16 translate-y-0 translate-x-0 grid-cols-[32px_1fr_90px_100px_48px] transition-all",
"rounded-rounded py-xsmall pl-xsmall pr-base focus-within:bg-grey-5 hover:bg-grey-5 grid h-16 translate-x-0 translate-y-0 grid-cols-[32px_1fr_90px_100px_48px] transition-all",
{
"opacity-50": isDragging,
}
@@ -294,7 +294,6 @@ const VariantValidity = ({
productDimensions,
}: Pick<Props, "source" | "productCustoms" | "productDimensions">) => {
const {
prices,
options,
dimensions,
customs,
@@ -335,8 +334,6 @@ const VariantValidity = ({
)
}
const validPrices = prices?.prices.some((p) => p.amount !== null)
const validDimensions =
Object.values(productDimensions).every((value) => !!value) ||
Object.values(dimensions).every((value) => !!value)
@@ -346,13 +343,7 @@ const VariantValidity = ({
const barcodeValidity = !!barcode || !!upc || !!ean
if (
!sku ||
!validCustoms ||
!validDimensions ||
!barcodeValidity ||
!validPrices
) {
if (!sku || !validCustoms || !validDimensions || !barcodeValidity) {
return (
<IconTooltip
type="warning"
@@ -364,7 +355,6 @@ const VariantValidity = ({
fields:
</p>
<ul className="list-inside list-disc">
{!validPrices && <li>Pricing</li>}
{!validDimensions && <li>Dimensions</li>}
{!validCustoms && <li>Customs</li>}
{!inventory_quantity && <li>Inventory quantity</li>}

View File

@@ -48,7 +48,7 @@ const getDevServerConfig = () => {
onListening: function () {
openBrowser(`http://localhost:7001`)
},
allowedHosts: 'auto',
allowedHosts: "auto",
} as Configuration,
},
}