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

refactor(picker-starter): place query and filters logic directly into the picker.config.ts file #91

Conversation

demetriusfeijoo
Copy link
Contributor

Issue: EXT-2135

What?

This PR places all query and filter logic directly into the picker.config.ts file

Why?

The idea of this change is to provide a better experience for developers using this starter by placing the core logic for fetching items and filters directly into the main file of this project which is the picker.config.ts file.

Copy link

vercel bot commented Jan 4, 2024

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

Name Status Preview Comments Updated (UTC)
code-block ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 5, 2024 11:55am

@demetriusfeijoo demetriusfeijoo marked this pull request as ready for review January 4, 2024 12:55
Copy link
Contributor

@eunjae-lee eunjae-lee left a comment

Choose a reason for hiding this comment

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

This seems much easier compared to the previous :)
I've left some feedback.

label: 'Categories',
name: 'categoryMulti',
defaultValue: [],
options: categoryMockAssets.map((category) => ({
Copy link
Contributor

Choose a reason for hiding this comment

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

what if categoryMockAssets is just categories? like items above.

Or we could name them something like:

  • sampleItems
  • sampleCategories

"mock" feels like unit testing to me.

Comment on lines 30 to 32
const filteredItems = items
.filter(matchCategories(filterSelection['categoryMulti'] as string[]))
.filter(matchItem(searchTerm))
Copy link
Contributor

Choose a reason for hiding this comment

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

matchItem sounds a bit unintuitive to me. It can be something like matchSearchTerm...?

Or we could rename them altogether like:

        const filteredItems = items
          .filter(filterByCategories(filterSelection['categoryMulti'] as string[]))
          .filter(filterBySearchTerm(searchTerm))

What do you think? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

matchItem sounds a bit unintuitive to me. It can be something like matchSearchTerm...?

Yeah, you're totally right, matchSearchTerm is much better.

About the filterByCategories and filterBySearchTerm renaming, I'm not too sure.
These names suggest to me this function is going to perform the filtering action while it doesn't.

I don't know... somehow using match... was more meaningful to me.

What do you think, @eunjae-lee?

Copy link
Contributor

Choose a reason for hiding this comment

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

okay, then it sounds good. let's merge!

Copy link
Contributor Author

@demetriusfeijoo demetriusfeijoo left a comment

Choose a reason for hiding this comment

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

Thanks for you feedback, @eunjae-lee.
Great suggestions 💯

I've applied them already ✅

016af1d
a83dd8c

Comment on lines 30 to 32
const filteredItems = items
.filter(matchCategories(filterSelection['categoryMulti'] as string[]))
.filter(matchItem(searchTerm))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

matchItem sounds a bit unintuitive to me. It can be something like matchSearchTerm...?

Yeah, you're totally right, matchSearchTerm is much better.

About the filterByCategories and filterBySearchTerm renaming, I'm not too sure.
These names suggest to me this function is going to perform the filtering action while it doesn't.

I don't know... somehow using match... was more meaningful to me.

What do you think, @eunjae-lee?

@demetriusfeijoo demetriusfeijoo merged commit 6870040 into main Jan 5, 2024
4 checks passed
@demetriusfeijoo demetriusfeijoo deleted the EXT-2135-place-query-and-query-options-logic-directly-into-picker-config-ts-file branch January 5, 2024 15:42
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