Skip to content

Commit 5d71df8

Browse files
committed
Handle null sales channel entries in product list and detail views
Filter out null entries from sales_channels arrays before rendering. When a sales channel is deleted without cleaning up the join table, the API returns null entries that crash the Admin UI with TypeError.
1 parent cec755c commit 5d71df8

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@medusajs/dashboard": patch
3+
---
4+
5+
fix(@medusajs/dashboard): handle null sales channel entries in product list and detail views

packages/admin/dashboard/src/components/table/table-cells/product/sales-channels-cell/sales-channels-cell.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ export const SalesChannelsCell = ({
1313
}: SalesChannelsCellProps) => {
1414
const { t } = useTranslation()
1515

16-
// Filter out null/undefined entries that can occur when a sales channel
17-
// is deleted but the product association is not cleaned up
1816
const validChannels = salesChannels?.filter(
1917
(sc): sc is SalesChannelDTO => sc != null
2018
)

packages/admin/dashboard/src/routes/products/product-detail/components/product-sales-channel-section/product-sales-channel-section.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const ProductSalesChannelSection = ({
2020
// is deleted but the product association is not cleaned up
2121
const availableInSalesChannels =
2222
product.sales_channels
23-
?.filter((sc) => sc != null)
23+
?.filter((sc): sc is HttpTypes.AdminProductSalesChannel => sc != null)
2424
.map((sc) => ({
2525
id: sc.id,
2626
name: sc.name,

0 commit comments

Comments
 (0)