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

Feature/add treecluster filter #40

Merged
merged 12 commits into from
Sep 16, 2024
Merged

Conversation

doriengr
Copy link
Contributor

@doriengr doriengr commented Sep 13, 2024

refs #26

@doriengr doriengr self-assigned this Sep 13, 2024
@doriengr doriengr marked this pull request as ready for review September 15, 2024 05:59
@doriengr doriengr added the need-reviewer Send notification in Discord label Sep 15, 2024
Copy link
Member

@choffmann choffmann left a comment

Choose a reason for hiding this comment

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

👍 👍 👍

Well done! Now I'm happy, now you don't skip the react render logic and everything works. I changed the router definition a little bit as well as the zod schema to get an array of strings, so you dont have to do it manually

Comment on lines +9 to +10
status: z.array(z.string()).optional(),
region: z.array(z.string()).optional(),
Copy link
Member

@choffmann choffmann Sep 15, 2024

Choose a reason for hiding this comment

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

I have changed this to an array of strings, so you do not need to do this manually.

Comment on lines +29 to +37
const search = useLoaderData({ from: '/_protected/treecluster/' });

const [statusTags, setStatusTags] = useState<string[]>(search.status);
const [regionTags, setRegionTags] = useState<string[]>(search.region);

useEffect(() => {
if (search.status) setStatusTags(search.status);
if (search.region) setRegionTags(search.region);
}, [search.status, search.region]);
Copy link
Member

Choose a reason for hiding this comment

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

And because we have parsed it in the router loader, we can access the data with the useLoaderData hook.

Comment on lines +17 to +20
loaderDeps: ({ search: { status, region } }) => ({
status: status || [],
region: region || [],
}),
Copy link
Member

Choose a reason for hiding this comment

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

So now we can say that if it's not undefined, take the search param as an array, otherwise use an empty array.

@doriengr doriengr merged commit 9933892 into develop Sep 16, 2024
1 check passed
@doriengr doriengr deleted the feature/add-treecluster-filter branch September 16, 2024 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need-reviewer Send notification in Discord
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants