aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/organisms/modals/search-modal.tsx
blob: 08b28cb8f965453c4f38d76525bf65da1af5c79e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { forwardRef, ForwardRefRenderFunction } from 'react';
import { useIntl } from 'react-intl';
import Modal, { type ModalProps } from '../../molecules/modals/modal';
import SearchForm, { type SearchFormProps } from '../forms/search-form';
import styles from './search-modal.module.scss';

export type SearchModalProps = SearchFormProps & {
  /**
   * Set additional classnames to modal wrapper.
   */
  className?: ModalProps['className'];
};

/**
 * SearchModal
 *
 * Render a search form modal.
 */
const SearchModal: ForwardRefRenderFunction<
  HTMLInputElement,
  SearchModalProps
> = ({ className, searchPage }, ref) => {
  const intl = useIntl();
  const modalTitle = intl.formatMessage({
    defaultMessage: 'Search',
    description: 'SearchModal: modal title',
    id: 'G+Twgm',
  });

  return (
    <Modal title={modalTitle} className={`${styles.wrapper} ${className}`}>
      <SearchForm hideLabel={true} ref={ref} searchPage={searchPage} />
    </Modal>
  );
};

export default forwardRef(SearchModal);