Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Admin Returns API #8117

Merged
merged 9 commits into from
Jul 15, 2024
Merged

feat: Admin Returns API #8117

merged 9 commits into from
Jul 15, 2024

Conversation

olivermrbl
Copy link
Contributor

Opening to solicit feedback

What

Adds

  • POST /admin/returns/:id/request-items
  • POST /admin/returns/:id/shipping-method
  • POST /admin/returns/:id/request

Copy link

vercel bot commented Jul 13, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
medusa-dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 15, 2024 10:21am
6 Skipped Deployments
Name Status Preview Comments Updated (UTC)
api-reference ⬜️ Ignored (Inspect) Jul 15, 2024 10:21am
api-reference-v2 ⬜️ Ignored (Inspect) Visit Preview Jul 15, 2024 10:21am
docs-ui ⬜️ Ignored (Inspect) Visit Preview Jul 15, 2024 10:21am
docs-v2 ⬜️ Ignored (Inspect) Visit Preview Jul 15, 2024 10:21am
medusa-docs ⬜️ Ignored (Inspect) Visit Preview Jul 15, 2024 10:21am
resources-docs ⬜️ Ignored (Inspect) Visit Preview Jul 15, 2024 10:21am

Copy link

changeset-bot bot commented Jul 13, 2024

⚠️ No Changeset found

Latest commit: 4a4a60b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@olivermrbl
Copy link
Contributor Author

olivermrbl commented Jul 14, 2024

The PR needs a lot of clean-up of types, return values, more tests and others. Please keep the review isolated to the flow of events. I'll clean it up as soon as we've got the workflows in place.

Aside from the flow of events, there are two larger elements to also discuss:

  • How do we go about return fulfillment?
  • How do we go about refunds?

Additionally, one thought I had was that we should create a dedicated order preview endpoint so we can follow our convention for Rest API response types. The /admin/returns should not return order previews but the return object. The same goes for /admin/claims and /admin/exchanges/ that should return claims and exchanges respectively.

Let me know what you think.

cc @carlos-r-l-rodrigues

@olivermrbl
Copy link
Contributor Author

How do we go about return fulfillment?

For this one, I could port over what we have in createAndCompleteReturn workflow, such that we always create a return fulfillment as part of submitting the request to create a return. But we'll need to decide if this is where we want it to happen.

changes: OrderChangeDTO[]
}

export const confirmOrderChanges = createStep(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment: Can be "bulkified"

returnId: string
}

export const createReturnItems = createStep(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment: Can be "bulkified"

@olivermrbl
Copy link
Contributor Author

/snapshot-this

Copy link
Contributor

🚀 A snapshot release has been made for this PR

Test the snapshots by updating your package.json with the newly published versions:

yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]

Latest commit: 1bd1d4f

@olivermrbl olivermrbl changed the title [wip] feat: Admin Returns API feat: Admin Returns API Jul 15, 2024
@olivermrbl olivermrbl marked this pull request as ready for review July 15, 2024 10:19
@olivermrbl olivermrbl requested a review from a team as a code owner July 15, 2024 10:19

const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)

await requestItemReturnWorkflow(req.scope).run({
Copy link
Contributor

@carlos-r-l-rodrigues carlos-r-l-rodrigues Jul 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we should return the result of this workflow, which will be the preview of the Order after the change actions are applied.

Same for the shipping-method

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we will need anything but the totals preview in the FE?

Was just discussing the response with Seb, and we thought of doing:

res.status(200).json({ return: orderReturn, total_summary: result.summary })

...provided the result here is the order preview.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we will need anything but the totals preview in the FE?

Was just discussing the response with Seb, and we thought of doing:

res.status(200).json({ return: orderReturn, total_summary: result.summary })

...provided the result here is the order preview.

Comment on lines +27 to +29
location_id?: string
description?: string
internal_note?: string
Copy link
Contributor

@fPolic fPolic Jul 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discussion: we would need to send this info when we confirm a return request right? When we initiate a return request we don't know this info yet and later we can't update this fields.

EDIT: or we add a general update return request endpoint which would update note, location etc.?

Copy link
Contributor Author

@olivermrbl olivermrbl Jul 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's right – it will be send with the confirmation request. Also just discussed the return reasons with Seb. We will move these from the return level to the return item level, as we also talked about this morning. This is pending design.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we add a general update return request endpoint which would update note, location etc.?

Yeah, that's also possible. We will have the following endpoint:

POST /admin/returns/:id 

{ location_id?, no_notification?, metadata? }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point.
And based on the message displayed when the location selected doesn't have stock associated with that location, maybe we need an extra endpoint to update the return location and return the result of this stock location check.

@olivermrbl
Copy link
Contributor Author

@fPolic @carlos-r-l-rodrigues, would it make sense to merge this and address the rest in follow up PRs?

@fPolic
Copy link
Contributor

fPolic commented Jul 15, 2024

@fPolic @carlos-r-l-rodrigues, would it make sense to merge this and address the rest in follow up PRs?

sounds good 👍

@olivermrbl olivermrbl merged commit 00c7900 into develop Jul 15, 2024
23 checks passed
@olivermrbl olivermrbl deleted the feat/returns-rest-api branch July 15, 2024 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants