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 authored and GitHub committed 2023-11-24 12:51:32 +00:00
1 parent 712c4496ce
commit f4c489fb85
4 files changed
+9 -14

No files matched your search

+5
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
@@ -157,7 +157,7 @@ const ProductDetails = ({ product }: Props) => {
{isFeatureEnabled(FeatureFlag.PRODUCT_CATEGORIES) && ( {isFeatureEnabled(FeatureFlag.PRODUCT_CATEGORIES) && (
<Detail <Detail
title={t("product-general-section-category", "Category")} title={t("product-general-section-category", "Category")}
value={product.categories.map((c) => c.name)} value={product.categories?.map((c) => c.name)}
/> />
)} )}
<Detail <Detail
@@ -175,7 +175,7 @@ const NewVariant = ({
ref={preview} ref={preview}
data-handler-id={handlerId} data-handler-id={handlerId}
className={clsx( 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, "opacity-50": isDragging,
} }
@@ -294,7 +294,6 @@ const VariantValidity = ({
productDimensions, productDimensions,
}: Pick<Props, "source" | "productCustoms" | "productDimensions">) => { }: Pick<Props, "source" | "productCustoms" | "productDimensions">) => {
const { const {
prices,
options, options,
dimensions, dimensions,
customs, customs,
@@ -335,8 +334,6 @@ const VariantValidity = ({
) )
} }
const validPrices = prices?.prices.some((p) => p.amount !== null)
const validDimensions = const validDimensions =
Object.values(productDimensions).every((value) => !!value) || Object.values(productDimensions).every((value) => !!value) ||
Object.values(dimensions).every((value) => !!value) Object.values(dimensions).every((value) => !!value)
@@ -346,13 +343,7 @@ const VariantValidity = ({
const barcodeValidity = !!barcode || !!upc || !!ean const barcodeValidity = !!barcode || !!upc || !!ean
if ( if (!sku || !validCustoms || !validDimensions || !barcodeValidity) {
!sku ||
!validCustoms ||
!validDimensions ||
!barcodeValidity ||
!validPrices
) {
return ( return (
<IconTooltip <IconTooltip
type="warning" type="warning"
@@ -364,7 +355,6 @@ const VariantValidity = ({
fields: fields:
</p> </p>
<ul className="list-inside list-disc"> <ul className="list-inside list-disc">
{!validPrices && <li>Pricing</li>}
{!validDimensions && <li>Dimensions</li>} {!validDimensions && <li>Dimensions</li>}
{!validCustoms && <li>Customs</li>} {!validCustoms && <li>Customs</li>}
{!inventory_quantity && <li>Inventory quantity</li>} {!inventory_quantity && <li>Inventory quantity</li>}
+1 -1
View File
@@ -48,7 +48,7 @@ const getDevServerConfig = () => {
onListening: function () { onListening: function () {
openBrowser(`http://localhost:7001`) openBrowser(`http://localhost:7001`)
}, },
allowedHosts: 'auto', allowedHosts: "auto",
} as Configuration, } as Configuration,
}, },
} }