feat(medusa): order changes endpoint (#8728)
What: - `admin/orders/:id/changes` endpoint to get order changes related to the order - added `*_by` attributes missing
This commit is contained in:
committed by
GitHub
parent
2a6c6fe590
commit
b6521e4c1a
@@ -397,6 +397,17 @@ medusaIntegrationTestRunner({
|
||||
|
||||
expect(result.total).toEqual(34)
|
||||
expect(result.items.length).toEqual(1)
|
||||
|
||||
result = (
|
||||
await api.get(
|
||||
`/admin/orders/${orderId}/changes?change_type=edit`,
|
||||
adminHeaders
|
||||
)
|
||||
).data.order_changes
|
||||
|
||||
expect(result[0].actions).toHaveLength(3)
|
||||
expect(result[0].status).toEqual("confirmed")
|
||||
expect(result[0].confirmed_by).toEqual(expect.stringContaining("user_"))
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
@@ -33,7 +33,7 @@ export const cancelOrderChangeStep = createStep(
|
||||
"exchange_id",
|
||||
"version",
|
||||
"canceled_at",
|
||||
"cancelled_by"
|
||||
"canceled_by"
|
||||
)
|
||||
|
||||
const dataBeforeUpdate = await service.retrieveOrderChange(data.id, {
|
||||
|
||||
@@ -4,6 +4,7 @@ import { createStep, StepResponse } from "@medusajs/workflows-sdk"
|
||||
|
||||
export type CancelOrdersStepInput = {
|
||||
orderIds: string[]
|
||||
canceled_by?: string
|
||||
}
|
||||
|
||||
export const cancelOrdersStepId = "cancel-orders"
|
||||
@@ -35,6 +36,7 @@ export const cancelOrdersStep = createStep(
|
||||
id: order.id,
|
||||
status: prevData.status,
|
||||
canceled_at: null,
|
||||
canceled_by: null,
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
@@ -5,6 +5,7 @@ import { createStep, StepResponse } from "@medusajs/workflows-sdk"
|
||||
export type ConfirmOrderChangesInput = {
|
||||
orderId: string
|
||||
changes: OrderChangeDTO[]
|
||||
confirmed_by?: string
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -15,7 +16,10 @@ export const confirmOrderChanges = createStep(
|
||||
async (input: ConfirmOrderChangesInput, { container }) => {
|
||||
const orderModuleService = container.resolve(ModuleRegistrationName.ORDER)
|
||||
await orderModuleService.confirmOrderChange(
|
||||
input.changes.map((action) => action.id)
|
||||
input.changes.map((action) => ({
|
||||
id: action.id,
|
||||
confirmed_by: input.confirmed_by,
|
||||
}))
|
||||
)
|
||||
|
||||
return new StepResponse(null, input.orderId)
|
||||
|
||||
@@ -86,6 +86,7 @@ export const cancelOrderClaimWorkflow = createWorkflow(
|
||||
cancelOrderClaimStep({
|
||||
claim_id: orderClaim.id,
|
||||
order_id: orderClaim.order_id,
|
||||
canceled_by: input.canceled_by,
|
||||
}),
|
||||
deleteReservationsByLineItemsStep(lineItemIds)
|
||||
)
|
||||
|
||||
@@ -16,12 +16,12 @@ import {
|
||||
ReturnStatus,
|
||||
} from "@medusajs/utils"
|
||||
import {
|
||||
WorkflowResponse,
|
||||
createStep,
|
||||
createWorkflow,
|
||||
parallelize,
|
||||
transform,
|
||||
when,
|
||||
WorkflowResponse,
|
||||
} from "@medusajs/workflows-sdk"
|
||||
import { reserveInventoryStep } from "../../../cart/steps/reserve-inventory"
|
||||
import { prepareConfirmInventoryInput } from "../../../cart/utils/prepare-confirm-inventory-input"
|
||||
@@ -39,6 +39,7 @@ import { createOrUpdateOrderPaymentCollectionWorkflow } from "../create-or-updat
|
||||
|
||||
export type ConfirmClaimRequestWorkflowInput = {
|
||||
claim_id: string
|
||||
confirmed_by?: string
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -90,6 +90,7 @@ export const cancelOrderExchangeWorkflow = createWorkflow(
|
||||
cancelOrderExchangeStep({
|
||||
exchange_id: orderExchange.id,
|
||||
order_id: orderExchange.order_id,
|
||||
canceled_by: input.canceled_by,
|
||||
}),
|
||||
deleteReservationsByLineItemsStep(lineItemIds)
|
||||
)
|
||||
|
||||
@@ -39,6 +39,7 @@ import { createOrUpdateOrderPaymentCollectionWorkflow } from "../create-or-updat
|
||||
|
||||
export type ConfirmExchangeRequestWorkflowInput = {
|
||||
exchange_id: string
|
||||
confirmed_by?: string
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+7
-2
@@ -11,9 +11,9 @@ import {
|
||||
createWorkflow,
|
||||
transform,
|
||||
} from "@medusajs/workflows-sdk"
|
||||
import { useRemoteQueryStep } from "../../../common"
|
||||
import { reserveInventoryStep } from "../../../cart/steps/reserve-inventory"
|
||||
import { prepareConfirmInventoryInput } from "../../../cart/utils/prepare-confirm-inventory-input"
|
||||
import { useRemoteQueryStep } from "../../../common"
|
||||
import { previewOrderChangeStep } from "../../steps"
|
||||
import { confirmOrderChanges } from "../../steps/confirm-order-changes"
|
||||
import {
|
||||
@@ -24,6 +24,7 @@ import { createOrUpdateOrderPaymentCollectionWorkflow } from "../create-or-updat
|
||||
|
||||
export type ConfirmOrderEditRequestWorkflowInput = {
|
||||
order_id: string
|
||||
confirmed_by?: string
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,7 +100,11 @@ export const confirmOrderEditRequestWorkflow = createWorkflow(
|
||||
|
||||
const orderPreview = previewOrderChangeStep(order.id)
|
||||
|
||||
confirmOrderChanges({ changes: [orderChange], orderId: order.id })
|
||||
confirmOrderChanges({
|
||||
changes: [orderChange],
|
||||
orderId: order.id,
|
||||
confirmed_by: input.confirmed_by,
|
||||
})
|
||||
|
||||
const orderItems = useRemoteQueryStep({
|
||||
entry_point: "order",
|
||||
|
||||
@@ -16,6 +16,7 @@ import { createOrUpdateOrderPaymentCollectionWorkflow } from "../create-or-updat
|
||||
|
||||
export type OrderEditRequestWorkflowInput = {
|
||||
order_id: string
|
||||
requested_by?: string
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,6 +74,8 @@ export const requestOrderEditRequestWorkflow = createWorkflow(
|
||||
{
|
||||
id: orderChange.id,
|
||||
status: OrderChangeStatus.REQUESTED,
|
||||
requested_at: new Date(),
|
||||
requested_by: input.requested_by,
|
||||
},
|
||||
])
|
||||
|
||||
|
||||
@@ -89,6 +89,7 @@ export const cancelReturnWorkflow = createWorkflow(
|
||||
cancelOrderReturnStep({
|
||||
return_id: orderReturn.id,
|
||||
order_id: orderReturn.order_id,
|
||||
canceled_by: input.canceled_by,
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
+6
-1
@@ -36,6 +36,7 @@ import {
|
||||
|
||||
export type ConfirmReceiveReturnRequestWorkflowInput = {
|
||||
return_id: string
|
||||
confirmed_by?: string
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -292,7 +293,11 @@ export const confirmReturnReceiveWorkflow = createWorkflow(
|
||||
parallelize(
|
||||
updateReturnsStep([updateReturn]),
|
||||
updateReturnItemsStep(updateReturnItem),
|
||||
confirmOrderChanges({ changes: [orderChange], orderId: order.id }),
|
||||
confirmOrderChanges({
|
||||
changes: [orderChange],
|
||||
orderId: order.id,
|
||||
confirmed_by: input.confirmed_by,
|
||||
}),
|
||||
adjustInventoryLevelsStep(inventoryAdjustment)
|
||||
)
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ import { createOrUpdateOrderPaymentCollectionWorkflow } from "../create-or-updat
|
||||
|
||||
export type ConfirmReturnRequestWorkflowInput = {
|
||||
return_id: string
|
||||
confirmed_by?: string
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -278,7 +279,11 @@ export const confirmReturnRequestWorkflow = createWorkflow(
|
||||
requested_at: new Date(),
|
||||
},
|
||||
]),
|
||||
confirmOrderChanges({ changes: [orderChange], orderId: order.id })
|
||||
confirmOrderChanges({
|
||||
changes: [orderChange],
|
||||
orderId: order.id,
|
||||
confirmed_by: input.confirmed_by,
|
||||
})
|
||||
)
|
||||
|
||||
createOrUpdateOrderPaymentCollectionWorkflow.runAsStep({
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
import { PaginatedResponse } from "../../common"
|
||||
import { BaseOrderChange } from "../common"
|
||||
import { AdminOrder, AdminOrderPreview } from "./entities"
|
||||
|
||||
export interface AdminOrderResponse {
|
||||
order: AdminOrder
|
||||
}
|
||||
|
||||
export interface AdminOrderChangesResponse {
|
||||
order_changes: BaseOrderChange[]
|
||||
}
|
||||
|
||||
export type AdminOrderListResponse = PaginatedResponse<{
|
||||
orders: AdminOrder[]
|
||||
}>
|
||||
@@ -19,4 +24,4 @@ export interface AdminDraftOrderResponse {
|
||||
|
||||
export type AdminDraftOrderListResponse = PaginatedResponse<{
|
||||
draft_orders: AdminOrder
|
||||
}>
|
||||
}>
|
||||
|
||||
@@ -1894,6 +1894,7 @@ export interface UpdateOrderExchangeWithSelectorDTO {
|
||||
}
|
||||
export interface CancelOrderReturnDTO extends BaseOrderBundledActionsDTO {
|
||||
return_id: string
|
||||
canceled_by?: string
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1981,6 +1982,7 @@ export interface CreateOrderClaimDTO extends BaseOrderBundledActionsDTO {
|
||||
|
||||
export interface CancelOrderClaimDTO extends BaseOrderBundledActionsDTO {
|
||||
claim_id: string
|
||||
canceled_by?: string
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2031,6 +2033,7 @@ export interface CreateOrderExchangeDTO extends BaseOrderBundledActionsDTO {
|
||||
|
||||
export interface CancelOrderExchangeDTO extends BaseOrderBundledActionsDTO {
|
||||
exchange_id: string
|
||||
canceled_by?: string
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
export interface CancelOrderClaimWorkflowInput {
|
||||
claim_id: string
|
||||
no_notification?: boolean
|
||||
canceled_by?: string
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
export interface CancelOrderExchangeWorkflowInput {
|
||||
exchange_id: string
|
||||
no_notification?: boolean
|
||||
canceled_by?: string
|
||||
}
|
||||
|
||||
@@ -2,4 +2,5 @@ export interface CancelOrderFulfillmentWorkflowInput {
|
||||
order_id: string
|
||||
fulfillment_id: string
|
||||
no_notification?: boolean
|
||||
canceled_by?: string
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
export interface CancelOrderWorkflowInput {
|
||||
order_id: string
|
||||
no_notification?: boolean
|
||||
canceled_by?: string
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
export interface CancelReturnWorkflowInput {
|
||||
return_id: string
|
||||
no_notification?: boolean
|
||||
canceled_by?: string
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { cancelOrderClaimWorkflow } from "@medusajs/core-flows"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import {
|
||||
AuthenticatedMedusaRequest,
|
||||
MedusaResponse,
|
||||
} from "../../../../../types/routing"
|
||||
import { AdminPostCancelClaimReqSchemaType } from "../../validators"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminPostCancelClaimReqSchemaType>,
|
||||
@@ -17,6 +17,7 @@ export const POST = async (
|
||||
input: {
|
||||
...req.validatedBody,
|
||||
claim_id: id,
|
||||
canceled_by: req.auth_context.actor_id,
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import {
|
||||
cancelBeginOrderClaimWorkflow,
|
||||
confirmClaimRequestWorkflow,
|
||||
} from "@medusajs/core-flows"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import {
|
||||
ContainerRegistrationKeys,
|
||||
remoteQueryObjectFromString,
|
||||
@@ -11,7 +12,6 @@ import {
|
||||
MedusaResponse,
|
||||
} from "../../../../../types/routing"
|
||||
import { defaultAdminDetailsReturnFields } from "../../../returns/query-config"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest,
|
||||
@@ -22,7 +22,10 @@ export const POST = async (
|
||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||
|
||||
const { result } = await confirmClaimRequestWorkflow(req.scope).run({
|
||||
input: { claim_id: id },
|
||||
input: {
|
||||
claim_id: id,
|
||||
confirmed_by: req.auth_context.actor_id,
|
||||
},
|
||||
})
|
||||
|
||||
const queryObject = remoteQueryObjectFromString({
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { cancelOrderExchangeWorkflow } from "@medusajs/core-flows"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import {
|
||||
AuthenticatedMedusaRequest,
|
||||
MedusaResponse,
|
||||
} from "../../../../../types/routing"
|
||||
import { AdminPostCancelExchangeReqSchemaType } from "../../validators"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminPostCancelExchangeReqSchemaType>,
|
||||
@@ -17,6 +17,7 @@ export const POST = async (
|
||||
input: {
|
||||
...req.validatedBody,
|
||||
exchange_id: id,
|
||||
canceled_by: req.auth_context.actor_id,
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import {
|
||||
cancelBeginOrderExchangeWorkflow,
|
||||
confirmExchangeRequestWorkflow,
|
||||
} from "@medusajs/core-flows"
|
||||
import { DeleteResponse, HttpTypes } from "@medusajs/types"
|
||||
import {
|
||||
ContainerRegistrationKeys,
|
||||
remoteQueryObjectFromString,
|
||||
@@ -11,7 +12,6 @@ import {
|
||||
MedusaResponse,
|
||||
} from "../../../../../types/routing"
|
||||
import { defaultAdminDetailsReturnFields } from "../../../returns/query-config"
|
||||
import { DeleteResponse, HttpTypes } from "@medusajs/types"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest,
|
||||
@@ -22,7 +22,10 @@ export const POST = async (
|
||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||
|
||||
const { result } = await confirmExchangeRequestWorkflow(req.scope).run({
|
||||
input: { exchange_id: id },
|
||||
input: {
|
||||
exchange_id: id,
|
||||
confirmed_by: req.auth_context.actor_id,
|
||||
},
|
||||
})
|
||||
|
||||
const queryObject = remoteQueryObjectFromString({
|
||||
|
||||
@@ -12,7 +12,10 @@ export const POST = async (
|
||||
const { id } = req.params
|
||||
|
||||
const { result } = await confirmOrderEditRequestWorkflow(req.scope).run({
|
||||
input: { order_id: id },
|
||||
input: {
|
||||
order_id: id,
|
||||
confirmed_by: req.auth_context.actor_id,
|
||||
},
|
||||
})
|
||||
|
||||
res.json({
|
||||
|
||||
@@ -12,7 +12,10 @@ export const POST = async (
|
||||
const { id } = req.params
|
||||
|
||||
const { result } = await requestOrderEditRequestWorkflow(req.scope).run({
|
||||
input: { order_id: id },
|
||||
input: {
|
||||
order_id: id,
|
||||
requested_by: req.auth_context.actor_id,
|
||||
},
|
||||
})
|
||||
|
||||
res.json({
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { cancelOrderWorkflow } from "@medusajs/core-flows"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import {
|
||||
ContainerRegistrationKeys,
|
||||
remoteQueryObjectFromString,
|
||||
@@ -7,7 +8,6 @@ import {
|
||||
AuthenticatedMedusaRequest,
|
||||
MedusaResponse,
|
||||
} from "../../../../../types/routing"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest,
|
||||
@@ -19,6 +19,7 @@ export const POST = async (
|
||||
|
||||
const input = {
|
||||
order_id: req.params.id,
|
||||
canceled_by: req.auth_context.actor_id,
|
||||
}
|
||||
|
||||
await cancelOrderWorkflow(req.scope).run({
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import {
|
||||
ContainerRegistrationKeys,
|
||||
remoteQueryObjectFromString,
|
||||
} from "@medusajs/utils"
|
||||
import {
|
||||
AuthenticatedMedusaRequest,
|
||||
MedusaResponse,
|
||||
} from "../../../../../types/routing"
|
||||
|
||||
export const GET = async (
|
||||
req: AuthenticatedMedusaRequest,
|
||||
res: MedusaResponse<HttpTypes.AdminOrderChangesResponse>
|
||||
) => {
|
||||
const { id } = req.params
|
||||
|
||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||
const queryObject = remoteQueryObjectFromString({
|
||||
entryPoint: "order_change",
|
||||
variables: {
|
||||
filters: {
|
||||
...req.filterableFields,
|
||||
order_id: id,
|
||||
},
|
||||
},
|
||||
fields: req.remoteQueryConfig.fields,
|
||||
})
|
||||
|
||||
const order_changes = await remoteQuery(queryObject)
|
||||
|
||||
res.status(200).json({ order_changes })
|
||||
}
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
import { cancelOrderFulfillmentWorkflow } from "@medusajs/core-flows"
|
||||
import { AdditionalData, HttpTypes } from "@medusajs/types"
|
||||
import {
|
||||
ContainerRegistrationKeys,
|
||||
remoteQueryObjectFromString,
|
||||
@@ -8,7 +9,6 @@ import {
|
||||
MedusaResponse,
|
||||
} from "../../../../../../../types/routing"
|
||||
import { AdminOrderCancelFulfillmentType } from "../../../../validators"
|
||||
import { AdditionalData, HttpTypes } from "@medusajs/types"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<
|
||||
@@ -24,6 +24,7 @@ export const POST = async (
|
||||
...req.validatedBody,
|
||||
order_id: req.params.id,
|
||||
fulfillment_id: req.params.fulfillment_id,
|
||||
canceled_by: req.auth_context.actor_id,
|
||||
}
|
||||
|
||||
await cancelOrderFulfillmentWorkflow(req.scope).run({
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
AdminGetOrdersOrderParams,
|
||||
AdminGetOrdersParams,
|
||||
AdminOrderCancelFulfillment,
|
||||
AdminOrderChanges,
|
||||
AdminOrderCreateFulfillment,
|
||||
AdminOrderCreateShipment,
|
||||
} from "./validators"
|
||||
@@ -33,6 +34,16 @@ export const adminOrderRoutesMiddlewares: MiddlewareRoute[] = [
|
||||
),
|
||||
],
|
||||
},
|
||||
{
|
||||
method: ["GET"],
|
||||
matcher: "/admin/orders/:id/changes",
|
||||
middlewares: [
|
||||
validateAndTransformQuery(
|
||||
AdminOrderChanges,
|
||||
QueryConfig.retrieveOrderChangesTransformQueryConfig
|
||||
),
|
||||
],
|
||||
},
|
||||
{
|
||||
method: ["GET"],
|
||||
matcher: "/admin/orders/:id/preview",
|
||||
|
||||
@@ -53,6 +53,33 @@ export const defaultAdminRetrieveOrderFields = [
|
||||
"*payment_collections.payments.refunds",
|
||||
]
|
||||
|
||||
export const defaultAdminRetrieveOrderChangesFields = [
|
||||
"id",
|
||||
"order_id",
|
||||
"return_id",
|
||||
"claim_id",
|
||||
"exchange_id",
|
||||
"version",
|
||||
"change_type",
|
||||
"*actions",
|
||||
"description",
|
||||
"status",
|
||||
"internal_note",
|
||||
"created_by",
|
||||
"requested_by",
|
||||
"requested_at",
|
||||
"confirmed_by",
|
||||
"confirmed_at",
|
||||
"declined_by",
|
||||
"declined_reason",
|
||||
"metadata",
|
||||
"declined_at",
|
||||
"canceled_by",
|
||||
"canceled_at",
|
||||
"created_at",
|
||||
"updated_at",
|
||||
]
|
||||
|
||||
export const retrieveTransformQueryConfig = {
|
||||
defaultFields: defaultAdminRetrieveOrderFields,
|
||||
isList: false,
|
||||
@@ -63,3 +90,8 @@ export const listTransformQueryConfig = {
|
||||
defaultLimit: 20,
|
||||
isList: true,
|
||||
}
|
||||
|
||||
export const retrieveOrderChangesTransformQueryConfig = {
|
||||
defaultFields: defaultAdminRetrieveOrderChangesFields,
|
||||
isList: false,
|
||||
}
|
||||
|
||||
@@ -91,3 +91,13 @@ export const OrderCancelFulfillment = z.object({
|
||||
export const AdminOrderCancelFulfillment = WithAdditionalData(
|
||||
OrderCancelFulfillment
|
||||
)
|
||||
|
||||
export const AdminOrderChanges = z.object({
|
||||
id: z.union([z.string(), z.array(z.string())]).optional(),
|
||||
status: z.union([z.string(), z.array(z.string())]).optional(),
|
||||
change_type: z.union([z.string(), z.array(z.string())]).optional(),
|
||||
created_at: createOperatorMap().optional(),
|
||||
updated_at: createOperatorMap().optional(),
|
||||
deleted_at: createOperatorMap().optional(),
|
||||
})
|
||||
export type AdminOrderChangesType = z.infer<typeof AdminOrderChanges>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { confirmReturnReceiveWorkflow } from "@medusajs/core-flows"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import {
|
||||
ContainerRegistrationKeys,
|
||||
remoteQueryObjectFromString,
|
||||
@@ -8,7 +9,6 @@ import {
|
||||
MedusaResponse,
|
||||
} from "../../../../../../types/routing"
|
||||
import { AdminPostReturnsConfirmRequestReqSchemaType } from "../../../validators"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminPostReturnsConfirmRequestReqSchemaType>,
|
||||
@@ -19,7 +19,10 @@ export const POST = async (
|
||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||
|
||||
const { result } = await confirmReturnReceiveWorkflow(req.scope).run({
|
||||
input: { return_id: id },
|
||||
input: {
|
||||
return_id: id,
|
||||
confirmed_by: req.auth_context.actor_id,
|
||||
},
|
||||
})
|
||||
|
||||
const queryObject = remoteQueryObjectFromString({
|
||||
|
||||
@@ -2,6 +2,7 @@ import {
|
||||
cancelReturnRequestWorkflow,
|
||||
confirmReturnRequestWorkflow,
|
||||
} from "@medusajs/core-flows"
|
||||
import { DeleteResponse, HttpTypes } from "@medusajs/types"
|
||||
import {
|
||||
ContainerRegistrationKeys,
|
||||
remoteQueryObjectFromString,
|
||||
@@ -11,7 +12,6 @@ import {
|
||||
MedusaResponse,
|
||||
} from "../../../../../types/routing"
|
||||
import { AdminPostReturnsConfirmRequestReqSchemaType } from "../../validators"
|
||||
import { DeleteResponse, HttpTypes } from "@medusajs/types"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminPostReturnsConfirmRequestReqSchemaType>,
|
||||
@@ -22,7 +22,10 @@ export const POST = async (
|
||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||
|
||||
const { result } = await confirmReturnRequestWorkflow(req.scope).run({
|
||||
input: { return_id: id },
|
||||
input: {
|
||||
return_id: id,
|
||||
confirmed_by: req.auth_context.actor_id,
|
||||
},
|
||||
})
|
||||
|
||||
const queryObject = remoteQueryObjectFromString({
|
||||
|
||||
Reference in New Issue
Block a user