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(admin-ui): Fix issue with null product categories #5707

Merged
merged 2 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions .changeset/hungry-dodos-fix.md
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down Expand Up @@ -294,7 +294,6 @@ const VariantValidity = ({
productDimensions,
}: Pick<Props, "source" | "productCustoms" | "productDimensions">) => {
const {
prices,
options,
dimensions,
customs,
Expand Down Expand Up @@ -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)
Expand All @@ -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"
Expand All @@ -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>}
Expand Down
2 changes: 1 addition & 1 deletion packages/admin-ui/webpack.config.dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const getDevServerConfig = () => {
onListening: function () {
openBrowser(`http://localhost:7001`)
},
allowedHosts: 'auto',
allowedHosts: "auto",
} as Configuration,
},
}
Expand Down