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

Version2: Add certificate search logic #167

Open
wants to merge 6 commits into
base: donskov/v2
Choose a base branch
from

Conversation

OleksandrSPV
Copy link
Collaborator

Screen.Recording.2024-07-04.at.18.56.29.mov

@OleksandrSPV OleksandrSPV self-assigned this Jul 4, 2024
@OleksandrSPV OleksandrSPV linked an issue Jul 4, 2024 that may be closed by this pull request
@OleksandrSPV OleksandrSPV marked this pull request as ready for review July 5, 2024 11:42
@OleksandrSPV OleksandrSPV requested a review from donskov July 5, 2024 11:42
import { CertificateProps } from "../../types";

export function useSearchList(certificates: CertificateProps[]) {
const searchParams = new URLSearchParams(window.location.search);
Copy link
Collaborator

Choose a reason for hiding this comment

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

We need to use the searchParams only for default state prefilling, but this code calls on each rerender. We have to fix this and parse parameters only 1 time.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@donskov Fixed here 3de8b75

return {
searchedText,
list: searchedText
? certificates.filter(({ label }) =>
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's the same situation with multiple re-renders. We should try to make filtration only when the searchedText or the certificates have changed. Now, even when opening a dialog, we filter certificates.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@donskov Fixed here 3de8b75

@donskov
Copy link
Collaborator

donskov commented Jul 11, 2024

@OleksandrSPV Not related to these changes, but is there any reason to have the search state in the search hook and two search states in the component? Can we use only a single source of truth?

@OleksandrSPV
Copy link
Collaborator Author

OleksandrSPV commented Jul 15, 2024

@OleksandrSPV Not related to these changes, but is there any reason to have the search state in the search hook and two search states in the component? Can we use only a single source of truth?

@donskov I needed to use delayed input, so I decided use this part near the input component not in search hook.
As I see guys on Goodkey don't use input delay for certificate search, we can go this way if you prefer, and remove one state from search component, or if you have another proposition, please let me know.

@donskov
Copy link
Collaborator

donskov commented Jul 16, 2024

@OleksandrSPV Not related to these changes, but is there any reason to have the search state in the search hook and two search states in the component? Can we use only a single source of truth?

@donskov I needed to use delayed input, so I decided use this part near the input component not in search hook. As I see guys on Goodkey don't use input delay for certificate search, we can go this way if you prefer, and remove one state from search component, or if you have another proposition, please let me know.

Yeah, let's remove it.

@OleksandrSPV
Copy link
Collaborator Author

@OleksandrSPV Not related to these changes, but is there any reason to have the search state in the search hook and two search states in the component? Can we use only a single source of truth?

@donskov I needed to use delayed input, so I decided use this part near the input component not in search hook. As I see guys on Goodkey don't use input delay for certificate search, we can go this way if you prefer, and remove one state from search component, or if you have another proposition, please let me know.

Yeah, let's remove it.

@donskov removed here 93c9ee7

@donskov
Copy link
Collaborator

donskov commented Jul 16, 2024

@OleksandrSPV Not related to these changes, but is there any reason to have the search state in the search hook and two search states in the component? Can we use only a single source of truth?

@donskov I needed to use delayed input, so I decided use this part near the input component not in search hook. As I see guys on Goodkey don't use input delay for certificate search, we can go this way if you prefer, and remove one state from search component, or if you have another proposition, please let me know.

Yeah, let's remove it.

@donskov removed here 93c9ee7

Do we also need the search input state (const [searchInputValue, setSearchInputValue] = React.useState(searchValue);)?

@OleksandrSPV
Copy link
Collaborator Author

OleksandrSPV commented Jul 16, 2024

235b1fd

@donskov oops, actually don't need, fixed here 235b1fd

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.

Add certificate search logic
3 participants