fix(dashboard): RMA allow shipping unset (#12021)
**What** - allow unsetting shipping in RMA flows + bug cleanup around shipping flows in claims / exchanges - additional fixes: - product type create form - product type delete - delete confirmation messages - fix a few inventory strings + material field --- CLOSES CMRC-945 CLOSES CMRC-953 CLOSES CMRC-967 CLOSES CMRC-963 CLOSES CMRC-954 Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/dashboard": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(dashboard): RMA allow shipping unset
|
||||||
@@ -3034,6 +3034,9 @@
|
|||||||
"manageLocations": {
|
"manageLocations": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"manageLocationQuantity": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"deleteWarning": {
|
"deleteWarning": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
@@ -3252,6 +3255,7 @@
|
|||||||
"locationLevels",
|
"locationLevels",
|
||||||
"associatedVariants",
|
"associatedVariants",
|
||||||
"manageLocations",
|
"manageLocations",
|
||||||
|
"manageLocationQuantity",
|
||||||
"deleteWarning",
|
"deleteWarning",
|
||||||
"editItemDetails",
|
"editItemDetails",
|
||||||
"create",
|
"create",
|
||||||
|
|||||||
@@ -811,6 +811,7 @@
|
|||||||
"locationLevels": "Locations",
|
"locationLevels": "Locations",
|
||||||
"associatedVariants": "Associated variants",
|
"associatedVariants": "Associated variants",
|
||||||
"manageLocations": "Manage locations",
|
"manageLocations": "Manage locations",
|
||||||
|
"manageLocationQuantity": "Manage location quantity",
|
||||||
"deleteWarning": "You are about to delete an inventory item. This action cannot be undone.",
|
"deleteWarning": "You are about to delete an inventory item. This action cannot be undone.",
|
||||||
"editItemDetails": "Edit item details",
|
"editItemDetails": "Edit item details",
|
||||||
"create": {
|
"create": {
|
||||||
@@ -1501,7 +1502,7 @@
|
|||||||
"successToast": "Location {{name}} was successfully updated."
|
"successToast": "Location {{name}} was successfully updated."
|
||||||
},
|
},
|
||||||
"delete": {
|
"delete": {
|
||||||
"confirmation": "You are about to delete the stock location {{name}}. This action cannot be undone."
|
"confirmation": "You are about to delete the stock location \"{{name}}\". This action cannot be undone."
|
||||||
},
|
},
|
||||||
"fulfillmentProviders": {
|
"fulfillmentProviders": {
|
||||||
"header": "Fulfillment Providers",
|
"header": "Fulfillment Providers",
|
||||||
@@ -1520,7 +1521,7 @@
|
|||||||
"header": "Shipping"
|
"header": "Shipping"
|
||||||
},
|
},
|
||||||
"disable": {
|
"disable": {
|
||||||
"confirmation": "Are you sure that you want to disable {{name}}? This will delete all associated service zones and shipping options, and cannot be undone.",
|
"confirmation": "Are you sure that you want to disable \"{{name}}\"? This will delete all associated service zones and shipping options, and cannot be undone.",
|
||||||
"pickup": "Pickup was successfully disabled.",
|
"pickup": "Pickup was successfully disabled.",
|
||||||
"shipping": "Shipping was successfully disabled."
|
"shipping": "Shipping was successfully disabled."
|
||||||
},
|
},
|
||||||
@@ -1577,7 +1578,7 @@
|
|||||||
"action": "Create option"
|
"action": "Create option"
|
||||||
},
|
},
|
||||||
"delete": {
|
"delete": {
|
||||||
"confirmation": "You are about to delete the shipping option {{name}}. This action cannot be undone.",
|
"confirmation": "You are about to delete the shipping option \"{{name}}\". This action cannot be undone.",
|
||||||
"successToast": "Shipping option {{name}} was successfully deleted."
|
"successToast": "Shipping option {{name}} was successfully deleted."
|
||||||
},
|
},
|
||||||
"edit": {
|
"edit": {
|
||||||
@@ -1666,7 +1667,7 @@
|
|||||||
"successToast": "Service zone {{name}} was successfully updated."
|
"successToast": "Service zone {{name}} was successfully updated."
|
||||||
},
|
},
|
||||||
"delete": {
|
"delete": {
|
||||||
"confirmation": "You are about to delete the service zone {{name}}. This action cannot be undone.",
|
"confirmation": "You are about to delete the service zone \"{{name}}\". This action cannot be undone.",
|
||||||
"successToast": "Service zone {{name}} was successfully deleted."
|
"successToast": "Service zone {{name}} was successfully deleted."
|
||||||
},
|
},
|
||||||
"manageAreas": {
|
"manageAreas": {
|
||||||
@@ -1831,7 +1832,7 @@
|
|||||||
"successToast": "Tax rate was successfully updated."
|
"successToast": "Tax rate was successfully updated."
|
||||||
},
|
},
|
||||||
"delete": {
|
"delete": {
|
||||||
"confirmation": "You are about to delete the tax rate {{name}}. This action cannot be undone.",
|
"confirmation": "You are about to delete the tax rate \"{{name}}\". This action cannot be undone.",
|
||||||
"successToast": "Tax rate was successfully deleted."
|
"successToast": "Tax rate was successfully deleted."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -2089,11 +2090,11 @@
|
|||||||
},
|
},
|
||||||
"value_type": {
|
"value_type": {
|
||||||
"fixed": {
|
"fixed": {
|
||||||
"title": "Promotion Value",
|
"title": "Fixed amount",
|
||||||
"description": "The amount to be discounted. eg. 100"
|
"description": "The amount to be discounted. eg. 100"
|
||||||
},
|
},
|
||||||
"percentage": {
|
"percentage": {
|
||||||
"title": "Promotion Value",
|
"title": "Percentage",
|
||||||
"description": "The percentage to discount off the amount. eg. 8%"
|
"description": "The percentage to discount off the amount. eg. 8%"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2206,8 +2207,8 @@
|
|||||||
"domain": "Price Lists",
|
"domain": "Price Lists",
|
||||||
"subtitle": "Create sales or override prices for specific conditions.",
|
"subtitle": "Create sales or override prices for specific conditions.",
|
||||||
"delete": {
|
"delete": {
|
||||||
"confirmation": "You are about to delete the price list {{title}}. This action cannot be undone.",
|
"confirmation": "You are about to delete the price list \"{{title}}\". This action cannot be undone.",
|
||||||
"successToast": "Price list {{title}} was successfully deleted."
|
"successToast": "Price list \"{{title}}\" was successfully deleted."
|
||||||
},
|
},
|
||||||
"create": {
|
"create": {
|
||||||
"header": "Create Price List",
|
"header": "Create Price List",
|
||||||
@@ -2643,8 +2644,8 @@
|
|||||||
"successToast": "Return reason {{label}} was successfully updated."
|
"successToast": "Return reason {{label}} was successfully updated."
|
||||||
},
|
},
|
||||||
"delete": {
|
"delete": {
|
||||||
"confirmation": "You are about to delete the return reason {{label}}. This action cannot be undone.",
|
"confirmation": "You are about to delete the return reason \"{{label}}\". This action cannot be undone.",
|
||||||
"successToast": "Return reason {{label}} was successfully deleted."
|
"successToast": "Return reason \"{{label}}\" was successfully deleted."
|
||||||
},
|
},
|
||||||
"fields": {
|
"fields": {
|
||||||
"value": {
|
"value": {
|
||||||
@@ -2764,8 +2765,8 @@
|
|||||||
"successToast": "Product type {{value}} was successfully updated."
|
"successToast": "Product type {{value}} was successfully updated."
|
||||||
},
|
},
|
||||||
"delete": {
|
"delete": {
|
||||||
"confirmation": "You are about to delete the product type {{value}}. This action cannot be undone.",
|
"confirmation": "You are about to delete the product type \"{{value}}\". This action cannot be undone.",
|
||||||
"successToast": "Product type {{value}} was successfully deleted."
|
"successToast": "Product type \"{{value}}\" was successfully deleted."
|
||||||
},
|
},
|
||||||
"fields": {
|
"fields": {
|
||||||
"value": "Value"
|
"value": "Value"
|
||||||
|
|||||||
+1
-1
@@ -41,7 +41,7 @@ export const AdjustInventoryDrawer = () => {
|
|||||||
return (
|
return (
|
||||||
<RouteDrawer>
|
<RouteDrawer>
|
||||||
<RouteDrawer.Header>
|
<RouteDrawer.Header>
|
||||||
<Heading>{t("inventory.manageLocations")}</Heading>
|
<Heading>{t("inventory.manageLocationQuantity")}</Heading>
|
||||||
</RouteDrawer.Header>
|
</RouteDrawer.Header>
|
||||||
{ready && (
|
{ready && (
|
||||||
<AdjustInventoryForm
|
<AdjustInventoryForm
|
||||||
|
|||||||
+17
@@ -24,6 +24,7 @@ const EditInventoryItemAttributesSchema = z.object({
|
|||||||
length: z.number().positive().optional(),
|
length: z.number().positive().optional(),
|
||||||
weight: z.number().positive().optional(),
|
weight: z.number().positive().optional(),
|
||||||
mid_code: z.string().optional(),
|
mid_code: z.string().optional(),
|
||||||
|
material: z.string().optional(),
|
||||||
hs_code: z.string().optional(),
|
hs_code: z.string().optional(),
|
||||||
origin_country: z.string().optional(),
|
origin_country: z.string().optional(),
|
||||||
})
|
})
|
||||||
@@ -35,6 +36,7 @@ const getDefaultValues = (item: InventoryTypes.InventoryItemDTO) => {
|
|||||||
length: item.length ?? undefined,
|
length: item.length ?? undefined,
|
||||||
weight: item.weight ?? undefined,
|
weight: item.weight ?? undefined,
|
||||||
mid_code: item.mid_code ?? undefined,
|
mid_code: item.mid_code ?? undefined,
|
||||||
|
material: item.material ?? undefined,
|
||||||
hs_code: item.hs_code ?? undefined,
|
hs_code: item.hs_code ?? undefined,
|
||||||
origin_country: item.origin_country ?? undefined,
|
origin_country: item.origin_country ?? undefined,
|
||||||
}
|
}
|
||||||
@@ -216,6 +218,21 @@ export const EditInventoryItemAttributesForm = ({
|
|||||||
)
|
)
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
<Form.Field
|
||||||
|
control={form.control}
|
||||||
|
name="material"
|
||||||
|
render={({ field }) => {
|
||||||
|
return (
|
||||||
|
<Form.Item>
|
||||||
|
<Form.Label optional>{t("fields.material")}</Form.Label>
|
||||||
|
<Form.Control>
|
||||||
|
<Input {...field} />
|
||||||
|
</Form.Control>
|
||||||
|
<Form.ErrorMessage />
|
||||||
|
</Form.Item>
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
<Form.Field
|
<Form.Field
|
||||||
control={form.control}
|
control={form.control}
|
||||||
|
|||||||
+1
@@ -39,6 +39,7 @@ export const InventoryItemAttributeSection = ({
|
|||||||
<SectionRow title={t("fields.length")} value={inventoryItem.length} />
|
<SectionRow title={t("fields.length")} value={inventoryItem.length} />
|
||||||
<SectionRow title={t("fields.weight")} value={inventoryItem.weight} />
|
<SectionRow title={t("fields.weight")} value={inventoryItem.weight} />
|
||||||
<SectionRow title={t("fields.midCode")} value={inventoryItem.mid_code} />
|
<SectionRow title={t("fields.midCode")} value={inventoryItem.mid_code} />
|
||||||
|
<SectionRow title={t("fields.material")} value={inventoryItem.material} />
|
||||||
<SectionRow title={t("fields.hsCode")} value={inventoryItem.hs_code} />
|
<SectionRow title={t("fields.hsCode")} value={inventoryItem.hs_code} />
|
||||||
<SectionRow
|
<SectionRow
|
||||||
title={t("fields.countryOfOrigin")}
|
title={t("fields.countryOfOrigin")}
|
||||||
|
|||||||
+16
-11
@@ -425,13 +425,15 @@ export const ClaimCreateForm = ({
|
|||||||
await updateReturn({ location_id: selectedLocationId })
|
await updateReturn({ location_id: selectedLocationId })
|
||||||
}
|
}
|
||||||
|
|
||||||
const onShippingOptionChange = async (selectedOptionId: string) => {
|
const onShippingOptionChange = async (
|
||||||
|
selectedOptionId: string | undefined
|
||||||
|
) => {
|
||||||
const inboundShippingMethods = preview.shipping_methods.filter((s) => {
|
const inboundShippingMethods = preview.shipping_methods.filter((s) => {
|
||||||
const action = s.actions?.find(
|
const action = s.actions?.find(
|
||||||
(a) => a.action === "SHIPPING_ADD" && !!a.return_id
|
(a) => a.action === "SHIPPING_ADD" && !!a.return_id
|
||||||
)
|
)
|
||||||
|
|
||||||
return action && !action?.return_id
|
return action && !!action?.return_id
|
||||||
})
|
})
|
||||||
|
|
||||||
const promises = inboundShippingMethods
|
const promises = inboundShippingMethods
|
||||||
@@ -448,14 +450,16 @@ export const ClaimCreateForm = ({
|
|||||||
|
|
||||||
await Promise.all(promises)
|
await Promise.all(promises)
|
||||||
|
|
||||||
await addInboundShipping(
|
if (selectedOptionId) {
|
||||||
{ shipping_option_id: selectedOptionId },
|
await addInboundShipping(
|
||||||
{
|
{ shipping_option_id: selectedOptionId },
|
||||||
onError: (error) => {
|
{
|
||||||
toast.error(error.message)
|
onError: (error) => {
|
||||||
},
|
toast.error(error.message)
|
||||||
}
|
},
|
||||||
)
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -740,10 +744,11 @@ export const ClaimCreateForm = ({
|
|||||||
<Form.Item>
|
<Form.Item>
|
||||||
<Form.Control>
|
<Form.Control>
|
||||||
<Combobox
|
<Combobox
|
||||||
|
allowClear
|
||||||
value={value ?? undefined}
|
value={value ?? undefined}
|
||||||
onChange={(val) => {
|
onChange={(val) => {
|
||||||
onChange(val)
|
onChange(val)
|
||||||
val && onShippingOptionChange(val)
|
onShippingOptionChange(val)
|
||||||
}}
|
}}
|
||||||
{...field}
|
{...field}
|
||||||
options={inboundShippingOptions.map((so) => ({
|
options={inboundShippingOptions.map((so) => ({
|
||||||
|
|||||||
+15
-10
@@ -197,7 +197,9 @@ export const ClaimOutboundSection = ({
|
|||||||
setIsOpen("outbound-items", false)
|
setIsOpen("outbound-items", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
const onShippingOptionChange = async (selectedOptionId: string) => {
|
const onShippingOptionChange = async (
|
||||||
|
selectedOptionId: string | undefined
|
||||||
|
) => {
|
||||||
const outboundShippingMethods = preview.shipping_methods.filter((s) => {
|
const outboundShippingMethods = preview.shipping_methods.filter((s) => {
|
||||||
const action = s.actions?.find(
|
const action = s.actions?.find(
|
||||||
(a) => a.action === "SHIPPING_ADD" && !a.return_id
|
(a) => a.action === "SHIPPING_ADD" && !a.return_id
|
||||||
@@ -220,14 +222,16 @@ export const ClaimOutboundSection = ({
|
|||||||
|
|
||||||
await Promise.all(promises)
|
await Promise.all(promises)
|
||||||
|
|
||||||
await addOutboundShipping(
|
if (selectedOptionId) {
|
||||||
{ shipping_option_id: selectedOptionId },
|
await addOutboundShipping(
|
||||||
{
|
{ shipping_option_id: selectedOptionId },
|
||||||
onError: (error) => {
|
{
|
||||||
toast.error(error.message)
|
onError: (error) => {
|
||||||
},
|
toast.error(error.message)
|
||||||
}
|
},
|
||||||
)
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const showLevelsWarning = useMemo(() => {
|
const showLevelsWarning = useMemo(() => {
|
||||||
@@ -403,10 +407,11 @@ export const ClaimOutboundSection = ({
|
|||||||
<Form.Item>
|
<Form.Item>
|
||||||
<Form.Control>
|
<Form.Control>
|
||||||
<Combobox
|
<Combobox
|
||||||
|
allowClear
|
||||||
value={value ?? undefined}
|
value={value ?? undefined}
|
||||||
onChange={(val) => {
|
onChange={(val) => {
|
||||||
onChange(val)
|
onChange(val)
|
||||||
val && onShippingOptionChange(val)
|
onShippingOptionChange(val)
|
||||||
}}
|
}}
|
||||||
{...field}
|
{...field}
|
||||||
options={outboundShippingOptions.map((so) => ({
|
options={outboundShippingOptions.map((so) => ({
|
||||||
|
|||||||
+16
-11
@@ -199,7 +199,7 @@ export const ExchangeInboundSection = ({
|
|||||||
inboundShippingMethod.shipping_option_id
|
inboundShippingMethod.shipping_option_id
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
form.setValue("inbound_option_id", null)
|
form.setValue("inbound_option_id", "")
|
||||||
}
|
}
|
||||||
}, [preview.shipping_methods])
|
}, [preview.shipping_methods])
|
||||||
|
|
||||||
@@ -246,7 +246,9 @@ export const ExchangeInboundSection = ({
|
|||||||
await updateReturn({ location_id: selectedLocationId })
|
await updateReturn({ location_id: selectedLocationId })
|
||||||
}
|
}
|
||||||
|
|
||||||
const onShippingOptionChange = async (selectedOptionId: string) => {
|
const onShippingOptionChange = async (
|
||||||
|
selectedOptionId: string | undefined
|
||||||
|
) => {
|
||||||
const inboundShippingMethods = preview.shipping_methods.filter((s) =>
|
const inboundShippingMethods = preview.shipping_methods.filter((s) =>
|
||||||
s.actions?.find((a) => a.action === "SHIPPING_ADD" && !!a.return_id)
|
s.actions?.find((a) => a.action === "SHIPPING_ADD" && !!a.return_id)
|
||||||
)
|
)
|
||||||
@@ -265,14 +267,16 @@ export const ExchangeInboundSection = ({
|
|||||||
|
|
||||||
await Promise.all(promises)
|
await Promise.all(promises)
|
||||||
|
|
||||||
await addInboundShipping(
|
if (selectedOptionId) {
|
||||||
{ shipping_option_id: selectedOptionId },
|
await addInboundShipping(
|
||||||
{
|
{ shipping_option_id: selectedOptionId },
|
||||||
onError: (error) => {
|
{
|
||||||
toast.error(error.message)
|
onError: (error) => {
|
||||||
},
|
toast.error(error.message)
|
||||||
}
|
},
|
||||||
)
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const showLevelsWarning = useMemo(() => {
|
const showLevelsWarning = useMemo(() => {
|
||||||
@@ -505,10 +509,11 @@ export const ExchangeInboundSection = ({
|
|||||||
<Form.Item>
|
<Form.Item>
|
||||||
<Form.Control>
|
<Form.Control>
|
||||||
<Combobox
|
<Combobox
|
||||||
|
allowClear
|
||||||
value={value ?? undefined}
|
value={value ?? undefined}
|
||||||
onChange={(val) => {
|
onChange={(val) => {
|
||||||
onChange(val)
|
onChange(val)
|
||||||
val && onShippingOptionChange(val)
|
onShippingOptionChange(val)
|
||||||
}}
|
}}
|
||||||
{...field}
|
{...field}
|
||||||
options={inboundShippingOptions.map((so) => ({
|
options={inboundShippingOptions.map((so) => ({
|
||||||
|
|||||||
+16
-12
@@ -30,7 +30,6 @@ import { ItemPlaceholder } from "../../../order-create-claim/components/claim-cr
|
|||||||
import { AddExchangeOutboundItemsTable } from "../add-exchange-outbound-items-table"
|
import { AddExchangeOutboundItemsTable } from "../add-exchange-outbound-items-table"
|
||||||
import { ExchangeOutboundItem } from "./exchange-outbound-item"
|
import { ExchangeOutboundItem } from "./exchange-outbound-item"
|
||||||
import { CreateExchangeSchemaType } from "./schema"
|
import { CreateExchangeSchemaType } from "./schema"
|
||||||
import { log } from "console"
|
|
||||||
|
|
||||||
type ExchangeOutboundSectionProps = {
|
type ExchangeOutboundSectionProps = {
|
||||||
order: AdminOrder
|
order: AdminOrder
|
||||||
@@ -206,11 +205,13 @@ export const ExchangeOutboundSection = ({
|
|||||||
if (outboundShipping) {
|
if (outboundShipping) {
|
||||||
form.setValue("outbound_option_id", outboundShipping.shipping_option_id)
|
form.setValue("outbound_option_id", outboundShipping.shipping_option_id)
|
||||||
} else {
|
} else {
|
||||||
form.setValue("outbound_option_id", null)
|
form.setValue("outbound_option_id", "")
|
||||||
}
|
}
|
||||||
}, [preview.shipping_methods])
|
}, [preview.shipping_methods])
|
||||||
|
|
||||||
const onShippingOptionChange = async (selectedOptionId: string) => {
|
const onShippingOptionChange = async (
|
||||||
|
selectedOptionId: string | undefined
|
||||||
|
) => {
|
||||||
const outboundShippingMethods = preview.shipping_methods.filter(
|
const outboundShippingMethods = preview.shipping_methods.filter(
|
||||||
(s) =>
|
(s) =>
|
||||||
!!s.actions?.find((a) => a.action === "SHIPPING_ADD" && !a.return_id)
|
!!s.actions?.find((a) => a.action === "SHIPPING_ADD" && !a.return_id)
|
||||||
@@ -230,14 +231,16 @@ export const ExchangeOutboundSection = ({
|
|||||||
|
|
||||||
await Promise.all(promises)
|
await Promise.all(promises)
|
||||||
|
|
||||||
await addOutboundShipping(
|
if (selectedOptionId) {
|
||||||
{ shipping_option_id: selectedOptionId },
|
await addOutboundShipping(
|
||||||
{
|
{ shipping_option_id: selectedOptionId },
|
||||||
onError: (error) => {
|
{
|
||||||
toast.error(error.message)
|
onError: (error) => {
|
||||||
},
|
toast.error(error.message)
|
||||||
}
|
},
|
||||||
)
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const showLevelsWarning = useMemo(() => {
|
const showLevelsWarning = useMemo(() => {
|
||||||
@@ -412,11 +415,12 @@ export const ExchangeOutboundSection = ({
|
|||||||
<Form.Item>
|
<Form.Item>
|
||||||
<Form.Control>
|
<Form.Control>
|
||||||
<Combobox
|
<Combobox
|
||||||
|
allowClear
|
||||||
noResultsPlaceholder={<OutboundShippingPlaceholder />}
|
noResultsPlaceholder={<OutboundShippingPlaceholder />}
|
||||||
value={value ?? undefined}
|
value={value ?? undefined}
|
||||||
onChange={(val) => {
|
onChange={(val) => {
|
||||||
onChange(val)
|
onChange(val)
|
||||||
val && onShippingOptionChange(val)
|
onShippingOptionChange(val)
|
||||||
}}
|
}}
|
||||||
{...field}
|
{...field}
|
||||||
options={outboundShippingOptions.map((so) => ({
|
options={outboundShippingOptions.map((so) => ({
|
||||||
|
|||||||
+7
-3
@@ -292,7 +292,9 @@ export const ReturnCreateForm = ({
|
|||||||
await updateReturnRequest({ location_id: selectedLocationId })
|
await updateReturnRequest({ location_id: selectedLocationId })
|
||||||
}
|
}
|
||||||
|
|
||||||
const onShippingOptionChange = async (selectedOptionId: string) => {
|
const onShippingOptionChange = async (
|
||||||
|
selectedOptionId: string | undefined
|
||||||
|
) => {
|
||||||
const promises = preview.shipping_methods
|
const promises = preview.shipping_methods
|
||||||
.map((s) => s.actions?.find((a) => a.action === "SHIPPING_ADD")?.id)
|
.map((s) => s.actions?.find((a) => a.action === "SHIPPING_ADD")?.id)
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
@@ -300,7 +302,9 @@ export const ReturnCreateForm = ({
|
|||||||
|
|
||||||
await Promise.all(promises)
|
await Promise.all(promises)
|
||||||
|
|
||||||
await addReturnShipping({ shipping_option_id: selectedOptionId })
|
if (selectedOptionId) {
|
||||||
|
await addReturnShipping({ shipping_option_id: selectedOptionId })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -562,7 +566,6 @@ export const ReturnCreateForm = ({
|
|||||||
</Form.Hint>
|
</Form.Hint>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* TODO: WHAT IF THE RETURN OPTION HAS COMPUTED PRICE*/}
|
|
||||||
<Form.Field
|
<Form.Field
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="option_id"
|
name="option_id"
|
||||||
@@ -571,6 +574,7 @@ export const ReturnCreateForm = ({
|
|||||||
<Form.Item>
|
<Form.Item>
|
||||||
<Form.Control>
|
<Form.Control>
|
||||||
<Combobox
|
<Combobox
|
||||||
|
allowClear
|
||||||
value={value}
|
value={value}
|
||||||
onChange={(v) => {
|
onChange={(v) => {
|
||||||
onChange(v)
|
onChange(v)
|
||||||
|
|||||||
+7
-3
@@ -1,17 +1,20 @@
|
|||||||
|
import { useNavigate } from "react-router-dom"
|
||||||
import { toast, usePrompt } from "@medusajs/ui"
|
import { toast, usePrompt } from "@medusajs/ui"
|
||||||
import { useTranslation } from "react-i18next"
|
import { useTranslation } from "react-i18next"
|
||||||
|
|
||||||
import { useDeleteProductType } from "../../../../hooks/api/product-types"
|
import { useDeleteProductType } from "../../../../hooks/api/product-types"
|
||||||
|
|
||||||
export const useDeleteProductTypeAction = (id: string) => {
|
export const useDeleteProductTypeAction = (id: string, value: string) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const prompt = usePrompt()
|
const prompt = usePrompt()
|
||||||
|
const navigate = useNavigate()
|
||||||
|
|
||||||
const { mutateAsync } = useDeleteProductType(id)
|
const { mutateAsync } = useDeleteProductType(id)
|
||||||
|
|
||||||
const handleDelete = async () => {
|
const handleDelete = async () => {
|
||||||
const result = await prompt({
|
const result = await prompt({
|
||||||
title: t("general.areYouSure"),
|
title: t("general.areYouSure"),
|
||||||
description: t("productTypes.delete.confirmation"),
|
description: t("productTypes.delete.confirmation", { value }),
|
||||||
confirmText: t("actions.delete"),
|
confirmText: t("actions.delete"),
|
||||||
cancelText: t("actions.cancel"),
|
cancelText: t("actions.cancel"),
|
||||||
})
|
})
|
||||||
@@ -22,7 +25,8 @@ export const useDeleteProductTypeAction = (id: string) => {
|
|||||||
|
|
||||||
await mutateAsync(undefined, {
|
await mutateAsync(undefined, {
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
toast.success(t("productTypes.delete.successToast"))
|
navigate("/settings/product-types", { replace: true })
|
||||||
|
toast.success(t("productTypes.delete.successToast", { value }))
|
||||||
},
|
},
|
||||||
onError: (e) => {
|
onError: (e) => {
|
||||||
toast.error(e.message)
|
toast.error(e.message)
|
||||||
|
|||||||
+20
-23
@@ -34,7 +34,7 @@ export const CreateProductTypeForm = () => {
|
|||||||
onSuccess: ({ product_type }) => {
|
onSuccess: ({ product_type }) => {
|
||||||
toast.success(
|
toast.success(
|
||||||
t("productTypes.create.successToast", {
|
t("productTypes.create.successToast", {
|
||||||
value: product_type.value,
|
value: product_type.value.trim(),
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -49,28 +49,8 @@ export const CreateProductTypeForm = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<RouteFocusModal.Form form={form}>
|
<RouteFocusModal.Form form={form}>
|
||||||
<KeyboundForm
|
<KeyboundForm onSubmit={handleSubmit} className="flex h-full flex-col">
|
||||||
onSubmit={handleSubmit}
|
<RouteFocusModal.Body className="flex flex-col items-center overflow-auto p-16">
|
||||||
className="flex flex-col overflow-hidden"
|
|
||||||
>
|
|
||||||
<RouteFocusModal.Header>
|
|
||||||
<div className="flex items-center justify-end gap-x-2">
|
|
||||||
<RouteFocusModal.Close asChild>
|
|
||||||
<Button size="small" variant="secondary">
|
|
||||||
{t("actions.cancel")}
|
|
||||||
</Button>
|
|
||||||
</RouteFocusModal.Close>
|
|
||||||
<Button
|
|
||||||
size="small"
|
|
||||||
variant="primary"
|
|
||||||
type="submit"
|
|
||||||
isLoading={isPending}
|
|
||||||
>
|
|
||||||
{t("actions.create")}
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</RouteFocusModal.Header>
|
|
||||||
<RouteFocusModal.Body className="flex flex-col items-center overflow-y-auto p-16">
|
|
||||||
<div className="flex w-full max-w-[720px] flex-col gap-y-8">
|
<div className="flex w-full max-w-[720px] flex-col gap-y-8">
|
||||||
<div>
|
<div>
|
||||||
<Heading>{t("productTypes.create.header")}</Heading>
|
<Heading>{t("productTypes.create.header")}</Heading>
|
||||||
@@ -97,6 +77,23 @@ export const CreateProductTypeForm = () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</RouteFocusModal.Body>
|
</RouteFocusModal.Body>
|
||||||
|
<RouteFocusModal.Footer>
|
||||||
|
<div className="flex items-center justify-end gap-x-2">
|
||||||
|
<RouteFocusModal.Close asChild>
|
||||||
|
<Button size="small" variant="secondary">
|
||||||
|
{t("actions.cancel")}
|
||||||
|
</Button>
|
||||||
|
</RouteFocusModal.Close>
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
variant="primary"
|
||||||
|
type="submit"
|
||||||
|
isLoading={isPending}
|
||||||
|
>
|
||||||
|
{t("actions.create")}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</RouteFocusModal.Footer>
|
||||||
</KeyboundForm>
|
</KeyboundForm>
|
||||||
</RouteFocusModal.Form>
|
</RouteFocusModal.Form>
|
||||||
)
|
)
|
||||||
|
|||||||
+4
-1
@@ -13,7 +13,10 @@ export const ProductTypeGeneralSection = ({
|
|||||||
productType,
|
productType,
|
||||||
}: ProductTypeGeneralSectionProps) => {
|
}: ProductTypeGeneralSectionProps) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const handleDelete = useDeleteProductTypeAction(productType.id)
|
const handleDelete = useDeleteProductTypeAction(
|
||||||
|
productType.id,
|
||||||
|
productType.value
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container className="flex items-center justify-between">
|
<Container className="flex items-center justify-between">
|
||||||
|
|||||||
+4
-1
@@ -12,7 +12,10 @@ export const ProductTypeRowActions = ({
|
|||||||
productType,
|
productType,
|
||||||
}: ProductTypeRowActionsProps) => {
|
}: ProductTypeRowActionsProps) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const handleDelete = useDeleteProductTypeAction(productType.id)
|
const handleDelete = useDeleteProductTypeAction(
|
||||||
|
productType.id,
|
||||||
|
productType.value
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ActionMenu
|
<ActionMenu
|
||||||
|
|||||||
Reference in New Issue
Block a user