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