@bigbinary/neeto-message-templates-frontend 0.6.7 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4,7 +4,8 @@ import { buildFiltersFromURL, Bar } from '@bigbinary/neeto-filters-frontend';
4
4
  import Container from '@bigbinary/neeto-molecules/Container';
5
5
  import NeetoHeader from '@bigbinary/neeto-molecules/Header';
6
6
  import SubHeader from '@bigbinary/neeto-molecules/SubHeader';
7
- import { Button, Typography, Pane, Table, NoData, Alert, Select, Textarea as Textarea$1, Label } from '@bigbinary/neetoui';
7
+ import Button from '@bigbinary/neetoui/Button';
8
+ import Typography from '@bigbinary/neetoui/Typography';
8
9
  import { isEmpty, equals, prop, includes, pick, omit, assoc, mergeAll, pluck, whereAny, reject, modify } from 'ramda';
9
10
  import { useTranslation, Trans } from 'react-i18next';
10
11
  import { t as t$1 } from 'i18next';
@@ -15,13 +16,24 @@ import { useQuery } from 'react-query';
15
16
  import axios from 'axios';
16
17
  import require$$0 from 'util';
17
18
  import { create } from 'zustand';
19
+ import Pane from '@bigbinary/neetoui/Pane';
18
20
  import { FormikEditor } from '@bigbinary/neeto-editor';
19
- import { Textarea, Input, Form as Form$2, ActionBlock, Select as Select$1 } from '@bigbinary/neetoui/formik';
21
+ import NeetoUIForm from '@bigbinary/neetoui/formik/Form';
22
+ import Input from '@bigbinary/neetoui/formik/Input';
23
+ import ActionBlock from '@bigbinary/neetoui/formik/ActionBlock';
20
24
  import { useFormikContext, FieldArray } from 'formik';
25
+ import Textarea from '@bigbinary/neetoui/formik/Textarea';
21
26
  import { isPhoneNumberValid } from '@bigbinary/neeto-molecules/PhoneNumber';
22
27
  import * as yup from 'yup';
23
28
  import TableWrapper from '@bigbinary/neeto-molecules/TableWrapper';
29
+ import Alert from '@bigbinary/neetoui/Alert';
30
+ import Table from '@bigbinary/neetoui/Table';
31
+ import NoData from '@bigbinary/neetoui/NoData';
32
+ import Select from '@bigbinary/neetoui/Select';
33
+ import Textarea$1 from '@bigbinary/neetoui/Textarea';
34
+ import Select$1 from '@bigbinary/neetoui/formik/Select';
24
35
  import { Delete } from '@bigbinary/neeto-icons';
36
+ import Label from '@bigbinary/neetoui/Label';
25
37
 
26
38
  function _typeof$1(o) {
27
39
  "@babel/helpers - typeof";
@@ -3072,7 +3084,7 @@ var Form$1 = function Form(_ref) {
3072
3084
  });
3073
3085
  };
3074
3086
  var messageBodyLabel = isEmailTemplate ? t("neetoMessageTemplate.template.emailBody") : t("neetoMessageTemplate.template.smsBody");
3075
- return /*#__PURE__*/React.createElement(Form$2, {
3087
+ return /*#__PURE__*/React.createElement(NeetoUIForm, {
3076
3088
  formProps: {
3077
3089
  noValidate: true,
3078
3090
  className: "flex w-full flex-col gap-y-4 pb-6"
@@ -3531,7 +3543,7 @@ var EmailAndSms = function EmailAndSms(_ref) {
3531
3543
  var updatedInitialValues = mergeAll([INITIAL_VALUES, customFieldsInitialValues]);
3532
3544
  var updatedValidationSchema = yup.object().shape(_objectSpread$3(_objectSpread$3({}, SEND_MESSAGE_FORM_SCHEMA === null || SEND_MESSAGE_FORM_SCHEMA === void 0 ? void 0 : SEND_MESSAGE_FORM_SCHEMA.fields), customFieldsValidationSchema === null || customFieldsValidationSchema === void 0 ? void 0 : customFieldsValidationSchema.fields));
3533
3545
  var initialValueKeys = Object.keys(INITIAL_VALUES);
3534
- return /*#__PURE__*/React.createElement(Form$2, {
3546
+ return /*#__PURE__*/React.createElement(NeetoUIForm, {
3535
3547
  formProps: {
3536
3548
  noValidate: true,
3537
3549
  className: "flex w-full flex-col gap-y-4 pb-6"
@@ -3602,7 +3614,9 @@ var Whatsapp = function Whatsapp(_ref) {
3602
3614
  handleSubmit = _ref.handleSubmit,
3603
3615
  customFields = _ref.customFields,
3604
3616
  customFieldsInitialValues = _ref.customFieldsInitialValues,
3605
- customFieldsValidationSchema = _ref.customFieldsValidationSchema;
3617
+ customFieldsValidationSchema = _ref.customFieldsValidationSchema,
3618
+ _ref$helpDocUrl = _ref.helpDocUrl,
3619
+ helpDocUrl = _ref$helpDocUrl === void 0 ? "" : _ref$helpDocUrl;
3606
3620
  var _useTranslation = useTranslation(),
3607
3621
  t = _useTranslation.t;
3608
3622
  var getInitialVariableComponents = function getInitialVariableComponents(variables) {
@@ -3628,9 +3642,19 @@ var Whatsapp = function Whatsapp(_ref) {
3628
3642
  };
3629
3643
  var updatedInitialValues = mergeAll([initialFormValues, customFieldsInitialValues]);
3630
3644
  var updatedValidationSchema = yup.object().shape(_objectSpread$2(_objectSpread$2({}, WHATSAPP_MESSAGE_FORM_VALIDATIONS_SCHEMA === null || WHATSAPP_MESSAGE_FORM_VALIDATIONS_SCHEMA === void 0 ? void 0 : WHATSAPP_MESSAGE_FORM_VALIDATIONS_SCHEMA.fields), customFieldsValidationSchema === null || customFieldsValidationSchema === void 0 ? void 0 : customFieldsValidationSchema.fields));
3645
+ var initialValueKeys = Object.keys(initialFormValues);
3631
3646
  if (isEmpty(templates)) {
3632
3647
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Typography, null, t("neetoMessageTemplate.template.emptyState", {
3633
3648
  type: t("neetoMessageTemplate.template.whatsappTemplates")
3649
+ }), " ", helpDocUrl && /*#__PURE__*/React.createElement(Trans, {
3650
+ i18nKey: "neetoMessageTemplate.template.whatsapp.helpDocText",
3651
+ components: {
3652
+ Link: /*#__PURE__*/React.createElement(Button, {
3653
+ size: "large",
3654
+ style: "link",
3655
+ to: helpDocUrl
3656
+ })
3657
+ }
3634
3658
  })), /*#__PURE__*/React.createElement(Pane.Footer, {
3635
3659
  className: "absolute bottom-0 left-0"
3636
3660
  }, /*#__PURE__*/React.createElement(Button, {
@@ -3638,7 +3662,7 @@ var Whatsapp = function Whatsapp(_ref) {
3638
3662
  onClick: onClose
3639
3663
  })));
3640
3664
  }
3641
- return /*#__PURE__*/React.createElement(Form$2, {
3665
+ return /*#__PURE__*/React.createElement(NeetoUIForm, {
3642
3666
  formProps: {
3643
3667
  noValidate: true,
3644
3668
  className: "flex w-full flex-col gap-y-4 pb-6"
@@ -3656,14 +3680,15 @@ var Whatsapp = function Whatsapp(_ref) {
3656
3680
  var template = findBy({
3657
3681
  id: value === null || value === void 0 ? void 0 : value.value
3658
3682
  }, templates);
3659
- setValues({
3683
+ var customFieldValues = omit(initialValueKeys, values);
3684
+ setValues(_objectSpread$2({
3660
3685
  selectedTemplate: {
3661
3686
  label: template.name,
3662
3687
  value: template.id
3663
3688
  },
3664
3689
  templateMessage: getTemplateMessage(template.components),
3665
3690
  variableContents: getInitialVariableComponents(template.variableCount)
3666
- });
3691
+ }, customFieldValues));
3667
3692
  };
3668
3693
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Select$1, {
3669
3694
  required: true,
@@ -3731,7 +3756,9 @@ var SendMessagePane = function SendMessagePane(_ref) {
3731
3756
  _ref$templateVariable = _ref.templateVariables,
3732
3757
  templateVariables = _ref$templateVariable === void 0 ? {} : _ref$templateVariable,
3733
3758
  _ref$ownerId = _ref.ownerId,
3734
- ownerId = _ref$ownerId === void 0 ? "" : _ref$ownerId;
3759
+ ownerId = _ref$ownerId === void 0 ? "" : _ref$ownerId,
3760
+ _ref$helpDocUrl = _ref.helpDocUrl,
3761
+ helpDocUrl = _ref$helpDocUrl === void 0 ? "" : _ref$helpDocUrl;
3735
3762
  var _useTranslation = useTranslation(),
3736
3763
  t = _useTranslation.t;
3737
3764
  var initialFocusField = useRef();
@@ -3762,6 +3789,7 @@ var SendMessagePane = function SendMessagePane(_ref) {
3762
3789
  customFieldsInitialValues: customFieldsInitialValues,
3763
3790
  customFieldsValidationSchema: customFieldsValidationSchema,
3764
3791
  handleSubmit: handleSubmit,
3792
+ helpDocUrl: helpDocUrl,
3765
3793
  onClose: onClose,
3766
3794
  templates: templates
3767
3795
  }) : /*#__PURE__*/React.createElement(EmailAndSms, {
@@ -4023,7 +4051,7 @@ var Form = function Form(_ref) {
4023
4051
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Pane.Header, null, /*#__PURE__*/React.createElement(Typography, {
4024
4052
  style: "h2",
4025
4053
  weight: "semibold"
4026
- }, isEdit ? t("neetoMessageTemplate.api.editApiTemplate") : t("neetoMessageTemplate.api.addApiTemplate"))), /*#__PURE__*/React.createElement(Form$2, {
4054
+ }, isEdit ? t("neetoMessageTemplate.api.editApiTemplate") : t("neetoMessageTemplate.api.addApiTemplate"))), /*#__PURE__*/React.createElement(NeetoUIForm, {
4027
4055
  formikProps: {
4028
4056
  initialValues: buildApiTemplateInitialValues(isEdit, selectedApiTemplate),
4029
4057
  validationSchema: API_TEMPLATE_FORM_VALIDATION_SCHEMA,
@@ -4310,7 +4338,7 @@ var SendToApiForm = function SendToApiForm(_ref) {
4310
4338
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Pane.Header, null, /*#__PURE__*/React.createElement(Typography, {
4311
4339
  style: "h2",
4312
4340
  weight: "semibold"
4313
- }, t("neetoMessageTemplate.api.sendToApi"))), /*#__PURE__*/React.createElement(Form$2, {
4341
+ }, t("neetoMessageTemplate.api.sendToApi"))), /*#__PURE__*/React.createElement(NeetoUIForm, {
4314
4342
  formikProps: {
4315
4343
  initialValues: SEND_TO_API_FORM_INITIAL_VALUES,
4316
4344
  validationSchema: SEND_TO_API_FORM_VALIDATION_SCHEMA,