Skip to content

fix(products): redirect unknown product id to list instead of dangling URL#1742

Open
Shreyag02 wants to merge 1 commit into
mainfrom
fix/products-create-url-redirect
Open

fix(products): redirect unknown product id to list instead of dangling URL#1742
Shreyag02 wants to merge 1 commit into
mainfrom
fix/products-create-url-redirect

Conversation

@Shreyag02

Copy link
Copy Markdown
Contributor

Summary

Fixes the /products/create staging URL, which rendered the Products list page but left the URL stuck at /products/create. There is no product-create page in the admin UI (products are managed directly in the DB via YAML), so any unresolved product id now cleanly falls back to the list.

Changes

  • Redirect to /products when the URL carries a product id that resolves to no product (covers /products/create and any stale/invalid id).
  • Reuses the existing "close detail" navigation instead of adding a special-case route for create.

Technical Details

  • /products/create was matching the dynamic products/:productId route with productId = "create". ProductsView found no matching product and silently showed the list, but the URL never updated.
  • Added an effect in ProductsView that calls onCloseDetail (→ navigate("/products")) when a selectedProductId resolves to no product — only after the list has finished loading, and skipped on load error so a valid deep link isn't bounced when it's the list fetch that failed.

Test Plan

  • Manual testing completed
    • /products/create → redirects to /products and shows the list.
    • /products/ → redirects to /products.
    • /products/ → opens the product detail as before.
    • Direct load / refresh on a valid product id doesn't get bounced mid-load.
  • Build and type checking passes (no new type errors introduced)

SQL Safety (if your PR touches *_repository.go or goqu.*)

N/A

@vercel

vercel Bot commented Jul 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
frontier Ready Ready Preview, Comment Jul 8, 2026 9:12am

@Shreyag02 Shreyag02 requested a review from rohanchkrabrty July 8, 2026 09:13
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6f65ca65-7930-433a-a716-3ad298b43ea1

📥 Commits

Reviewing files that changed from the base of the PR and between 545ee21 and 1adce1a.

📒 Files selected for processing (1)
  • web/sdk/admin/views/products/index.tsx

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • The product detail view now closes automatically if the selected product is no longer available after loading completes.
    • Prevents the interface from showing an invalid or stale product detail state when a product can’t be found.

Walkthrough

Adds a useEffect hook to ProductsView that, after product list loading completes without error, detects if selectedProductId does not match any loaded product and invokes onCloseDetail to clear the detail sheet state.

Changes

Products detail auto-close

Layer / File(s) Summary
Detect unknown selected product and close detail
web/sdk/admin/views/products/index.tsx
Imports useEffect and adds an effect that closes the detail sheet via onCloseDetail when selectedProductId has no matching product after loading finishes without error.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 28931371043

Coverage remained the same at 44.879%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 37621
Covered Lines: 16884
Line Coverage: 44.88%
Coverage Strength: 12.49 hits per line

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants