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

fix(medusa): Support q search and order in list regions #6202

Merged
merged 4 commits into from
Jan 24, 2024

Conversation

olivermrbl
Copy link
Contributor

Closes #6174

@olivermrbl olivermrbl requested review from a team as code owners January 24, 2024 10:01
Copy link

changeset-bot bot commented Jan 24, 2024

🦋 Changeset detected

Latest commit: daa61df

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

This PR includes changesets to release 1 package
Name Type
@medusajs/medusa 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

Copy link

vercel bot commented Jan 24, 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 Jan 24, 2024 11:36am
3 Ignored Deployments
Name Status Preview Comments Updated (UTC)
api-reference ⬜️ Ignored (Inspect) Jan 24, 2024 11:36am
docs-ui ⬜️ Ignored (Inspect) Visit Preview Jan 24, 2024 11:36am
medusa-docs ⬜️ Ignored (Inspect) Visit Preview Jan 24, 2024 11:36am

if (q) {
const where = query.where as FindOptionsWhere<Region>

delete where.name
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kasperkristensen, only included the name for now. Let me know if this is sufficient.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that is fine, the only other option I think would make sense was to allow search by country, like how we have search product variants by product title:

if (q) {
query.relations = query.relations ?? {}
query.relations["product"] = query.relations["product"] ?? true
query.where = query.where as FindOptionsWhere<ProductVariant>
delete query.where?.title
query.where = query.where ?? {}
query.where = [
{
...query.where,
title: ILike(`%${q}%`),
},
{
...query.where,
sku: ILike(`%${q}%`),
},
{
...query.where,
product: {
...((query.where.product ??
{}) as FindOptionsWhere<ProductVariant>),
title: ILike(`%${q}%`),
},
},
]
}

Would be cool to be able to search "denmark" and then "Europe" pops up, but I am good with leaving that for a future iteration 😄

@olivermrbl olivermrbl force-pushed the fix/support-q-search-in-regions branch from eb649d6 to ddfb0b9 Compare January 24, 2024 10:21
@olivermrbl olivermrbl force-pushed the fix/support-q-search-in-regions branch from ddfb0b9 to 0b91270 Compare January 24, 2024 10:22
Copy link
Contributor

@kasperkristensen kasperkristensen left a comment

Choose a reason for hiding this comment

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

LGTM!

@olivermrbl olivermrbl merged commit 8ad7539 into develop Jan 24, 2024
16 checks passed
@olivermrbl olivermrbl deleted the fix/support-q-search-in-regions branch January 24, 2024 11:52
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.

bug(medusa): Missing list params on /admin/regions
2 participants