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

import { useTranslation } from 'src/pages/dashboard/recognitions/i18n';
import { IdeaObject } from 'src/types/recognitions';

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

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

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

  const { t } = useTranslation();

  return (
    <>
      <TextFieldControl
        name="savings"
        label={t('AVOID_BUYING')}
        placeholder={t('AVOID_BUYING_PLACEHOLDER')}
        control={control}
        defaultValue={defaultValues ? defaultValues.savings : ''}
        isReadOnly={isReadOnly}
      />
      <TextFieldControl
        name="improvedActivities"
        label={t('ACTIVITIES_IMPROVE')}
        control={control}
        defaultValue={defaultValues ? defaultValues.improvedActivities : ''}
        isReadOnly={isReadOnly}
      />
      <TextFieldControl
        name="investment"
        label={t('INVESTMENT')}
        placeholder={t('RESOURCES_USED')}
        control={control}
        defaultValue={defaultValues ? defaultValues.investment : ''}
        isReadOnly={isReadOnly}
        isRequired
      />
    </>
  );
};

export default CapexForm;
