import { FC } from 'react';
import { Control } from 'react-hook-form';

import {
  OCURRENCE_OPTIONS,
  SEVERITY_OPTIONS,
} from 'src/constants/recognitions';
import { useTranslation } from 'src/pages/dashboard/recognitions/i18n';
import { IdeaObject } from 'src/types/recognitions';

import MultipleToggleControl from '../formControls/MultipleToggleControl';
import TextFieldControl from '../formControls/TextFieldControl';

export type SecurityFormProps = {
  control?: Control;
  defaultValues?: IdeaObject;
  isReadOnly?: boolean;
};

export const SecurityForm: FC<SecurityFormProps> = props => {
  const { control = null, defaultValues = null, isReadOnly = false } = props;

  const { t } = useTranslation();

  return (
    <>
      <TextFieldControl
        name="existingDangers"
        label={t('HAZARDS')}
        placeholder={t('EXISTING_HAZARDS')}
        control={control}
        defaultValue={defaultValues ? defaultValues.existingDangers : ''}
        isReadOnly={isReadOnly}
      />
      <MultipleToggleControl
        name="ocurrence"
        label={t('OCURRENCE_PROBABILITY')}
        options={OCURRENCE_OPTIONS}
        control={control}
        defaultValue={defaultValues ? defaultValues.ocurrence : null}
        isReadOnly={isReadOnly}
      />
      <MultipleToggleControl
        name="severity"
        label={t('SEVERITY')}
        options={SEVERITY_OPTIONS}
        control={control}
        defaultValue={defaultValues ? defaultValues.severity : null}
        isReadOnly={isReadOnly}
      />
      <TextFieldControl
        name="improvedStandards"
        label={t('STANDARD_IMPROVE')}
        placeholder={t('STANDARD_CHANGE')}
        control={control}
        defaultValue={defaultValues ? defaultValues.improvedStandards : ''}
        isReadOnly={isReadOnly}
      />
    </>
  );
};

export default SecurityForm;
