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

Rupato/fix: added content search for different languages #10026

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,29 @@ const Sidebar = observer(() => {
search_input.current.value = '';
setsearchFAQList([]);
}

setsearchFilteredList(guide_tab_content);
setsearchFAQList(faq_content);
}, [active_tab_tutorials, active_tab]);

React.useEffect(() => {
const content_list = active_tab_tutorials === 0 ? guide_tab_content : faq_content;
const filtered_list = content_list.filter(data => {
return content_list === guide_tab_content
? data.content.toLowerCase().includes(faq_search_value)
: data.title.toLowerCase().includes(faq_search_value);
});
return active_tab_tutorials === 0 ? setsearchFilteredList(filtered_list) : setsearchFAQList(filtered_list);
}, [faq_search_value]);
const is_faq = active_tab_tutorials === 1;
const search = faq_search_value?.toLowerCase();

if (is_faq) {
const filtered_list = faq_content?.filter(({ title, description = [] }) => {
const match = description?.map(item => (item.type === 'text' ? item.content : '')).join(' ');
const title_has_match = title?.toLowerCase()?.includes(search);
const description_has_match = match?.toLowerCase()?.includes(search);
return title_has_match || description_has_match;
});
setsearchFAQList(filtered_list);
} else {
const filtered_list = guide_tab_content?.filter(({ content = '' }) =>
content?.toLowerCase()?.includes(search)
);
setsearchFilteredList(filtered_list);
}
}, [faq_search_value, active_tab_tutorials]);

const onSearch = (event: React.ChangeEvent<HTMLInputElement>) => {
const value = event.target.value;
Expand Down