@bigbinary/neeto-approvals-frontend 0.0.34 → 0.1.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.cjs.js CHANGED
@@ -4125,7 +4125,7 @@ var common$1 = {
4125
4125
  status: "Status",
4126
4126
  record_one: "Record",
4127
4127
  record_other: "Records",
4128
- note: "Note by approver",
4128
+ note: "Note",
4129
4129
  approvedBy: "Approved by",
4130
4130
  rejectedBy: "Rejected by",
4131
4131
  cancelledBy: "Cancelled by",
@@ -4151,8 +4151,7 @@ var inputs = {
4151
4151
  description: "Description",
4152
4152
  approver: "Approver",
4153
4153
  variableMapping: "Variable mapping",
4154
- message: "Message",
4155
- approverNote: "Approver's note"
4154
+ message: "Message"
4156
4155
  },
4157
4156
  placeholders: {
4158
4157
  firstName: "Enter first name",
@@ -5061,17 +5060,17 @@ var ApprovalsDetails = function ApprovalsDetails(_ref) {
5061
5060
  createdAt = approvalDetails.createdAt,
5062
5061
  approverName = approvalDetails.approverName,
5063
5062
  approverEmail = approvalDetails.approverEmail,
5064
- _approvalDetails$appr = approvalDetails.approverNote,
5065
- note = _approvalDetails$appr === void 0 ? "" : _approvalDetails$appr,
5063
+ _approvalDetails$note = approvalDetails.note,
5064
+ initialNote = _approvalDetails$note === void 0 ? "" : _approvalDetails$note,
5066
5065
  requesterName = approvalDetails.requesterName,
5067
5066
  requesterEmail = approvalDetails.requesterEmail;
5068
- var _useState = React.useState(note),
5067
+ var _useState = React.useState(initialNote),
5069
5068
  _useState2 = _slicedToArray(_useState, 2),
5070
- approverNote = _useState2[0],
5071
- setApproverNote = _useState2[1];
5069
+ note = _useState2[0],
5070
+ setNote = _useState2[1];
5072
5071
  React.useEffect(function () {
5073
- setApproverNote(note);
5074
- }, [note]);
5072
+ setNote(initialNote);
5073
+ }, [initialNote]);
5075
5074
  var requesterOrApproverDetails = status === STATUSES.cancelled ? "".concat(requesterName, " (").concat(requesterEmail, ")") : "".concat(approverName, " (").concat(approverEmail, ")");
5076
5075
  var isCurrentUserApprover = ((_window$globalProps = window.globalProps) === null || _window$globalProps === void 0 ? void 0 : (_window$globalProps$u = _window$globalProps.user) === null || _window$globalProps$u === void 0 ? void 0 : _window$globalProps$u.email) === approverEmail;
5077
5076
  var getStatusLabel = function getStatusLabel() {
@@ -5081,13 +5080,13 @@ var ApprovalsDetails = function ApprovalsDetails(_ref) {
5081
5080
  return STATUS_UPDATED_BY[status];
5082
5081
  };
5083
5082
  var handleOnClose = function handleOnClose() {
5084
- setApproverNote("");
5083
+ setNote("");
5085
5084
  onClose();
5086
5085
  };
5087
5086
  var handleSubmit = function handleSubmit(status) {
5088
5087
  onSubmit({
5089
5088
  status: status,
5090
- approverNote: approverNote,
5089
+ note: note,
5091
5090
  approvedAt: new Date()
5092
5091
  });
5093
5092
  };
@@ -5120,17 +5119,17 @@ var ApprovalsDetails = function ApprovalsDetails(_ref) {
5120
5119
  })), isPending && isCurrentUserApprover && /*#__PURE__*/React__default["default"].createElement(neetoui.Textarea, {
5121
5120
  className: "w-full",
5122
5121
  disabled: !isPending,
5123
- label: t("inputs.labels.approverNote"),
5124
- value: approverNote,
5122
+ label: t("common.note"),
5123
+ value: note,
5125
5124
  placeholder: t("inputs.placeholders.add_", {
5126
5125
  what: t("common.note").toLocaleLowerCase()
5127
5126
  }),
5128
- onChange: utils.withEventTargetValue(setApproverNote)
5129
- }), !isPending && approverNote && /*#__PURE__*/React__default["default"].createElement("div", {
5127
+ onChange: utils.withEventTargetValue(setNote)
5128
+ }), !isPending && note && /*#__PURE__*/React__default["default"].createElement("div", {
5130
5129
  className: "w-full space-y-2"
5131
5130
  }, /*#__PURE__*/React__default["default"].createElement(neetoui.Label, null, t("common.note")), /*#__PURE__*/React__default["default"].createElement("div", {
5132
5131
  className: "neeto-ui-bg-gray-100 p-4"
5133
- }, approverNote))), isPending && isCurrentUserApprover && /*#__PURE__*/React__default["default"].createElement(neetoui.Pane.Footer, {
5132
+ }, note))), isPending && isCurrentUserApprover && /*#__PURE__*/React__default["default"].createElement(neetoui.Pane.Footer, {
5134
5133
  className: "flex gap-x-2"
5135
5134
  }, /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
5136
5135
  label: t("buttons.approve"),
@@ -5487,6 +5486,36 @@ var Field = function Field(_ref) {
5487
5486
  };
5488
5487
  var Field$1 = /*#__PURE__*/React__default["default"].memo(Field);
5489
5488
 
5489
+ var VALID_VARIABLE_NAME_REGEX = /^[a-z](?:\w*[a-z0-9])*$/i;
5490
+ var TEMPLATE_FORM_INITIAL_VALUES = {
5491
+ name: "",
5492
+ description: "",
5493
+ visibility: "",
5494
+ approver: "",
5495
+ variables: [],
5496
+ message: ""
5497
+ };
5498
+ var TEMPLATE_FORM_VALIDATION_SCHEMA = yup__namespace.object().shape({
5499
+ name: yup__namespace.string().trim().required(t$2("validations.required", {
5500
+ what: t$2("common.name")
5501
+ })),
5502
+ approver: yup__namespace.object().required(t$2("validations.approver")),
5503
+ message: yup__namespace.string().test("message", t$2("validations.required", {
5504
+ what: t$2("inputs.labels.message")
5505
+ }), function (content) {
5506
+ return !neetoEditor.isEditorEmpty(content);
5507
+ }),
5508
+ variables: yup__namespace.array().of(yup__namespace.object().shape({
5509
+ variable: yup__namespace.string().trim().required(t$2("validations.pleaseEnter_", {
5510
+ what: t$2("common.variable").toLocaleLowerCase()
5511
+ })).matches(VALID_VARIABLE_NAME_REGEX, t$2("validations.variableName"))
5512
+ }))
5513
+ });
5514
+ var EVERYONE_VISIBILITY = {
5515
+ label: t$2("select.visibility.everyone"),
5516
+ value: "everyone"
5517
+ };
5518
+
5490
5519
  var MemoizedEditorContent = /*#__PURE__*/React__default["default"].memo(neetoEditor.EditorContent);
5491
5520
  var TemplateDetails = function TemplateDetails(_ref) {
5492
5521
  var _Object$entries;
@@ -5521,7 +5550,7 @@ var TemplateDetails = function TemplateDetails(_ref) {
5521
5550
  value: approverName
5522
5551
  }), /*#__PURE__*/React__default["default"].createElement(Field$1, {
5523
5552
  label: t("common.visibility"),
5524
- value: accessible === null || accessible === void 0 ? void 0 : accessible.label
5553
+ value: (accessible === null || accessible === void 0 ? void 0 : accessible.label) || EVERYONE_VISIBILITY.label
5525
5554
  }), (_Object$entries = Object.entries(variables || {})) === null || _Object$entries === void 0 ? void 0 : _Object$entries.map(function (_ref2) {
5526
5555
  var _ref3 = _slicedToArray(_ref2, 2),
5527
5556
  variable = _ref3[0],
@@ -5541,36 +5570,6 @@ var TemplateDetails = function TemplateDetails(_ref) {
5541
5570
  }))));
5542
5571
  };
5543
5572
 
5544
- var VALID_VARIABLE_NAME_REGEX = /^[a-z](?:\w*[a-z0-9])*$/i;
5545
- var TEMPLATE_FORM_INITIAL_VALUES = {
5546
- name: "",
5547
- description: "",
5548
- visibility: "",
5549
- approver: "",
5550
- variables: [],
5551
- message: ""
5552
- };
5553
- var TEMPLATE_FORM_VALIDATION_SCHEMA = yup__namespace.object().shape({
5554
- name: yup__namespace.string().trim().required(t$2("validations.required", {
5555
- what: t$2("common.name")
5556
- })),
5557
- approver: yup__namespace.object().required(t$2("validations.approver")),
5558
- message: yup__namespace.string().test("message", t$2("validations.required", {
5559
- what: t$2("inputs.labels.message")
5560
- }), function (content) {
5561
- return !neetoEditor.isEditorEmpty(content);
5562
- }),
5563
- variables: yup__namespace.array().of(yup__namespace.object().shape({
5564
- variable: yup__namespace.string().trim().required(t$2("validations.pleaseEnter_", {
5565
- what: t$2("common.variable").toLocaleLowerCase()
5566
- })).matches(VALID_VARIABLE_NAME_REGEX, t$2("validations.variableName"))
5567
- }))
5568
- });
5569
- var EVERYONE_VISIBILITY = {
5570
- label: t$2("select.visibility.everyone"),
5571
- value: "everyone"
5572
- };
5573
-
5574
5573
  var Menu$1 = neetoui.Dropdown.Menu,
5575
5574
  MenuItem = neetoui.Dropdown.MenuItem;
5576
5575
  var columnData = function columnData(_ref) {
@@ -6315,16 +6314,16 @@ var show = function show(id) {
6315
6314
  };
6316
6315
  var accept = function accept(_ref) {
6317
6316
  var id = _ref.id,
6318
- approverNote = _ref.approverNote;
6317
+ note = _ref.note;
6319
6318
  return axios__default["default"].patch("".concat(BASE_URL, "/public/requests/").concat(id, "/accept"), {
6320
- approverNote: approverNote
6319
+ note: note
6321
6320
  });
6322
6321
  };
6323
6322
  var decline = function decline(_ref2) {
6324
6323
  var id = _ref2.id,
6325
- approverNote = _ref2.approverNote;
6324
+ note = _ref2.note;
6326
6325
  return axios__default["default"].patch("".concat(BASE_URL, "/public/requests/").concat(id, "/decline"), {
6327
- approverNote: approverNote
6326
+ note: note
6328
6327
  });
6329
6328
  };
6330
6329
  var publicRequestsApi = {
@@ -6371,8 +6370,8 @@ var useDeclinePendingRequest = function useDeclinePendingRequest(options) {
6371
6370
  var Public = function Public() {
6372
6371
  var _useState = React.useState(""),
6373
6372
  _useState2 = _slicedToArray(_useState, 2),
6374
- approverNote = _useState2[0],
6375
- setApproverNote = _useState2[1];
6373
+ note = _useState2[0],
6374
+ setNote = _useState2[1];
6376
6375
  var _useParams = reactRouterDom.useParams(),
6377
6376
  id = _useParams.id;
6378
6377
  var _useTranslation = useTranslation(),
@@ -6381,8 +6380,8 @@ var Public = function Public() {
6381
6380
  requestId: id
6382
6381
  }, {
6383
6382
  onSuccess: function onSuccess(_ref) {
6384
- var approverNote = _ref.approvalRequest.approverNote;
6385
- approverNote && setApproverNote(approverNote);
6383
+ var note = _ref.approvalRequest.note;
6384
+ note && setNote(note);
6386
6385
  }
6387
6386
  }),
6388
6387
  _useFetchPublicReques2 = _useFetchPublicReques.data,
@@ -6397,7 +6396,7 @@ var Public = function Public() {
6397
6396
  declinePendingRequest = _useDeclinePendingReq.mutate,
6398
6397
  isDeclining = _useDeclinePendingReq.isLoading;
6399
6398
  var calloutStyle = approvalRequest.status === STATUSES.approved ? "success" : "danger";
6400
- var hideTextArea = approvalRequest.status !== STATUSES.pending && ramda.isEmpty(approverNote);
6399
+ var hideTextArea = approvalRequest.status !== STATUSES.pending && ramda.isEmpty(note);
6401
6400
  if (isLoading) {
6402
6401
  return /*#__PURE__*/React__default["default"].createElement("div", {
6403
6402
  className: "h-screen items-center justify-center"
@@ -6416,15 +6415,13 @@ var Public = function Public() {
6416
6415
  }, approvalRequest.title), /*#__PURE__*/React__default["default"].createElement(neetoEditor.EditorContent, {
6417
6416
  content: approvalRequest.message
6418
6417
  }), !hideTextArea && /*#__PURE__*/React__default["default"].createElement(neetoui.Textarea, {
6419
- label: t("inputs.labels.approverNote"),
6418
+ label: t("common.note"),
6420
6419
  placeholder: t("inputs.placeholders.add_", {
6421
6420
  what: t("common.note").toLocaleLowerCase()
6422
6421
  }),
6423
- value: approverNote,
6422
+ value: note,
6424
6423
  disabled: approvalRequest.status !== STATUSES.pending,
6425
- onChange: function onChange(e) {
6426
- return setApproverNote(e.target.value);
6427
- }
6424
+ onChange: utils.withEventTargetValue(setNote)
6428
6425
  }), approvalRequest.status === STATUSES.pending ? /*#__PURE__*/React__default["default"].createElement("div", {
6429
6426
  className: "mx-auto mt-8 flex space-x-6"
6430
6427
  }, /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
@@ -6432,7 +6429,7 @@ var Public = function Public() {
6432
6429
  onClick: function onClick() {
6433
6430
  return acceptPendingRequest({
6434
6431
  id: approvalRequest.id,
6435
- approverNote: approverNote
6432
+ note: note
6436
6433
  });
6437
6434
  },
6438
6435
  loading: isAccepting
@@ -6441,7 +6438,7 @@ var Public = function Public() {
6441
6438
  onClick: function onClick() {
6442
6439
  return declinePendingRequest({
6443
6440
  id: approvalRequest.id,
6444
- approverNote: approverNote
6441
+ note: note
6445
6442
  });
6446
6443
  },
6447
6444
  style: "secondary",