feat(dashboard,core-flows,js-sdk,types,medusa): Add exchange UI + fixes (#8606)

what:

- adds exchange UI
- fixes bugs on core-flows and endpoints
- random set of tiny fixes


https://github.com/user-attachments/assets/b163b9c1-4475-4936-ae98-20795760cc55
This commit is contained in:
Riqwan Thamir
2024-08-15 17:54:51 +00:00
committed by GitHub
parent ba34c53151
commit 82c147b91e
36 changed files with 3666 additions and 67 deletions
@@ -2,6 +2,7 @@ import {
removeItemReturnActionWorkflow,
updateRequestItemReturnWorkflow,
} from "@medusajs/core-flows"
import { HttpTypes } from "@medusajs/types"
import {
ContainerRegistrationKeys,
remoteQueryObjectFromString,
@@ -10,9 +11,9 @@ import {
AuthenticatedMedusaRequest,
MedusaResponse,
} from "../../../../../../../types/routing"
import { refetchEntity } from "../../../../../../utils/refetch-entity"
import { defaultAdminDetailsReturnFields } from "../../../../../returns/query-config"
import { AdminPostExchangesRequestItemsReturnActionReqSchemaType } from "../../../../validators"
import { HttpTypes } from "@medusajs/types"
export const POST = async (
req: AuthenticatedMedusaRequest<AdminPostExchangesRequestItemsReturnActionReqSchemaType>,
@@ -69,11 +70,15 @@ export const DELETE = async (
const { id, action_id } = req.params
const exchange = await refetchEntity("order_exchange", id, req.scope, [
"return_id",
])
const { result: orderPreview } = await removeItemReturnActionWorkflow(
req.scope
).run({
input: {
return_id: id,
return_id: exchange.return_id,
action_id,
},
})
@@ -81,7 +86,7 @@ export const DELETE = async (
const queryObject = remoteQueryObjectFromString({
entryPoint: "return",
variables: {
id,
id: exchange.return_id,
filters: {
...req.filterableFields,
},
@@ -0,0 +1,28 @@
import { AdminExchangeResponse } from "@medusajs/types"
import { MedusaError } from "@medusajs/utils"
import {
AuthenticatedMedusaRequest,
MedusaResponse,
} from "../../../../types/routing"
import { refetchEntity } from "../../../utils/refetch-entity"
export const GET = async (
req: AuthenticatedMedusaRequest,
res: MedusaResponse<AdminExchangeResponse>
) => {
const exchange = await refetchEntity(
"order_exchange",
req.params.id,
req.scope,
req.remoteQueryConfig.fields
)
if (!exchange) {
throw new MedusaError(
MedusaError.Types.NOT_FOUND,
`Exchange with id: ${req.params.id} was not found`
)
}
res.status(200).json({ exchange })
}