@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.js CHANGED
@@ -4092,7 +4092,7 @@ var common$1 = {
4092
4092
  status: "Status",
4093
4093
  record_one: "Record",
4094
4094
  record_other: "Records",
4095
- note: "Note by approver",
4095
+ note: "Note",
4096
4096
  approvedBy: "Approved by",
4097
4097
  rejectedBy: "Rejected by",
4098
4098
  cancelledBy: "Cancelled by",
@@ -4118,8 +4118,7 @@ var inputs = {
4118
4118
  description: "Description",
4119
4119
  approver: "Approver",
4120
4120
  variableMapping: "Variable mapping",
4121
- message: "Message",
4122
- approverNote: "Approver's note"
4121
+ message: "Message"
4123
4122
  },
4124
4123
  placeholders: {
4125
4124
  firstName: "Enter first name",
@@ -5028,17 +5027,17 @@ var ApprovalsDetails = function ApprovalsDetails(_ref) {
5028
5027
  createdAt = approvalDetails.createdAt,
5029
5028
  approverName = approvalDetails.approverName,
5030
5029
  approverEmail = approvalDetails.approverEmail,
5031
- _approvalDetails$appr = approvalDetails.approverNote,
5032
- note = _approvalDetails$appr === void 0 ? "" : _approvalDetails$appr,
5030
+ _approvalDetails$note = approvalDetails.note,
5031
+ initialNote = _approvalDetails$note === void 0 ? "" : _approvalDetails$note,
5033
5032
  requesterName = approvalDetails.requesterName,
5034
5033
  requesterEmail = approvalDetails.requesterEmail;
5035
- var _useState = useState(note),
5034
+ var _useState = useState(initialNote),
5036
5035
  _useState2 = _slicedToArray(_useState, 2),
5037
- approverNote = _useState2[0],
5038
- setApproverNote = _useState2[1];
5036
+ note = _useState2[0],
5037
+ setNote = _useState2[1];
5039
5038
  useEffect(function () {
5040
- setApproverNote(note);
5041
- }, [note]);
5039
+ setNote(initialNote);
5040
+ }, [initialNote]);
5042
5041
  var requesterOrApproverDetails = status === STATUSES.cancelled ? "".concat(requesterName, " (").concat(requesterEmail, ")") : "".concat(approverName, " (").concat(approverEmail, ")");
5043
5042
  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;
5044
5043
  var getStatusLabel = function getStatusLabel() {
@@ -5048,13 +5047,13 @@ var ApprovalsDetails = function ApprovalsDetails(_ref) {
5048
5047
  return STATUS_UPDATED_BY[status];
5049
5048
  };
5050
5049
  var handleOnClose = function handleOnClose() {
5051
- setApproverNote("");
5050
+ setNote("");
5052
5051
  onClose();
5053
5052
  };
5054
5053
  var handleSubmit = function handleSubmit(status) {
5055
5054
  onSubmit({
5056
5055
  status: status,
5057
- approverNote: approverNote,
5056
+ note: note,
5058
5057
  approvedAt: new Date()
5059
5058
  });
5060
5059
  };
@@ -5087,17 +5086,17 @@ var ApprovalsDetails = function ApprovalsDetails(_ref) {
5087
5086
  })), isPending && isCurrentUserApprover && /*#__PURE__*/React.createElement(Textarea, {
5088
5087
  className: "w-full",
5089
5088
  disabled: !isPending,
5090
- label: t("inputs.labels.approverNote"),
5091
- value: approverNote,
5089
+ label: t("common.note"),
5090
+ value: note,
5092
5091
  placeholder: t("inputs.placeholders.add_", {
5093
5092
  what: t("common.note").toLocaleLowerCase()
5094
5093
  }),
5095
- onChange: withEventTargetValue(setApproverNote)
5096
- }), !isPending && approverNote && /*#__PURE__*/React.createElement("div", {
5094
+ onChange: withEventTargetValue(setNote)
5095
+ }), !isPending && note && /*#__PURE__*/React.createElement("div", {
5097
5096
  className: "w-full space-y-2"
5098
5097
  }, /*#__PURE__*/React.createElement(Label, null, t("common.note")), /*#__PURE__*/React.createElement("div", {
5099
5098
  className: "neeto-ui-bg-gray-100 p-4"
5100
- }, approverNote))), isPending && isCurrentUserApprover && /*#__PURE__*/React.createElement(Pane.Footer, {
5099
+ }, note))), isPending && isCurrentUserApprover && /*#__PURE__*/React.createElement(Pane.Footer, {
5101
5100
  className: "flex gap-x-2"
5102
5101
  }, /*#__PURE__*/React.createElement(Button, {
5103
5102
  label: t("buttons.approve"),
@@ -5454,6 +5453,36 @@ var Field = function Field(_ref) {
5454
5453
  };
5455
5454
  var Field$1 = /*#__PURE__*/React.memo(Field);
5456
5455
 
5456
+ var VALID_VARIABLE_NAME_REGEX = /^[a-z](?:\w*[a-z0-9])*$/i;
5457
+ var TEMPLATE_FORM_INITIAL_VALUES = {
5458
+ name: "",
5459
+ description: "",
5460
+ visibility: "",
5461
+ approver: "",
5462
+ variables: [],
5463
+ message: ""
5464
+ };
5465
+ var TEMPLATE_FORM_VALIDATION_SCHEMA = yup.object().shape({
5466
+ name: yup.string().trim().required(t$2("validations.required", {
5467
+ what: t$2("common.name")
5468
+ })),
5469
+ approver: yup.object().required(t$2("validations.approver")),
5470
+ message: yup.string().test("message", t$2("validations.required", {
5471
+ what: t$2("inputs.labels.message")
5472
+ }), function (content) {
5473
+ return !isEditorEmpty(content);
5474
+ }),
5475
+ variables: yup.array().of(yup.object().shape({
5476
+ variable: yup.string().trim().required(t$2("validations.pleaseEnter_", {
5477
+ what: t$2("common.variable").toLocaleLowerCase()
5478
+ })).matches(VALID_VARIABLE_NAME_REGEX, t$2("validations.variableName"))
5479
+ }))
5480
+ });
5481
+ var EVERYONE_VISIBILITY = {
5482
+ label: t$2("select.visibility.everyone"),
5483
+ value: "everyone"
5484
+ };
5485
+
5457
5486
  var MemoizedEditorContent = /*#__PURE__*/React.memo(EditorContent);
5458
5487
  var TemplateDetails = function TemplateDetails(_ref) {
5459
5488
  var _Object$entries;
@@ -5488,7 +5517,7 @@ var TemplateDetails = function TemplateDetails(_ref) {
5488
5517
  value: approverName
5489
5518
  }), /*#__PURE__*/React.createElement(Field$1, {
5490
5519
  label: t("common.visibility"),
5491
- value: accessible === null || accessible === void 0 ? void 0 : accessible.label
5520
+ value: (accessible === null || accessible === void 0 ? void 0 : accessible.label) || EVERYONE_VISIBILITY.label
5492
5521
  }), (_Object$entries = Object.entries(variables || {})) === null || _Object$entries === void 0 ? void 0 : _Object$entries.map(function (_ref2) {
5493
5522
  var _ref3 = _slicedToArray(_ref2, 2),
5494
5523
  variable = _ref3[0],
@@ -5508,36 +5537,6 @@ var TemplateDetails = function TemplateDetails(_ref) {
5508
5537
  }))));
5509
5538
  };
5510
5539
 
5511
- var VALID_VARIABLE_NAME_REGEX = /^[a-z](?:\w*[a-z0-9])*$/i;
5512
- var TEMPLATE_FORM_INITIAL_VALUES = {
5513
- name: "",
5514
- description: "",
5515
- visibility: "",
5516
- approver: "",
5517
- variables: [],
5518
- message: ""
5519
- };
5520
- var TEMPLATE_FORM_VALIDATION_SCHEMA = yup.object().shape({
5521
- name: yup.string().trim().required(t$2("validations.required", {
5522
- what: t$2("common.name")
5523
- })),
5524
- approver: yup.object().required(t$2("validations.approver")),
5525
- message: yup.string().test("message", t$2("validations.required", {
5526
- what: t$2("inputs.labels.message")
5527
- }), function (content) {
5528
- return !isEditorEmpty(content);
5529
- }),
5530
- variables: yup.array().of(yup.object().shape({
5531
- variable: yup.string().trim().required(t$2("validations.pleaseEnter_", {
5532
- what: t$2("common.variable").toLocaleLowerCase()
5533
- })).matches(VALID_VARIABLE_NAME_REGEX, t$2("validations.variableName"))
5534
- }))
5535
- });
5536
- var EVERYONE_VISIBILITY = {
5537
- label: t$2("select.visibility.everyone"),
5538
- value: "everyone"
5539
- };
5540
-
5541
5540
  var Menu$1 = Dropdown.Menu,
5542
5541
  MenuItem = Dropdown.MenuItem;
5543
5542
  var columnData = function columnData(_ref) {
@@ -6282,16 +6281,16 @@ var show = function show(id) {
6282
6281
  };
6283
6282
  var accept = function accept(_ref) {
6284
6283
  var id = _ref.id,
6285
- approverNote = _ref.approverNote;
6284
+ note = _ref.note;
6286
6285
  return axios.patch("".concat(BASE_URL, "/public/requests/").concat(id, "/accept"), {
6287
- approverNote: approverNote
6286
+ note: note
6288
6287
  });
6289
6288
  };
6290
6289
  var decline = function decline(_ref2) {
6291
6290
  var id = _ref2.id,
6292
- approverNote = _ref2.approverNote;
6291
+ note = _ref2.note;
6293
6292
  return axios.patch("".concat(BASE_URL, "/public/requests/").concat(id, "/decline"), {
6294
- approverNote: approverNote
6293
+ note: note
6295
6294
  });
6296
6295
  };
6297
6296
  var publicRequestsApi = {
@@ -6338,8 +6337,8 @@ var useDeclinePendingRequest = function useDeclinePendingRequest(options) {
6338
6337
  var Public = function Public() {
6339
6338
  var _useState = useState(""),
6340
6339
  _useState2 = _slicedToArray(_useState, 2),
6341
- approverNote = _useState2[0],
6342
- setApproverNote = _useState2[1];
6340
+ note = _useState2[0],
6341
+ setNote = _useState2[1];
6343
6342
  var _useParams = useParams(),
6344
6343
  id = _useParams.id;
6345
6344
  var _useTranslation = useTranslation(),
@@ -6348,8 +6347,8 @@ var Public = function Public() {
6348
6347
  requestId: id
6349
6348
  }, {
6350
6349
  onSuccess: function onSuccess(_ref) {
6351
- var approverNote = _ref.approvalRequest.approverNote;
6352
- approverNote && setApproverNote(approverNote);
6350
+ var note = _ref.approvalRequest.note;
6351
+ note && setNote(note);
6353
6352
  }
6354
6353
  }),
6355
6354
  _useFetchPublicReques2 = _useFetchPublicReques.data,
@@ -6364,7 +6363,7 @@ var Public = function Public() {
6364
6363
  declinePendingRequest = _useDeclinePendingReq.mutate,
6365
6364
  isDeclining = _useDeclinePendingReq.isLoading;
6366
6365
  var calloutStyle = approvalRequest.status === STATUSES.approved ? "success" : "danger";
6367
- var hideTextArea = approvalRequest.status !== STATUSES.pending && isEmpty(approverNote);
6366
+ var hideTextArea = approvalRequest.status !== STATUSES.pending && isEmpty(note);
6368
6367
  if (isLoading) {
6369
6368
  return /*#__PURE__*/React.createElement("div", {
6370
6369
  className: "h-screen items-center justify-center"
@@ -6383,15 +6382,13 @@ var Public = function Public() {
6383
6382
  }, approvalRequest.title), /*#__PURE__*/React.createElement(EditorContent, {
6384
6383
  content: approvalRequest.message
6385
6384
  }), !hideTextArea && /*#__PURE__*/React.createElement(Textarea, {
6386
- label: t("inputs.labels.approverNote"),
6385
+ label: t("common.note"),
6387
6386
  placeholder: t("inputs.placeholders.add_", {
6388
6387
  what: t("common.note").toLocaleLowerCase()
6389
6388
  }),
6390
- value: approverNote,
6389
+ value: note,
6391
6390
  disabled: approvalRequest.status !== STATUSES.pending,
6392
- onChange: function onChange(e) {
6393
- return setApproverNote(e.target.value);
6394
- }
6391
+ onChange: withEventTargetValue(setNote)
6395
6392
  }), approvalRequest.status === STATUSES.pending ? /*#__PURE__*/React.createElement("div", {
6396
6393
  className: "mx-auto mt-8 flex space-x-6"
6397
6394
  }, /*#__PURE__*/React.createElement(Button, {
@@ -6399,7 +6396,7 @@ var Public = function Public() {
6399
6396
  onClick: function onClick() {
6400
6397
  return acceptPendingRequest({
6401
6398
  id: approvalRequest.id,
6402
- approverNote: approverNote
6399
+ note: note
6403
6400
  });
6404
6401
  },
6405
6402
  loading: isAccepting
@@ -6408,7 +6405,7 @@ var Public = function Public() {
6408
6405
  onClick: function onClick() {
6409
6406
  return declinePendingRequest({
6410
6407
  id: approvalRequest.id,
6411
- approverNote: approverNote
6408
+ note: note
6412
6409
  });
6413
6410
  },
6414
6411
  style: "secondary",