feat: Returns order previews (#8135)
* work on order previews * fix create return shipping flow * fix http tests * fix tests
This commit is contained in:
@@ -17,7 +17,7 @@ export const POST = async (
|
||||
|
||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||
|
||||
await requestItemReturnWorkflow(req.scope).run({
|
||||
const { result } = await requestItemReturnWorkflow(req.scope).run({
|
||||
input: { ...req.validatedBody, return_id: id },
|
||||
})
|
||||
|
||||
@@ -35,6 +35,7 @@ export const POST = async (
|
||||
const [orderReturn] = await remoteQuery(queryObject)
|
||||
|
||||
res.json({
|
||||
order_preview: result,
|
||||
return: orderReturn,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -17,10 +17,12 @@ export const POST = async (
|
||||
|
||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||
|
||||
await confirmReturnRequestWorkflow(req.scope).run({
|
||||
const { result } = await confirmReturnRequestWorkflow(req.scope).run({
|
||||
input: { return_id: id },
|
||||
})
|
||||
|
||||
console.log("RESULT: ", result)
|
||||
|
||||
const queryObject = remoteQueryObjectFromString({
|
||||
entryPoint: "return",
|
||||
variables: {
|
||||
@@ -35,6 +37,7 @@ export const POST = async (
|
||||
const [orderReturn] = await remoteQuery(queryObject)
|
||||
|
||||
res.json({
|
||||
order_preview: result,
|
||||
return: orderReturn,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
import { createReturnShippingMethodWorkflow } from "@medusajs/core-flows"
|
||||
import {
|
||||
ContainerRegistrationKeys,
|
||||
remoteQueryObjectFromString,
|
||||
} from "@medusajs/utils"
|
||||
import {
|
||||
AuthenticatedMedusaRequest,
|
||||
MedusaResponse,
|
||||
@@ -11,13 +15,27 @@ export const POST = async (
|
||||
) => {
|
||||
const { id } = req.params
|
||||
|
||||
const { result: orderPreview } = await createReturnShippingMethodWorkflow(
|
||||
req.scope
|
||||
).run({
|
||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||
|
||||
const { result } = await createReturnShippingMethodWorkflow(req.scope).run({
|
||||
input: { ...req.validatedBody, return_id: id },
|
||||
})
|
||||
|
||||
const queryObject = remoteQueryObjectFromString({
|
||||
entryPoint: "return",
|
||||
variables: {
|
||||
id,
|
||||
filters: {
|
||||
...req.filterableFields,
|
||||
},
|
||||
},
|
||||
fields: req.remoteQueryConfig.fields,
|
||||
})
|
||||
|
||||
const [orderReturn] = await remoteQuery(queryObject)
|
||||
|
||||
res.json({
|
||||
order: orderPreview,
|
||||
order_preview: result,
|
||||
return: orderReturn,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -9,8 +9,6 @@ export const defaultAdminReturnFields = [
|
||||
"refund_amount",
|
||||
"created_at",
|
||||
"updated_at",
|
||||
"*items",
|
||||
"*shipping_methods",
|
||||
]
|
||||
|
||||
export const retrieveTransformQueryConfig = {
|
||||
|
||||
@@ -61,5 +61,8 @@ export const POST = async (
|
||||
|
||||
const [orderReturn] = await remoteQuery(queryObject)
|
||||
|
||||
res.status(200).json({ return: orderReturn })
|
||||
res.json({
|
||||
order_preview: result,
|
||||
return: orderReturn,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user