Skip to content

fix: migrate return reasons list to new DataTable component#14916

Open
TheSeydiCharyyev wants to merge 4 commits intomedusajs:developfrom
TheSeydiCharyyev:fix/issue-14812-return-reason-datatable
Open

fix: migrate return reasons list to new DataTable component#14916
TheSeydiCharyyev wants to merge 4 commits intomedusajs:developfrom
TheSeydiCharyyev:fix/issue-14812-return-reason-datatable

Conversation

@TheSeydiCharyyev
Copy link
Copy Markdown

@TheSeydiCharyyev TheSeydiCharyyev commented Mar 20, 2026

What

Migrates the Return Reasons settings page from the legacy _DataTable component to the newer DataTable component, matching the pattern already used by the Refund Reasons page.

Why

The Return Reasons page uses the legacy _DataTable with noHeader: true, which hides search, column sorting, and column headers. The Refund Reasons page already uses the modern
DataTable component with full functionality. This inconsistency was reported in #14812.

How

  • use-return-reason-table-columns.tsx — Replaced createColumnHelper from @tanstack/react-table with createDataTableColumnHelper from @medusajs/ui. Added column headers,
    sorting, and DescriptionCell for the description column.
  • return-reason-list-table.tsx — Replaced _DataTable + manual header with the new DataTable component. Added built-in search, heading, empty states, and inline action menu
    (edit/delete) using columnHelper.action().
  • return-reasons.tsx — Added useDeleteReturnReasonLazy hook (lazy variant where id is passed to mutationFn) to support the new inline delete action pattern.

Testing

  1. Navigate to Settings > Return Reasons
  2. Verify search bar is visible and functional
  3. Verify column headers (Label, Value, Description) are displayed
  4. Verify column sorting works on all columns
  5. Verify edit and delete actions work via row action menu
  6. Compare UX with Settings > Refund Reasons — should be consistent

Fixes #14812


Note

Low Risk
Low risk UI refactor that swaps table components and rewires row actions; main risk is regressions in list interactions (search/sort/navigation/delete) due to the new DataTable API and mutation wiring.

Overview
Migrates the Return Reasons settings list from the legacy _DataTable to the newer DataTable, restoring built-in header UI including search, empty states, and column sorting.

Updates return-reason columns to use createDataTableColumnHelper with translated headers and a dedicated DescriptionCell, and moves edit/delete into an inline row action column (with prompt + toasts and explicit navigation).

Adds useDeleteReturnReasonLazy (id passed at call time) and removes the old useDeleteReturnReasonAction helper, while keeping query invalidation behavior for list/detail refresh after deletes.

Written by Cursor Bugbot for commit fe789c0. This will update automatically on new commits. Configure here.

@TheSeydiCharyyev TheSeydiCharyyev requested a review from a team as a code owner March 20, 2026 06:37
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 20, 2026

@TheSeydiCharyyev is attempting to deploy a commit to the medusajs Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 20, 2026

🦋 Changeset detected

Latest commit: 3e9276b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 76 packages
Name Type
@medusajs/dashboard Patch
@medusajs/admin-bundler Patch
@medusajs/medusa Patch
@medusajs/test-utils Patch
@medusajs/medusa-oas-cli Patch
integration-tests-http Patch
@medusajs/analytics Patch
@medusajs/api-key Patch
@medusajs/auth Patch
@medusajs/caching Patch
@medusajs/cart Patch
@medusajs/currency Patch
@medusajs/customer Patch
@medusajs/file Patch
@medusajs/fulfillment Patch
@medusajs/index Patch
@medusajs/inventory Patch
@medusajs/link-modules Patch
@medusajs/locking Patch
@medusajs/notification Patch
@medusajs/order Patch
@medusajs/payment Patch
@medusajs/pricing Patch
@medusajs/product Patch
@medusajs/promotion Patch
@medusajs/rbac Patch
@medusajs/region Patch
@medusajs/sales-channel Patch
@medusajs/settings Patch
@medusajs/stock-location Patch
@medusajs/store Patch
@medusajs/tax Patch
@medusajs/translation Patch
@medusajs/user Patch
@medusajs/workflow-engine-inmemory Patch
@medusajs/workflow-engine-redis Patch
@medusajs/draft-order Patch
@medusajs/oas-github-ci Patch
@medusajs/cache-inmemory Patch
@medusajs/cache-redis Patch
@medusajs/event-bus-local Patch
@medusajs/event-bus-redis Patch
@medusajs/analytics-local Patch
@medusajs/analytics-posthog Patch
@medusajs/auth-emailpass Patch
@medusajs/auth-github Patch
@medusajs/auth-google Patch
@medusajs/caching-redis Patch
@medusajs/file-local Patch
@medusajs/file-s3 Patch
@medusajs/fulfillment-manual Patch
@medusajs/locking-postgres Patch
@medusajs/locking-redis Patch
@medusajs/notification-local Patch
@medusajs/notification-sendgrid Patch
@medusajs/payment-stripe Patch
@medusajs/core-flows Patch
@medusajs/framework Patch
@medusajs/js-sdk Patch
@medusajs/modules-sdk Patch
@medusajs/orchestration Patch
@medusajs/types Patch
@medusajs/utils Patch
@medusajs/workflows-sdk Patch
@medusajs/cli Patch
@medusajs/deps Patch
@medusajs/telemetry Patch
@medusajs/admin-sdk Patch
@medusajs/admin-shared Patch
@medusajs/admin-vite-plugin Patch
@medusajs/icons Patch
@medusajs/toolbox Patch
@medusajs/ui-preset Patch
create-medusa-app Patch
medusa-dev-cli Patch
@medusajs/ui Patch

Not sure what this means? Click here to learn what changesets are.

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

@NicolasGorga
Copy link
Copy Markdown
Contributor

@claude review this

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.


await mutateAsync(returnReason.id, {
onSuccess: () => {
toast.success(t("returnReasons.delete.successToast"))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing label interpolation in delete success toast

Medium Severity

The t("returnReasons.delete.successToast") call is missing the { label } interpolation parameter. The translation string expects {{label}} (Return reason "{{label}}" was successfully deleted.), so the toast will render with a raw placeholder or empty string instead of the actual reason label. The old code correctly passed { label }. This was likely copied from the refund reasons page, where the translation string doesn't use interpolation — but the return reasons one does. The returnReason variable is available in the enclosing handleDelete callback and its label property needs to be passed.

Fix in Cursor Fix in Web

@cursor
Copy link
Copy Markdown

cursor bot commented Mar 25, 2026

You have used all of your free Bugbot PR reviews.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

@TheSeydiCharyyev
Copy link
Copy Markdown
Author

Addressed the review feedback:

  1. Removed the orphaned useDeleteReturnReasonAction hook file — no longer used after migrating to inline delete logic with useDeleteReturnReasonLazy
  2. Fixed missing { label } interpolation in the delete success toast (returnReasons.delete.successToast)

@medusa-os-bot
Copy link
Copy Markdown

medusa-os-bot bot commented Apr 9, 2026

Thank you for your contribution!

After reviewing this PR, we need a few things addressed before we can move forward:

Required changes:

  • Add a changeset file under .changeset/. Since this is a bug fix, the message should follow the format fix(dashboard): short description with a patch bump for @medusajs/dashboard. You can generate one by running yarn changeset from the repo root.

The implementation itself looks solid — it correctly mirrors the pattern already used by the Refund Reasons page, the PR template is complete, and the linked issue (#14812) is valid and open.

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 10, 2026

You have used all of your free Bugbot PR reviews.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

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.

[Admin] Return Reasons list uses legacy _DataTable, missing search/sort unlike Refund Reasons

2 participants