summaryrefslogtreecommitdiffstats
path: root/src/components/organisms/forms/search-form.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/organisms/forms/search-form.tsx')
-rw-r--r--src/components/organisms/forms/search-form.tsx14
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 (