// Libs
// -----------------------------------------------------------------------------
import React, { FC, Fragment } from 'react';
import { Form, Input, Row, Col } from 'antd';
import { Rule } from 'antd/lib/form';

// App
// -----------------------------------------------------------------------------
import { CommonActionFormProps } from './CommonActionFormProps';
import { useCorrelationRulesTemplateMessages } from '../../i18n';

export const BashActionForm: FC<CommonActionFormProps> = ({
  name,
  isDisabled,
}) => {
  const locale = useCorrelationRulesTemplateMessages();
  const fieldStrings = locale.actionsRuleMessage.blockMessages.bashMessage;
  const fieldRules: Array<Rule> = [
    { required: true, message: locale.formValidationMessages.emptyField },
  ];

  return (
    <Fragment>
      <Form.Item name={[name, 'type']} rules={fieldRules} hidden>
        <Input type="hidden" disabled={isDisabled} />
      </Form.Item>

      <Row gutter={[32, 0]}>
        <Col span={24}>
          <Form.Item
            name={[name, 'body']}
            label={fieldStrings.body.title}
            rules={fieldRules}
          >
            <Input.TextArea
              placeholder={fieldStrings.body.placeholder}
              disabled={isDisabled}
              rows={5}
            />
          </Form.Item>
        </Col>
      </Row>
    </Fragment>
  );
};
