fix(dashboard): manage locations for item location levels (#7794)
* fix: manage locations for item location levels * fix: toast
This commit is contained in:
@@ -481,6 +481,9 @@
|
||||
"successToast": "Reservation was successfully created.",
|
||||
"updateSuccessToast": "Reservation was successfully updated.",
|
||||
"deleteSuccessToast": "Reservation was successfully deleted."
|
||||
},
|
||||
"toast": {
|
||||
"updateLocations": "Locations updated successfully."
|
||||
}
|
||||
},
|
||||
"giftCards": {
|
||||
|
||||
@@ -15,13 +15,22 @@ export const LocationItem = ({
|
||||
}: LocationItemProps) => {
|
||||
return (
|
||||
<div
|
||||
className={clx("flex w-full gap-x-2 rounded-lg border px-2 py-2", {
|
||||
"border-ui-border-interactive ": selected,
|
||||
})}
|
||||
className={clx(
|
||||
"flex w-full cursor-pointer gap-x-2 rounded-lg border px-2 py-2",
|
||||
{
|
||||
"border-ui-border-interactive ": selected,
|
||||
}
|
||||
)}
|
||||
onClick={() => onSelect(!selected)}
|
||||
>
|
||||
<div className="h-5 w-5">
|
||||
<Checkbox checked={selected} />
|
||||
<Checkbox
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
onSelect(!selected)
|
||||
}}
|
||||
checked={selected}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex w-full flex-col">
|
||||
<Text size="small" leading="compact" weight="plus">
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import * as zod from "zod"
|
||||
|
||||
import { Button, Text, toast } from "@medusajs/ui"
|
||||
import { AdminInventoryItem, AdminStockLocation } from "@medusajs/types"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { z } from "zod"
|
||||
import { zodResolver } from "@hookform/resolvers/zod"
|
||||
import {
|
||||
RouteDrawer,
|
||||
useRouteModal,
|
||||
@@ -8,16 +12,11 @@ import {
|
||||
import { useBatchUpdateInventoryLevels } from "../../../../../../hooks/api/inventory"
|
||||
import { useFieldArray, useForm } from "react-hook-form"
|
||||
|
||||
import { InventoryItemRes } from "../../../../../../types/api-responses"
|
||||
import { LocationItem } from "./location-item"
|
||||
import { StockLocationDTO } from "@medusajs/types"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { z } from "zod"
|
||||
import { zodResolver } from "@hookform/resolvers/zod"
|
||||
|
||||
type EditInventoryItemAttributeFormProps = {
|
||||
item: InventoryItemRes["inventory_item"]
|
||||
locations: StockLocationDTO[]
|
||||
item: AdminInventoryItem
|
||||
locations: AdminStockLocation[]
|
||||
}
|
||||
|
||||
const EditInventoryItemAttributesSchema = z.object({
|
||||
@@ -31,7 +30,7 @@ const EditInventoryItemAttributesSchema = z.object({
|
||||
})
|
||||
|
||||
const getDefaultValues = (
|
||||
allLocations: StockLocationDTO[],
|
||||
allLocations: AdminStockLocation[],
|
||||
existingLevels: Set<string>
|
||||
) => {
|
||||
return {
|
||||
@@ -105,7 +104,7 @@ export const ManageLocationsForm = ({
|
||||
handleSuccess()
|
||||
|
||||
toast.success(t("general.success"), {
|
||||
description: t("inventory.toast.update"),
|
||||
description: t("inventory.toast.updateLocations"),
|
||||
dismissLabel: t("actions.close"),
|
||||
})
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user