Skip to content
Snippets Groups Projects

feat: add category pins rendering and global search input

Merged Adrian Orłów requested to merge display-pins-of-categories into development
All threads resolved!
20 files
+ 155
63
Compare changes
  • Side-by-side
  • Inline
Files
20
@@ -8,26 +8,18 @@ import {
@@ -8,26 +8,18 @@ import {
} from '@/redux/search/search.selectors';
} from '@/redux/search/search.selectors';
import { getSearchData } from '@/redux/search/search.thunks';
import { getSearchData } from '@/redux/search/search.thunks';
import Image from 'next/image';
import Image from 'next/image';
import { ChangeEvent, KeyboardEvent, useEffect, useState } from 'react';
import { ChangeEvent, KeyboardEvent, useState } from 'react';
import { useSelector } from 'react-redux';
import { useSelector } from 'react-redux';
import { useRouter } from 'next/router';
import { getDefaultSearchTab, getSearchValuesArrayAndTrimToSeven } from './SearchBar.utils';
import { getDefaultSearchTab, getSearchValuesArrayAndTrimToSeven } from './SearchBar.utils';
const ENTER_KEY_CODE = 'Enter';
const ENTER_KEY_CODE = 'Enter';
export const SearchBar = (): JSX.Element => {
export const SearchBar = (): JSX.Element => {
 
const [searchValue, setSearchValue] = useState<string>('');
const isPendingSearchStatus = useSelector(isPendingSearchStatusSelector);
const isPendingSearchStatus = useSelector(isPendingSearchStatusSelector);
const isDrawerOpen = useSelector(isDrawerOpenSelector);
const isDrawerOpen = useSelector(isDrawerOpenSelector);
const isPerfectMatch = useSelector(perfectMatchSelector);
const isPerfectMatch = useSelector(perfectMatchSelector);
const [searchValue, setSearchValue] = useState<string>('');
const dispatch = useAppDispatch();
const dispatch = useAppDispatch();
const { query } = useRouter();
useEffect(() => {
if (!searchValue && query.searchValue) {
setSearchValue(String(query.searchValue));
}
}, [searchValue, query]);
const openSearchDrawerIfClosed = (defaultSearchTab: string): void => {
const openSearchDrawerIfClosed = (defaultSearchTab: string): void => {
if (!isDrawerOpen) {
if (!isDrawerOpen) {
@@ -35,8 +27,9 @@ export const SearchBar = (): JSX.Element => {
@@ -35,8 +27,9 @@ export const SearchBar = (): JSX.Element => {
}
}
};
};
const onSearchChange = (event: ChangeEvent<HTMLInputElement>): void =>
const onSearchChange = (event: ChangeEvent<HTMLInputElement>): void => {
setSearchValue(event.target.value);
setSearchValue(event.target.value);
 
};
const onSearchClick = (): void => {
const onSearchClick = (): void => {
const searchValues = getSearchValuesArrayAndTrimToSeven(searchValue);
const searchValues = getSearchValuesArrayAndTrimToSeven(searchValue);
Loading