import FormTimePicker from '@material-hu/components/composed-components/TimePicker/form';

import useRules from 'src/hooks/useRules';
import { useLokaliseTranslation } from 'src/utils/i18n';

export type TimeInputProps = {
  name: string;
  required?: boolean;
  formFilled?: boolean;
};

export const TimeInput = ({ name, required, formFilled }: TimeInputProps) => {
  const { t } = useLokaliseTranslation('validations');

  return (
    <FormTimePicker
      name={name}
      rules={useRules({
        requiredWithMessage: required && !formFilled ? t('required') : false,
      })}
      inputProps={{
        disabled: formFilled,
        fullWidth: true,
        minutesStep: 1,
      }}
    />
  );
};

export default TimeInput;
