@bigbinary/neeto-approvals-frontend 0.0.9 → 0.0.10

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.esm.js CHANGED
@@ -4984,12 +4984,6 @@ var nullSafe$1 = function nullSafe(func) {
4984
4984
  );
4985
4985
  };
4986
4986
  var noop = function noop() {};
4987
- var toLabelAndValue = function toLabelAndValue(string) {
4988
- return {
4989
- label: string,
4990
- value: string
4991
- };
4992
- };
4993
4987
  var isNotEmpty = /*#__PURE__*/complement(isEmpty);
4994
4988
  var isNotPresent = /*#__PURE__*/either(isNil, isEmpty);
4995
4989
  var isPresent = /*#__PURE__*/complement(isNotPresent);
@@ -8101,16 +8095,21 @@ const fetch$1 = params => axios.get(`${BASE_URL}/templates`, {
8101
8095
  params
8102
8096
  });
8103
8097
  const show$1 = id => axios.get(`${BASE_URL}/templates/${id}`);
8104
- const create = payload => axios.post(`${BASE_URL}/templates`, payload);
8105
- const update = _ref => {
8106
- let id = _ref.id,
8098
+ const create = _ref => {
8099
+ let _ref$url = _ref.url,
8100
+ url = _ref$url === void 0 ? BASE_URL : _ref$url,
8107
8101
  payload = _ref.payload;
8108
- return axios.put(`${BASE_URL}/templates/${id}`, {
8109
- template: payload
8110
- });
8102
+ return axios.post(url, payload);
8111
8103
  };
8112
- const destroy = _ref2 => {
8113
- let templateId = _ref2.templateId;
8104
+ const update = _ref2 => {
8105
+ let id = _ref2.id,
8106
+ payload = _ref2.payload,
8107
+ _ref2$url = _ref2.url,
8108
+ url = _ref2$url === void 0 ? BASE_URL : _ref2$url;
8109
+ return axios.put(`${url}/${id}`, payload);
8110
+ };
8111
+ const destroy = _ref3 => {
8112
+ let templateId = _ref3.templateId;
8114
8113
  return axios.delete(`${BASE_URL}/templates/${templateId}`);
8115
8114
  };
8116
8115
  const templatesApi = {
@@ -8187,7 +8186,11 @@ const columnData = _ref => {
8187
8186
  dataIndex: "visibility",
8188
8187
  key: "visibility",
8189
8188
  sorter: true,
8190
- title: instance.t("common.visibility")
8189
+ title: instance.t("common.visibility"),
8190
+ render: (_, _ref2) => {
8191
+ let accessible = _ref2.accessible;
8192
+ return accessible.label;
8193
+ }
8191
8194
  }, {
8192
8195
  key: "actions",
8193
8196
  ellipsis: true,
@@ -8349,19 +8352,10 @@ const TEMPLATE_FORM_VALIDATION_SCHEMA = yup.object().shape({
8349
8352
  variable: yup.string().trim().required(t$1("validations.variable"))
8350
8353
  }))
8351
8354
  });
8352
- const VISIBILITY_OPTIONS = [{
8355
+ const SELF_VISIBILITY = {
8353
8356
  label: t$1("select.visibility.self"),
8354
- value: "Self"
8355
- }, {
8356
- label: t$1("select.visibility.supportTeam"),
8357
- value: "Support team"
8358
- }, {
8359
- label: t$1("select.visibility.managers"),
8360
- value: "Managers"
8361
- }, {
8362
- label: t$1("select.visibility.financeTeam"),
8363
- value: "Finance team"
8364
- }];
8357
+ value: "self"
8358
+ };
8365
8359
 
8366
8360
  const DynamicBlock = () => {
8367
8361
  const _useTranslation = useTranslation(),
@@ -8425,7 +8419,8 @@ const Form$1 = _ref => {
8425
8419
  _ref$onSubmit = _ref.onSubmit,
8426
8420
  onSubmit = _ref$onSubmit === void 0 ? noop : _ref$onSubmit,
8427
8421
  _ref$isLoading = _ref.isLoading,
8428
- isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading;
8422
+ isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading,
8423
+ visibilityOptions = _ref.visibilityOptions;
8429
8424
  const history = useHistory();
8430
8425
  const _useTranslation = useTranslation(),
8431
8426
  t = _useTranslation.t;
@@ -8466,7 +8461,7 @@ const Form$1 = _ref => {
8466
8461
  }), /*#__PURE__*/t__default.createElement(Select, {
8467
8462
  name: "visibility",
8468
8463
  label: t("common.visibility"),
8469
- options: VISIBILITY_OPTIONS
8464
+ options: [...visibilityOptions, SELF_VISIBILITY]
8470
8465
  })), /*#__PURE__*/t__default.createElement(DynamicBlock, null), /*#__PURE__*/t__default.createElement("div", {
8471
8466
  className: "space-x-4 pb-6"
8472
8467
  }, /*#__PURE__*/t__default.createElement(Button, {
@@ -8490,16 +8485,20 @@ const buildTemplatePayload = template => {
8490
8485
  let variable = _ref.variable;
8491
8486
  return [`variable${index + 1}`, variable];
8492
8487
  });
8493
- const payload = _objectSpread$3(_objectSpread$3({}, template), {}, {
8494
- visibility: visibility.value,
8495
- approverId: recipient.value,
8496
- variables: fromPairs(indexedVariables)
8497
- });
8488
+ const payload = {
8489
+ template: _objectSpread$3(_objectSpread$3({}, template), {}, {
8490
+ accessibleId: visibility.value,
8491
+ approverId: recipient.value,
8492
+ variables: fromPairs(indexedVariables)
8493
+ })
8494
+ };
8498
8495
  return payload;
8499
8496
  };
8500
8497
 
8501
8498
  const Create = _ref => {
8502
- let approvalsPath = _ref.approvalsPath;
8499
+ let approvalsPath = _ref.approvalsPath,
8500
+ visibilityOptions = _ref.visibilityOptions,
8501
+ templateUrl = _ref.templateUrl;
8503
8502
  const history = useHistory();
8504
8503
  const _useTranslation = useTranslation(),
8505
8504
  t = _useTranslation.t;
@@ -8508,7 +8507,10 @@ const Create = _ref => {
8508
8507
  isLoading = _useCreateTemplate.isLoading;
8509
8508
  const onSubmit = template => {
8510
8509
  const payload = buildTemplatePayload(template);
8511
- createTemplate(payload, {
8510
+ createTemplate({
8511
+ url: templateUrl,
8512
+ payload
8513
+ }, {
8512
8514
  onSuccess: () => history.push(`${approvalsPath}${routes.templates.index}`)
8513
8515
  });
8514
8516
  };
@@ -8522,7 +8524,8 @@ const Create = _ref => {
8522
8524
  }]
8523
8525
  }), /*#__PURE__*/t__default.createElement(Form$1, {
8524
8526
  onSubmit: onSubmit,
8525
- isLoading: isLoading
8527
+ isLoading: isLoading,
8528
+ visibilityOptions: visibilityOptions
8526
8529
  }));
8527
8530
  };
8528
8531
 
@@ -8530,7 +8533,9 @@ function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if
8530
8533
  function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
8531
8534
  const Edit = _ref => {
8532
8535
  var _template$recipient, _template$recipient2;
8533
- let approvalsPath = _ref.approvalsPath;
8536
+ let approvalsPath = _ref.approvalsPath,
8537
+ visibilityOptions = _ref.visibilityOptions,
8538
+ templateUrl = _ref.templateUrl;
8534
8539
  const _useParams = useParams(),
8535
8540
  id = _useParams.id;
8536
8541
  const history = useHistory();
@@ -8553,7 +8558,8 @@ const Edit = _ref => {
8553
8558
  const payload = buildTemplatePayload(template);
8554
8559
  updateTemplate({
8555
8560
  id,
8556
- payload
8561
+ payload,
8562
+ url: templateUrl
8557
8563
  });
8558
8564
  };
8559
8565
  if (isFetchingTemplate) {
@@ -8570,10 +8576,11 @@ const Edit = _ref => {
8570
8576
  text: t("common.templates")
8571
8577
  }]
8572
8578
  }), /*#__PURE__*/t__default.createElement(Form$1, {
8579
+ visibilityOptions: visibilityOptions,
8573
8580
  onSubmit: onSubmit,
8574
8581
  isLoading: isUpdating,
8575
8582
  initialData: _objectSpread$2(_objectSpread$2({}, template), {}, {
8576
- visibility: toLabelAndValue(template.visibility),
8583
+ visibility: template.accessible.id,
8577
8584
  recipient: {
8578
8585
  label: (_template$recipient = template.recipient) === null || _template$recipient === void 0 ? void 0 : _template$recipient.name,
8579
8586
  value: (_template$recipient2 = template.recipient) === null || _template$recipient2 === void 0 ? void 0 : _template$recipient2.id