feat(core-flows): begin returns, claims and exchanges (#8088)
* chore(order): begin return * claims and exchanges
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { createAndCompleteReturnOrderWorkflow } from "@medusajs/core-flows"
|
||||
import { beginReturnOrderWorkflow } from "@medusajs/core-flows"
|
||||
import {
|
||||
ContainerRegistrationKeys,
|
||||
remoteQueryObjectFromString,
|
||||
@@ -42,7 +42,7 @@ export const POST = async (
|
||||
) => {
|
||||
const input = req.validatedBody as AdminPostReturnsReqSchemaType
|
||||
|
||||
const workflow = createAndCompleteReturnOrderWorkflow(req.scope)
|
||||
const workflow = beginReturnOrderWorkflow(req.scope)
|
||||
const { result } = await workflow.run({
|
||||
input,
|
||||
})
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ClaimType } from "@medusajs/utils"
|
||||
import { z } from "zod"
|
||||
import {
|
||||
createFindParams,
|
||||
@@ -37,31 +38,44 @@ export const AdminGetOrdersParams = createFindParams({
|
||||
|
||||
export type AdminGetOrdersParamsType = z.infer<typeof AdminGetOrdersParams>
|
||||
|
||||
const ReturnShippingSchema = z.object({
|
||||
option_id: z.string(),
|
||||
price: z.number().optional(),
|
||||
})
|
||||
|
||||
const ItemSchema = z.object({
|
||||
id: z.string(),
|
||||
quantity: z.number().min(1),
|
||||
reason_id: z.string().nullish(),
|
||||
note: z.string().nullish(),
|
||||
note: z.string().optional(),
|
||||
})
|
||||
|
||||
export const AdminPostReturnsReqSchema = z.object({
|
||||
order_id: z.string(),
|
||||
items: z.array(ItemSchema),
|
||||
return_shipping: ReturnShippingSchema.optional(),
|
||||
internal_note: z.string().nullish(),
|
||||
receive_now: z.boolean().optional(),
|
||||
refund_amount: z.number().optional(),
|
||||
location_id: z.string().nullish(),
|
||||
description: z.string().optional(),
|
||||
internal_note: z.string().optional(),
|
||||
metadata: z.record(z.unknown()).nullish(),
|
||||
})
|
||||
export type AdminPostReturnsReqSchemaType = z.infer<
|
||||
typeof AdminPostReturnsReqSchema
|
||||
>
|
||||
|
||||
export const AdminPostOrderClaimsReqSchema = z.object({
|
||||
type: z.nativeEnum(ClaimType),
|
||||
order_id: z.string(),
|
||||
description: z.string().optional(),
|
||||
internal_note: z.string().optional(),
|
||||
metadata: z.record(z.unknown()).nullish(),
|
||||
})
|
||||
export type AdminPostOrderClaimsReqSchemaType = z.infer<
|
||||
typeof AdminPostOrderClaimsReqSchema
|
||||
>
|
||||
|
||||
export const AdminPostOrderExchangesReqSchema = z.object({
|
||||
order_id: z.string(),
|
||||
description: z.string().optional(),
|
||||
internal_note: z.string().optional(),
|
||||
metadata: z.record(z.unknown()).nullish(),
|
||||
})
|
||||
export type AdminPostOrderExchangesReqSchemaType = z.infer<
|
||||
typeof AdminPostOrderExchangesReqSchema
|
||||
>
|
||||
|
||||
export const AdminPostReceiveReturnsReqSchema = z.object({
|
||||
return_id: z.string(),
|
||||
items: z.array(ItemSchema),
|
||||
|
||||
Reference in New Issue
Block a user