Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.67 KB | None | 0 0
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3.  
  4. import {
  5. TextInput,
  6. FormGroup,
  7. Checkbox,
  8. } from '../../../../../shared/libs/form';
  9.  
  10. import * as constants from '../../../constants';
  11. import { DropDown } from '../../../../../components';
  12. import ExtensionsCheckboxList from '../../../modals/ModalTemporalRules/DaysOfTheWeekCheckboxList';
  13. import Accordion from '../../../../Accordion';
  14.  
  15. /**
  16. * This function represents the Configuration Tab of the Initial Block.
  17. *
  18. * @param {Object} props - Object with props of the component.
  19. * @param {Object} props.translations - The translations.
  20. * @param {Array} props.extensions - The extensions of domain.
  21. * @param {number} props.numSelectedExt - Number of extensions selected.
  22. *
  23. * @returns {Object} Returns the JSX.
  24. */
  25. const Configuration = ({ translations, extensions, numSelectedExt }) => (
  26. <React.Fragment>
  27. <FormGroup
  28. title={translations.getTranslation('initialBlockMenuName')}
  29. className="gof-blockCardForm-textTitles"
  30. >
  31. <TextInput
  32. placeholder={translations.getTranslation('initialBlockTitle')}
  33. fieldName={constants.forms.initialBlock.fieldNames.TITLE}
  34. validationRules={{ maxLength: 50 }}
  35. validateOnChange
  36. showErrorFeedback
  37. messageErrorFeedback={translations.getTranslation('fieldTooLong')}
  38. />
  39. </FormGroup>
  40.  
  41. <FormGroup
  42. title={translations.getTranslation('initialBlockOptions')}
  43. className="gof-blockCardForm-textTitles"
  44. >
  45. <div>
  46. <DropDown
  47. numSelectedExt={numSelectedExt}
  48. allLabel={translations.getTranslation('DropDownAll')}
  49. renderOptions={(options) => {
  50. if (options.length === 0) {
  51. return null;
  52. }
  53. return (
  54. <Accordion
  55. initialBlock
  56. allowAdd={false}
  57. id="extentions_accordion"
  58. data={[
  59. {
  60. uuid: '',
  61. top: `${translations.getTranslation('extensions')}`,
  62. content: (
  63. <ExtensionsCheckboxList
  64. fieldName={constants.forms.initialBlock.fieldNames.EXTENSIONS}
  65. options={options}
  66. initialBlock
  67. persistValueOnUnmount
  68. />
  69. ),
  70. },
  71. ]}
  72. />
  73. );
  74. }
  75. }
  76. allowFilterOptions
  77. initialBlock
  78. options={extensions.map(extension => ({
  79. id: extension.extension,
  80. label: extension.extension,
  81. }))}
  82. value={translations.getTranslation('select')}
  83. inputPlaceholder={translations.getTranslation('filterInputExtensions').filterPlaceholder}
  84. noRecordsPlaceholder={translations.getTranslation('filterInputExtensions').noResultsFound}
  85. />
  86. </div>
  87. </FormGroup>
  88.  
  89. <FormGroup
  90. className="container row d-flex justify-content-between gof-blockCardForm-textTitles"
  91. >
  92. <Checkbox
  93. fieldName={constants.forms.initialBlock.fieldNames.CALL_RECORDING}
  94. labelClassname="gof-form-checkbox__callRecording"
  95. label={translations.getTranslation(constants.tabsBlockCard.CALL_RECORDING)}
  96. big
  97. />
  98. </FormGroup>
  99. </React.Fragment>
  100. );
  101. Configuration.propTypes = {
  102. translations: PropTypes.object.isRequired,
  103. extensions: PropTypes.arrayOf(PropTypes.any),
  104. numSelectedExt: PropTypes.number,
  105. };
  106.  
  107. Configuration.defaultProps = {
  108. extensions: [],
  109. numSelectedExt: 0,
  110. };
  111.  
  112. export default Configuration;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement