From d302db23975227527e5632110d67c2ac299317b3 Mon Sep 17 00:00:00 2001 From: Philip Korsholm <88927411+pKorsholm@users.noreply.github.com> Date: Fri, 21 Apr 2023 18:00:51 +0200 Subject: [PATCH] fix(admin-ui): Add guard for null `product_id` (#3894) * handle null variants differently * add changeset --- .changeset/rare-monkeys-press.md | 5 +++++ .../ui/src/components/templates/inventory-table/index.tsx | 6 ++---- 2 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 .changeset/rare-monkeys-press.md diff --git a/.changeset/rare-monkeys-press.md b/.changeset/rare-monkeys-press.md new file mode 100644 index 0000000000..24736b63b9 --- /dev/null +++ b/.changeset/rare-monkeys-press.md @@ -0,0 +1,5 @@ +--- +"@medusajs/admin-ui": patch +--- + +fix(admin): add guard for null variant in inventory overview diff --git a/packages/admin-ui/ui/src/components/templates/inventory-table/index.tsx b/packages/admin-ui/ui/src/components/templates/inventory-table/index.tsx index 40b5bf2174..409b248ffe 100644 --- a/packages/admin-ui/ui/src/components/templates/inventory-table/index.tsx +++ b/packages/admin-ui/ui/src/components/templates/inventory-table/index.tsx @@ -12,6 +12,7 @@ import { useAdminUpdateLocationLevel, useAdminVariant, } from "medusa-react" +import { useLocation, useNavigate } from "react-router-dom" import Button from "../../fundamentals/button" import ImagePlaceholder from "../../fundamentals/image-placeholder" @@ -27,7 +28,6 @@ import { isEmpty } from "lodash" import qs from "qs" import { useInventoryFilters } from "./use-inventory-filters" import useInventoryTableColumn from "./use-inventory-column" -import { useLocation, useNavigate } from "react-router-dom" import useNotification from "../../../hooks/use-notification" import useToggleState from "../../../hooks/use-toggle-state" @@ -306,9 +306,7 @@ const InventoryRow = ({ } = useToggleState() const getRowActionables = () => { - const productId = inventory.variants?.length - ? inventory.variants[0].product_id - : null + const productId = inventory.variants?.[0]?.product_id const actions = [ {