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

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

  const { t } = useTranslation();

  return (
    <>
      <TextFieldControl
        name="impactedTeams"
        label={t('IDEA_IMPACT')}
        defaultValue={defaultValues ? defaultValues.impactedTeams : ''}
        isReadOnly={isReadOnly}
        control={control}
      />
      <TextFieldControl
        name="delayCodes"
        label={t('DELAY_CODE')}
        defaultValue={defaultValues ? defaultValues.delayCodes : ''}
        isReadOnly={isReadOnly}
        control={control}
      />
      <TextFieldControl
        name="improvedActivities"
        label={t('ACTIVITIES_IMPROVE')}
        defaultValue={defaultValues ? defaultValues.improvedActivities : ''}
        isReadOnly={isReadOnly}
        control={control}
      />
      <TextFieldControl
        name="timeReduction"
        label={t('TIME_REDUCE')}
        placeholder={t('TIME_PLACEHOLDER')}
        defaultValue={defaultValues ? defaultValues.timeReduction : ''}
        isReadOnly={isReadOnly}
        control={control}
      />
      <TextFieldControl
        name="improvedStandards"
        label={t('STANDARD_IMPROVE')}
        placeholder={t('STANDARD_CHANGE')}
        defaultValue={defaultValues ? defaultValues.improvedStandards : ''}
        isReadOnly={isReadOnly}
        control={control}
        isRequired
      />
    </>
  );
};

export default ProductivityForm;
