fix: Minor fixes to the inventory pages (#7921)

This commit is contained in:
Stevche Radevski
2024-07-03 15:45:53 +02:00
committed by GitHub
parent 2711012d96
commit 3f499c829e
3 changed files with 12 additions and 9 deletions
@@ -59,7 +59,9 @@ export const InventoryItemGeneralSection = ({
} }
const getQuantityFormat = (quantity: number, locations?: number) => { const getQuantityFormat = (quantity: number, locations?: number) => {
return `${quantity ?? "-"} ${ if (quantity !== undefined && !isNaN(quantity)) {
quantity ? `across ${locations ?? "-"} locations` : "" return `${quantity} across ${locations ?? "-"} locations`
}` }
return "-"
} }
@@ -2,10 +2,7 @@ import * as zod from "zod"
import { InventoryTypes, StockLocationDTO } from "@medusajs/types" import { InventoryTypes, StockLocationDTO } from "@medusajs/types"
import { Button, Input, Select, Text, Textarea, toast } from "@medusajs/ui" import { Button, Input, Select, Text, Textarea, toast } from "@medusajs/ui"
import { import { RouteDrawer, useRouteModal } from "../../../../../../components/modals"
RouteDrawer,
useRouteModal,
} from "../../../../../../components/modals"
import { zodResolver } from "@hookform/resolvers/zod" import { zodResolver } from "@hookform/resolvers/zod"
import { useForm } from "react-hook-form" import { useForm } from "react-hook-form"
@@ -140,7 +137,11 @@ export const EditReservationForm = ({
/> />
<AttributeGridRow <AttributeGridRow
title={t("inventory.available")} title={t("inventory.available")}
value={level!.stocked_quantity - reservedQuantity} value={
level!.stocked_quantity -
(level.reserved_quantity - reservation.quantity) -
reservedQuantity
}
/> />
</div> </div>
<Form.Field <Form.Field
@@ -82,7 +82,7 @@ export const ReservationGeneralSection = ({
/> />
<SectionRow <SectionRow
title={t("inventory.reservation.reservedAtLocation")} title={t("inventory.reservation.reservedAtLocation")}
value={reservation.quantity} value={locationLevel?.reserved_quantity}
/> />
</Container> </Container>
) )