@bigbinary/neeto-approvals-frontend 0.2.2 → 0.2.4

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
@@ -11,8 +11,12 @@ import axios from 'axios';
11
11
  import { useQuery, useQueryClient, useMutation } from 'react-query';
12
12
  import { Form as Form$3, Input, Textarea as Textarea$1, Select } from '@bigbinary/neetoui/formik';
13
13
  import { MenuHorizontal, Delete } from '@bigbinary/neeto-icons';
14
- import { capitalize as capitalize$1, noop as noop$1, isPresent, findBy, camelToSnakeCase, removeBy, findById } from '@bigbinary/neeto-commons-frontend/pure';
14
+ import { isPresent, findBy, capitalize as capitalize$1, noop as noop$1, camelToSnakeCase, removeBy, findById } from '@bigbinary/neeto-commons-frontend/pure';
15
15
  import { dateFormat, withEventTargetValue } from '@bigbinary/neeto-commons-frontend/utils';
16
+ import dayjs from 'dayjs';
17
+ import timezone from 'dayjs/plugin/timezone';
18
+ import utc from 'dayjs/plugin/utc';
19
+ import { globalProps } from '@bigbinary/neeto-commons-frontend/initializers';
16
20
  import { EditorContent, isEditorEmpty, FormikEditor, substituteVariables } from '@bigbinary/neeto-editor';
17
21
  import { useFormikContext, FieldArray } from 'formik';
18
22
  import NeetoHeader from '@bigbinary/neeto-molecules/Header';
@@ -4343,17 +4347,20 @@ var Form$2 = function Form(_ref) {
4343
4347
  }, /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Pane.Body, null, /*#__PURE__*/React.createElement("div", {
4344
4348
  className: "w-full space-y-6"
4345
4349
  }, /*#__PURE__*/React.createElement(Input, {
4350
+ required: true,
4346
4351
  className: "w-full",
4347
4352
  label: t("inputs.labels.firstName"),
4348
4353
  name: "firstName",
4349
4354
  placeholder: t("inputs.placeholders.firstName"),
4350
4355
  ref: inputReference
4351
4356
  }), /*#__PURE__*/React.createElement(Input, {
4357
+ required: true,
4352
4358
  className: "w-full",
4353
4359
  label: t("inputs.labels.lastName"),
4354
4360
  name: "lastName",
4355
4361
  placeholder: t("inputs.placeholders.lastName")
4356
4362
  }), /*#__PURE__*/React.createElement(Input, {
4363
+ required: true,
4357
4364
  className: "w-full",
4358
4365
  label: t("common.email"),
4359
4366
  name: "email",
@@ -4775,6 +4782,45 @@ var useUpdateRequest = function useUpdateRequest(options) {
4775
4782
  }));
4776
4783
  };
4777
4784
 
4785
+ dayjs.extend(utc);
4786
+ dayjs.extend(timezone);
4787
+ var updateApprovalDetails = function updateApprovalDetails(_ref) {
4788
+ var requestsData = _ref.requestsData,
4789
+ approvalDetails = _ref.approvalDetails;
4790
+ if (isPresent(requestsData === null || requestsData === void 0 ? void 0 : requestsData.requests) && isPresent(approvalDetails)) {
4791
+ var request = findBy({
4792
+ id: approvalDetails.id
4793
+ }, requestsData.requests) || {};
4794
+ return request;
4795
+ }
4796
+ return {};
4797
+ };
4798
+ var timeInZone = function timeInZone(time) {
4799
+ var _globalProps$user, _globalProps$user2;
4800
+ ((_globalProps$user = globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.timeZone) && dayjs.tz.setDefault((_globalProps$user2 = globalProps.user) === null || _globalProps$user2 === void 0 ? void 0 : _globalProps$user2.timeZone);
4801
+ return dayjs(time).tz();
4802
+ };
4803
+ var getApprovalFilter = function getApprovalFilter() {
4804
+ return {
4805
+ PENDING: {
4806
+ label: t$2("common.pending"),
4807
+ value: "PENDING"
4808
+ },
4809
+ TEMPLATES: {
4810
+ label: t$2("common.template", PLURAL),
4811
+ value: "TEMPLATES"
4812
+ },
4813
+ HISTORY: {
4814
+ label: t$2("common.history"),
4815
+ value: "HISTORY"
4816
+ },
4817
+ APPROVERS: {
4818
+ label: t$2("common.approver", PLURAL),
4819
+ value: "APPROVERS"
4820
+ }
4821
+ };
4822
+ };
4823
+
4778
4824
  var HISTORY_TABLE_COLUMNS = [{
4779
4825
  dataIndex: "approvalLabel",
4780
4826
  key: "approvalLabel",
@@ -4815,7 +4861,7 @@ var HISTORY_TABLE_COLUMNS = [{
4815
4861
  width: "25%",
4816
4862
  title: t$2("common.created"),
4817
4863
  render: function render(createdAt) {
4818
- return dateFormat.fromNow(createdAt);
4864
+ return dateFormat.fromNow(timeInZone(createdAt));
4819
4865
  }
4820
4866
  }];
4821
4867
 
@@ -4891,7 +4937,7 @@ var ApprovalsDetails = function ApprovalsDetails(_ref) {
4891
4937
  style: "body2"
4892
4938
  }, requesterOrApproverDetails)), /*#__PURE__*/React.createElement("div", {
4893
4939
  className: "flex space-x-10 p-2"
4894
- }, /*#__PURE__*/React.createElement(Label, null, t("common.created")), /*#__PURE__*/React.createElement(Typography, null, dateFormat.extended(createdAt)))), /*#__PURE__*/React.createElement("div", {
4940
+ }, /*#__PURE__*/React.createElement(Label, null, t("common.created")), /*#__PURE__*/React.createElement(Typography, null, dateFormat.extended(timeInZone(createdAt))))), /*#__PURE__*/React.createElement("div", {
4895
4941
  className: "w-full space-y-2"
4896
4942
  }, /*#__PURE__*/React.createElement(Label, null, t("inputs.labels.message")), /*#__PURE__*/React.createElement(MemoizedEditorContent$1, {
4897
4943
  className: "neeto-ui-bg-gray-100 p-4",
@@ -4928,38 +4974,6 @@ var ApprovalsDetails = function ApprovalsDetails(_ref) {
4928
4974
  })));
4929
4975
  };
4930
4976
 
4931
- var updateApprovalDetails = function updateApprovalDetails(_ref) {
4932
- var requestsData = _ref.requestsData,
4933
- approvalDetails = _ref.approvalDetails;
4934
- if (isPresent(requestsData === null || requestsData === void 0 ? void 0 : requestsData.requests) && isPresent(approvalDetails)) {
4935
- var request = findBy({
4936
- id: approvalDetails.id
4937
- }, requestsData.requests) || {};
4938
- return request;
4939
- }
4940
- return {};
4941
- };
4942
- var getApprovalFilter = function getApprovalFilter() {
4943
- return {
4944
- PENDING: {
4945
- label: t$2("common.pending"),
4946
- value: "PENDING"
4947
- },
4948
- TEMPLATES: {
4949
- label: t$2("common.template", PLURAL),
4950
- value: "TEMPLATES"
4951
- },
4952
- HISTORY: {
4953
- label: t$2("common.history"),
4954
- value: "HISTORY"
4955
- },
4956
- APPROVERS: {
4957
- label: t$2("common.approver", PLURAL),
4958
- value: "APPROVERS"
4959
- }
4960
- };
4961
- };
4962
-
4963
4977
  function ownKeys$8(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4964
4978
  function _objectSpread$8(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$8(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$8(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4965
4979
  var History = function History(_ref) {
@@ -5239,10 +5253,14 @@ function _toConsumableArray(arr) {
5239
5253
 
5240
5254
  var _t;
5241
5255
  var VALID_VARIABLE_NAME_REGEX = /^[a-z](?:\w*[a-z0-9])*$/i;
5256
+ var EVERYONE_VISIBILITY = {
5257
+ label: t$2("select.visibility.everyone"),
5258
+ value: "everyone"
5259
+ };
5242
5260
  var TEMPLATE_FORM_INITIAL_VALUES = {
5243
5261
  name: "",
5244
5262
  description: "",
5245
- visibility: "",
5263
+ visibility: EVERYONE_VISIBILITY,
5246
5264
  approver: "",
5247
5265
  variables: [],
5248
5266
  message: ""
@@ -5263,10 +5281,6 @@ var TEMPLATE_FORM_VALIDATION_SCHEMA = yup.object().shape({
5263
5281
  })).matches(VALID_VARIABLE_NAME_REGEX, t$2("validations.variableName"))
5264
5282
  }))
5265
5283
  });
5266
- var EVERYONE_VISIBILITY = {
5267
- label: t$2("select.visibility.everyone"),
5268
- value: "everyone"
5269
- };
5270
5284
 
5271
5285
  var DynamicBlock = function DynamicBlock() {
5272
5286
  var _useTranslation = useTranslation(),
@@ -5299,6 +5313,7 @@ var DynamicBlock = function DynamicBlock() {
5299
5313
  key: index
5300
5314
  }, /*#__PURE__*/React.createElement(Input, {
5301
5315
  autoFocus: true,
5316
+ required: true,
5302
5317
  label: t("common.variable_", {
5303
5318
  number: index + 1
5304
5319
  }),
@@ -5323,6 +5338,7 @@ var DynamicBlock = function DynamicBlock() {
5323
5338
  }
5324
5339
  }));
5325
5340
  })), /*#__PURE__*/React.createElement(FormikEditor, {
5341
+ required: true,
5326
5342
  key: variables,
5327
5343
  label: t("inputs.labels.message"),
5328
5344
  name: "message",
@@ -5379,6 +5395,7 @@ var Form$1 = function Form(_ref) {
5379
5395
  className: "flex w-full flex-col space-y-6"
5380
5396
  }, /*#__PURE__*/React.createElement(Input, {
5381
5397
  autoFocus: true,
5398
+ required: true,
5382
5399
  className: "w-1/2",
5383
5400
  label: t("common.name"),
5384
5401
  name: "name",
@@ -5391,6 +5408,7 @@ var Form$1 = function Form(_ref) {
5391
5408
  }), /*#__PURE__*/React.createElement("div", {
5392
5409
  className: "flex space-x-6"
5393
5410
  }, /*#__PURE__*/React.createElement(Select, {
5411
+ required: true,
5394
5412
  label: t("inputs.labels.approver"),
5395
5413
  name: "approver",
5396
5414
  options: approvers.map(function (approver) {
@@ -6056,6 +6074,7 @@ var Form = function Form(_ref) {
6056
6074
  }, function () {
6057
6075
  return variables.map(function (variable, index) {
6058
6076
  return /*#__PURE__*/React.createElement(Input, {
6077
+ required: true,
6059
6078
  className: "w-full",
6060
6079
  key: variable,
6061
6080
  label: variable,