aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/organisms/modals/settings-modal.tsx
blob: 5d14836b2df4ee883f24f7122068f5fdd654b222 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import Spinner from '@components/atoms/loaders/spinner';
import Modal, { type ModalProps } from '@components/molecules/modals/modal';
import dynamic from 'next/dynamic';
import { FC } from 'react';
import { useIntl } from 'react-intl';
import { type SettingsFormProps } from '../forms/settings-form';
import styles from './settings-modal.module.scss';

const DynamicSettingsForm = dynamic(
  () => import('@components/organisms/forms/settings-form'),
  {
    loading: () => <Spinner />,
    ssr: false,
  }
);

export type SettingsModalProps = Pick<ModalProps, 'className'> &
  Pick<
    SettingsFormProps,
    'ackeeStorageKey' | 'motionStorageKey' | 'tooltipClassName'
  >;

/**
 * SettingsModal component
 *
 * Render a modal with settings options.
 */
const SettingsModal: FC<SettingsModalProps> = ({
  className = '',
  ...props
}) => {
  const intl = useIntl();
  const title = intl.formatMessage({
    defaultMessage: 'Settings',
    description: 'SettingsModal: title',
    id: 'gPfT/K',
  });

  return (
    <Modal
      title={title}
      icon="cogs"
      className={`${styles.wrapper} ${className}`}
      headingClassName={styles.heading}
    >
      <DynamicSettingsForm {...props} />
    </Modal>
  );
};

export default SettingsModal;