diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-05-15 16:36:58 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-05-15 16:36:58 +0200 |
| commit | 235fe67d770f83131c9ec10b99012319440db690 (patch) | |
| tree | 3b96e2c8a5877fe15a9cfa6bff46130fa7a04a65 /src/components/organisms/forms/search-form.tsx | |
| parent | fe2252ced2bb895e26179640553b5a6c02957d54 (diff) | |
chore: add Search page
Diffstat (limited to 'src/components/organisms/forms/search-form.tsx')
| -rw-r--r-- | src/components/organisms/forms/search-form.tsx | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/components/organisms/forms/search-form.tsx b/src/components/organisms/forms/search-form.tsx index 18b7c08..56d3895 100644 --- a/src/components/organisms/forms/search-form.tsx +++ b/src/components/organisms/forms/search-form.tsx @@ -4,18 +4,24 @@ import MagnifyingGlass from '@components/atoms/icons/magnifying-glass'; import LabelledField, { type LabelledFieldProps, } from '@components/molecules/forms/labelled-field'; +import { useRouter } from 'next/router'; import { FC, useState } from 'react'; import { useIntl } from 'react-intl'; import styles from './search-form.module.scss'; -export type SearchFormProps = Pick<LabelledFieldProps, 'hideLabel'>; +export type SearchFormProps = Pick<LabelledFieldProps, 'hideLabel'> & { + /** + * The search page url. + */ + searchPage: string; +}; /** * SearchForm component * * Render a search form. */ -const SearchForm: FC<SearchFormProps> = ({ hideLabel }) => { +const SearchForm: FC<SearchFormProps> = ({ hideLabel, searchPage }) => { const intl = useIntl(); const fieldLabel = intl.formatMessage({ defaultMessage: 'Search for:', @@ -28,10 +34,12 @@ const SearchForm: FC<SearchFormProps> = ({ hideLabel }) => { id: 'WMqQrv', }); + const router = useRouter(); const [value, setValue] = useState<string>(''); const submitHandler = () => { - return; + router.push({ pathname: searchPage, query: { s: value } }); + setValue(''); }; return ( |
