VaibhavArora314 / StyleShare

A simple web based platform where users can easily create, explore, and share Tailwind CSS components and designs with fellow users.
https://style-share.vercel.app
MIT License
40 stars 68 forks source link

[Feature Request]: Improve search posts #340

Closed Parth18Shah closed 3 months ago

Parth18Shah commented 4 months ago

Is there an existing issue for this?

Feature Description

Currently, users can input only one character at a time since the posts are filtered with each character typed. I plan to make the process more dynamic by displaying the search bar while posts are still loading and updating the displayed posts based on the current input.

Use Case

Improve UX for searching posts.

Benefits

Improve UX for searching posts.

Add ScreenShots

No response

Priority

High

Record

github-actions[bot] commented 4 months ago

Thank you for creating this issue! 🎉 We'll look into it as soon as possible. In the meantime, please make sure to provide all the necessary details and context. If you have any questions or additional information, feel free to add them here. Your contributions are highly appreciated! 😊

You can also check our CONTRIBUTING.md for guidelines on contributing to this project.

VaibhavArora314 commented 4 months ago

can you please explain more about this

Parth18Shah commented 4 months ago

Hello, apologies for the delay in my response. I had reached out to you on Discord, but I will reply here as well. Basically, my issue included the bug covered by Meet in his issue #362. I noticed he had checked the option of "I have searched the existing issues" but never mentioned my issue. Now, I don't mind him covering a particular task of mine even though I made an issue of it before he did, but I understand since I could not respond in time to your comment on my issue. If you want, you could close this issue, or I could try making the search dynamic i.e. remove the button next to the input field, which has its own pros and cons.

VaibhavArora314 commented 4 months ago

Hello, apologies for the delay in my response. I had reached out to you on Discord, but I will reply here as well. Basically, my issue included the bug covered by Meet in his issue #362. I noticed that he had checked the option of "I have searched the existing issues" but never mentioned my issue. Now, I don't mind him covering a particular task of mine even though I made an issue of it before he did, but I understand since I could not respond in time to your comment on my issue. If you want, you could close this issue, or I could try making the search dynamic i.e. remove the button next to the input field, which has its own pros and cons.

sorry for the late response as for the search functionality, I think you can implement order functionality like users can order posts by date or reactions. Currently, it is implemented by the count of reactions so you will have to modify that API to serve based on date if the user specifies else by default show by reactions.

VaibhavArora314 commented 4 months ago

if you are willing to implement this you can reply here, I will assign you this

Parth18Shah commented 4 months ago

Sure, I can implement it. So do you want me to create a separate option next to the search bar to sort by a particular type or change the order search result itself. The former will be better, in my opinion, since it will provide the users with more options to search for a particular post they want.

VaibhavArora314 commented 4 months ago

Sure, I can implement it. So do you want me to create a separate option next to the search bar to sort by a particular type or change the order search result itself. The former will be better, in my opinion, since it will provide the users with more options to search for a particular post they want.

yes we will provide the user with an option to change ordering

Parth18Shah commented 4 months ago

Understood, I will start working on it. Thanks for the clarification.

Parth18Shah commented 3 months ago

Could you please help me with the sorting on the server side. I am currently sending an additional parameter to the getPostsWithPagination controller to handle sorting. In the controller, I have generalized the orderBy query based on the sortBy parameter received. The code snippet is as follows:

const orderPosts = sortOrder === 'reactions' ? { reactions: { _count: 'desc' } } : { createdAt: 'desc' };

Unfortunately, the orderBy query is unable to accept a variable as input, as either reactions or createdAt will be undefined in one of the cases. How should I proceed to handle this sorting dynamically on the server side?

VaibhavArora314 commented 3 months ago

Could you please help me with the sorting on the server side. I am currently sending an additional parameter to the getPostsWithPagination controller to handle sorting. In the controller, I have generalized the orderBy query based on the sortBy parameter received. The code snippet is as follows:

const orderPosts = sortOrder === 'reactions' ? { reactions: { _count: 'desc' } } : { createdAt: 'desc' };

Unfortunately, the orderBy query is unable to accept a variable as input, as either reactions or createdAt will be undefined in one of the cases. How should I proceed to handle this sorting dynamically on the server side?

This may help https://stackoverflow.com/questions/73680309/dynamic-sorting-in-prisma-and-typed-queries

Parth18Shah commented 3 months ago

Yes, thank you. Wrapping orderBy with a const worked. Thanks.

Parth18Shah commented 3 months ago

I will try adding an option to sort in ascending or descending order for both of those options.

github-actions[bot] commented 3 months ago

Hello @Parth18Shah! Your issue #340 has been closed. Thank you for your contribution!