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

import { RAW_MATERIAL_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 RawMaterialFormProps = {
  control?: Control;
  defaultValues?: IdeaObject;
  isReadOnly?: boolean;
};

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

  const { t } = useTranslation();

  return (
    <>
      <MultipleToggleControl
        name="materialSavings"
        label={t('SAVING_TYPE')}
        options={RAW_MATERIAL_OPTIONS}
        control={control}
        defaultValue={defaultValues ? defaultValues.materialSavings : ''}
        isReadOnly={isReadOnly}
        longText
      />
      <TextFieldControl
        name="kgsWasted"
        label={t('KG_WASTED')}
        control={control}
        defaultValue={defaultValues ? defaultValues.kgsWasted : ''}
        isReadOnly={isReadOnly}
        isRequired
      />
      <TextFieldControl
        name="kgsWastedAfter"
        label={t('KG_WASTED_AFTER')}
        control={control}
        defaultValue={defaultValues ? defaultValues.kgsWastedAfter : ''}
        isReadOnly={isReadOnly}
        isRequired
      />
      <TextFieldControl
        name="improvedStandards"
        label={t('INVESTMENT')}
        placeholder={t('RESOURCES_USED')}
        control={control}
        defaultValue={defaultValues ? defaultValues.improvedStandards : ''}
        isReadOnly={isReadOnly}
        isRequired
      />
    </>
  );
};

export default RawMaterialForm;
