@medipass/utils 11.73.2-fix-utils-ts.6 → 11.73.3-chore-update-react-18.0

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.
Files changed (95) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/abn.js +40 -45
  3. package/{billable-items-f8291b1e.js → billable-items-5e559447.js} +1 -1
  4. package/build-validation-schema.js +81 -123
  5. package/{businesses-2633ab9b.js → businesses-94ec0280.js} +1 -1
  6. package/chart.js +7 -14
  7. package/claim-payment-status-formatted.js +5 -2
  8. package/claim-payment-status-icons.js +13 -2
  9. package/claim-payment-status-text-classes.js +14 -2
  10. package/constants.js +82 -69
  11. package/countries.js +6 -8
  12. package/datetime.js +6 -13
  13. package/document-types-formatted.js +8 -3
  14. package/document-types-icons.js +4 -2
  15. package/document-types-text-classes.js +5 -2
  16. package/documents/workflow-state-formatted-text-classes.js +13 -4
  17. package/documents/workflow-state-formatted.js +13 -4
  18. package/documents/workflow-state-icons.js +11 -2
  19. package/form-applications/assign-values-to-sections.js +10 -16
  20. package/{forms-e1c51a53.js → forms-646810f2.js} +1 -1
  21. package/funders.js +21 -56
  22. package/get-env.js +38 -75
  23. package/get-select-options.js +21 -40
  24. package/get-staff-type-display-name.js +2 -4
  25. package/google-addresses.js +46 -91
  26. package/{health-fund-accounts-88eac93c.js → health-fund-accounts-8eda8621.js} +1 -1
  27. package/{health-fund-settings-e7a0f2ec.js → health-fund-settings-6d803913.js} +1 -1
  28. package/{health-funds-7fea63a0.js → health-funds-5e838942.js} +2 -2
  29. package/i18n/index.js +15 -18
  30. package/i18n/translations.js +1 -1
  31. package/index.js +1 -3
  32. package/intercom.js +24 -70
  33. package/{members-8eb8d8d0.js → members-e1797829.js} +1 -1
  34. package/{modalities-2dfbea63.js → modalities-d9979fa4.js} +1 -1
  35. package/package.json +4 -4
  36. package/parse-health-fund-card-fields.js +4 -6
  37. package/{patients-dd3709c1.js → patients-aba388c0.js} +1 -1
  38. package/{payment-methods-d36bc018.js → payment-methods-4010f9e5.js} +1 -1
  39. package/payment-options.js +11 -33
  40. package/{practices-d6c480f1.js → practices-17c06e6c.js} +3 -3
  41. package/{products-0a392564.js → products-7054c705.js} +2 -2
  42. package/products.js +5 -12
  43. package/{professional-categories-157d1767.js → professional-categories-0927144e.js} +1 -1
  44. package/redux-actions.js +69 -108
  45. package/redux-reducer.js +53 -69
  46. package/sanitise-url.js +1 -1
  47. package/scroll.js +1 -3
  48. package/sensitive-keys.js +2 -2
  49. package/sentry.js +35 -59
  50. package/service-items.js +70 -111
  51. package/{services-f8480eba.js → services-a81b505c.js} +3 -3
  52. package/{specialties-25fbb171.js → specialties-c29f2f67.js} +1 -1
  53. package/{staff-646053b7.js → staff-fedb5a08.js} +4 -4
  54. package/status-icons.js +12 -2
  55. package/status-text-classes.js +12 -2
  56. package/{subscriptions-aef302aa.js → subscriptions-25d86dab.js} +5 -5
  57. package/test-framework/fixtures/accounts.js +1 -1
  58. package/test-framework/fixtures/billable-items.js +1 -1
  59. package/test-framework/fixtures/businesses.js +1 -1
  60. package/test-framework/fixtures/documents.js +3 -3
  61. package/test-framework/fixtures/form-application-templates.js +1 -1
  62. package/test-framework/fixtures/form-applications.js +1 -1
  63. package/test-framework/fixtures/forms.js +1 -1
  64. package/test-framework/fixtures/health-fund-accounts.js +1 -1
  65. package/test-framework/fixtures/health-fund-settings.js +1 -1
  66. package/test-framework/fixtures/health-funds.js +1 -1
  67. package/test-framework/fixtures/index.js +18 -18
  68. package/test-framework/fixtures/members.js +1 -1
  69. package/test-framework/fixtures/message-mappings.js +1 -1
  70. package/test-framework/fixtures/modalities.js +1 -1
  71. package/test-framework/fixtures/patients.js +1 -1
  72. package/test-framework/fixtures/payment-methods.js +1 -1
  73. package/test-framework/fixtures/practices.js +1 -1
  74. package/test-framework/fixtures/products.js +1 -1
  75. package/test-framework/fixtures/professional-categories.js +1 -1
  76. package/test-framework/fixtures/services.js +1 -1
  77. package/test-framework/fixtures/specialties.js +1 -1
  78. package/test-framework/fixtures/staff.js +1 -1
  79. package/test-framework/fixtures/subscriptions.js +1 -1
  80. package/test-framework/fixtures/transaction-reports.js +6 -6
  81. package/test-framework/fixtures/transactions.js +1 -1
  82. package/test-framework/fixtures/workflow-exceptions.js +2 -2
  83. package/test-framework/react.js +10 -12
  84. package/transaction-details-by-funder.js +20 -21
  85. package/transaction-status-formatted.js +13 -3
  86. package/transaction-status-helpers.js +21 -27
  87. package/transaction-status-icons.js +9 -2
  88. package/transaction-status-text-classes.js +16 -2
  89. package/transaction-status.js +7 -15
  90. package/{transactions-4a08e450.js → transactions-de63fd15.js} +14 -14
  91. package/validate-form.js +79 -269
  92. package/validate.js +16 -28
  93. package/webpack-config.js +6 -13
  94. package/workflow-state-formatted-text-classes.js +12 -4
  95. package/workflow-state-formatted.js +11 -2
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [11.73.2](https://github.com/medipass/web-medicules/compare/@medipass/utils@11.73.1...@medipass/utils@11.73.2) (2022-12-07)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * utils ts support ([#710](https://github.com/medipass/web-medicules/issues/710)) ([4e6953b](https://github.com/medipass/web-medicules/commit/4e6953b))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [11.73.1](https://github.com/medipass/web-medicules/compare/@medipass/utils@11.73.0...@medipass/utils@11.73.1) (2022-11-21)
7
18
 
8
19
  **Note:** Version bump only for package @medipass/utils
package/abn.js CHANGED
@@ -2,82 +2,77 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var ABN_LENGTH = 11;
6
- var ACN_LENGTH = 9;
7
- var normaliseAbn = function normaliseAbn(abn) {
8
- var trimmedABN = abn == null ? void 0 : abn.replace(/\s/g, ''); // The input is an ABN, in which case the format should be 99 999 999 999
5
+ const ABN_LENGTH = 11;
6
+ const ACN_LENGTH = 9;
7
+ const normaliseAbn = abn => {
8
+ const trimmedABN = abn?.replace(/\s/g, '');
9
9
 
10
+ // The input is an ABN, in which case the format should be 99 999 999 999
10
11
  if (trimmedABN.length === ABN_LENGTH) {
11
12
  return trimmedABN.substring(0, 2) + ' ' + trimmedABN.substring(2, 5) + ' ' + trimmedABN.substring(5, 8) + ' ' + trimmedABN.substring(8);
12
- } //The input is an ACN, in which case the format should be 999 999 999
13
-
13
+ }
14
14
 
15
+ //The input is an ACN, in which case the format should be 999 999 999
15
16
  if (trimmedABN.length === ACN_LENGTH) {
16
17
  return trimmedABN.substring(0, 3) + ' ' + trimmedABN.substring(3, 6) + ' ' + trimmedABN.substring(6);
17
18
  }
18
-
19
19
  return abn;
20
20
  };
21
- var isValidAbn = function isValidAbn(abn) {
22
- var VALID_ABN_LENGTH = 11; // strip whitespace from value
21
+ const isValidAbn = abn => {
22
+ const VALID_ABN_LENGTH = 11;
23
23
 
24
+ // strip whitespace from value
24
25
  abn = String(abn).replace(/\s+/g, '');
25
-
26
26
  if (abn.length === VALID_ABN_LENGTH) {
27
- var weights = [10, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19];
28
- var abnArray = [];
29
-
30
- for (var i = 0; i < abn.length; i++) {
27
+ const weights = [10, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19];
28
+ const abnArray = [];
29
+ for (let i = 0; i < abn.length; i++) {
31
30
  abnArray[i] = abn.charAt(i);
32
- } // subtract 1 from the left-most digit
33
-
34
-
35
- abnArray[0] -= 1; // multiply each of the digits by its weighting factor
36
-
37
- for (var _i = 0; _i < abnArray.length; _i++) {
38
- abnArray[_i] *= weights[_i];
39
- } // sum all the digits
40
-
41
-
42
- var abnSum = 0;
43
-
44
- for (var _i2 = 0; _i2 < abnArray.length; _i2++) {
45
- abnSum += abnArray[_i2];
46
31
  }
47
-
32
+ // subtract 1 from the left-most digit
33
+ abnArray[0] -= 1;
34
+ // multiply each of the digits by its weighting factor
35
+ for (let i = 0; i < abnArray.length; i++) {
36
+ abnArray[i] *= weights[i];
37
+ }
38
+ // sum all the digits
39
+ let abnSum = 0;
40
+ for (let i = 0; i < abnArray.length; i++) {
41
+ abnSum += abnArray[i];
42
+ }
48
43
  return abnSum % 89 === 0;
49
44
  } else {
50
45
  return false;
51
46
  }
52
47
  };
53
- var isValidAcn = function isValidAcn(acn) {
54
- var VALID_ACN_LENGTH = 9; // strip whitespace from value
48
+ const isValidAcn = acn => {
49
+ const VALID_ACN_LENGTH = 9;
55
50
 
51
+ // strip whitespace from value
56
52
  acn = String(acn).replace(/\s+/g, '');
57
-
58
53
  if (acn.length === VALID_ACN_LENGTH) {
59
- var weights = [8, 7, 6, 5, 4, 3, 2, 1];
60
- var acnArray = [];
61
-
62
- for (var i = 0; i < acn.length; i++) {
54
+ const weights = [8, 7, 6, 5, 4, 3, 2, 1];
55
+ const acnArray = [];
56
+ for (let i = 0; i < acn.length; i++) {
63
57
  acnArray[i] = parseInt(acn.charAt(i));
64
58
  }
59
+ let acnSum = 0;
65
60
 
66
- var acnSum = 0; // sum the digits 1-8
67
-
68
- for (var _i3 = 0; _i3 < weights.length; _i3++) {
69
- acnSum = acnSum + acnArray[_i3] * weights[_i3];
70
- } // divide by 10 and take remainder
71
-
61
+ // sum the digits 1-8
62
+ for (let i = 0; i < weights.length; i++) {
63
+ acnSum = acnSum + acnArray[i] * weights[i];
64
+ }
72
65
 
73
- var remainder = acnSum % 10; // complement the remainder to 10
66
+ // divide by 10 and take remainder
67
+ const remainder = acnSum % 10;
74
68
 
75
- var complement = 10 - remainder; // if the complement equals 10, set it to 0
69
+ // complement the remainder to 10
70
+ let complement = 10 - remainder;
76
71
 
72
+ // if the complement equals 10, set it to 0
77
73
  if (complement === 10) {
78
74
  complement = 0;
79
75
  }
80
-
81
76
  return acnArray[8] === complement;
82
77
  } else {
83
78
  return false;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var defaultBillableItem = {
3
+ const defaultBillableItem = {
4
4
  _id: 'billableItemDefaultId',
5
5
  organisationId: 'organisationDefaultId',
6
6
  businessId: 'businessDefaultId',
@@ -892,9 +892,8 @@ var lib$1 = createCommonjsModule(function (module) {
892
892
  });
893
893
 
894
894
  function ownKeys(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; }
895
-
896
895
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
897
- var FIELD_VALIDATORS = {
896
+ const FIELD_VALIDATORS = {
898
897
  firstName: {
899
898
  type: 'string',
900
899
  validators: [{
@@ -917,61 +916,51 @@ var FIELD_VALIDATORS = {
917
916
  }, {
918
917
  type: 'test',
919
918
  message: 'Please enter a valid day between 01 and 31',
920
- fn: function fn(value) {
919
+ fn: value => {
921
920
  if (!value) {
922
921
  return;
923
922
  }
924
-
925
- var day = _get(value.split('/'), '[0]', '').split(' ').join('');
926
-
923
+ const day = _get(value.split('/'), '[0]', '').split(' ').join('');
927
924
  return day ? /^0[1-9]|[12][0-9]|3[01]$/.test(day) : true;
928
925
  }
929
926
  }, {
930
927
  type: 'test',
931
928
  message: 'Please enter a valid month between 01 and 12',
932
- fn: function fn(value) {
929
+ fn: value => {
933
930
  if (!value) {
934
931
  return;
935
932
  }
936
-
937
- var month = _get(value.split('/'), '[1]', '');
938
-
933
+ const month = _get(value.split('/'), '[1]', '');
939
934
  return month ? /^(0[1-9]|1[012])$/.test(month) : true;
940
935
  }
941
936
  }, {
942
937
  type: 'test',
943
938
  message: 'Please enter a valid year',
944
- fn: function fn(value) {
939
+ fn: value => {
945
940
  if (!value) {
946
941
  return;
947
942
  }
948
-
949
- var year = _get(value.split('/'), '[2]', '');
950
-
943
+ const year = _get(value.split('/'), '[2]', '');
951
944
  return year ? /^[0-9]{4}$/.test(year) : true;
952
945
  }
953
946
  }, {
954
947
  type: 'test',
955
948
  message: 'Please enter a year greater than 1900',
956
- fn: function fn(value) {
949
+ fn: value => {
957
950
  if (!value) {
958
951
  return;
959
952
  }
960
-
961
- var year = _get(value.split('/'), '[2]', '');
962
-
953
+ const year = _get(value.split('/'), '[2]', '');
963
954
  return year ? parseInt(year, 10) >= 1900 : true;
964
955
  }
965
956
  }, {
966
957
  type: 'test',
967
- message: "Please enter a year before " + (new Date().getFullYear() + 1),
968
- fn: function fn(value) {
958
+ message: `Please enter a year before ${new Date().getFullYear() + 1}`,
959
+ fn: value => {
969
960
  if (!value) {
970
961
  return;
971
962
  }
972
-
973
- var year = _get(value.split('/'), '[2]', '');
974
-
963
+ const year = _get(value.split('/'), '[2]', '');
975
964
  return year ? parseInt(year, 10) <= new Date().getFullYear() : true;
976
965
  }
977
966
  }]
@@ -994,9 +983,7 @@ var FIELD_VALIDATORS = {
994
983
  }, {
995
984
  type: 'test',
996
985
  message: 'Please enter a valid Australian mobile number',
997
- fn: function fn(value) {
998
- return value ? validate.isMobileNumber(value, 'AU') : true;
999
- }
986
+ fn: value => value ? validate.isMobileNumber(value, 'AU') : true
1000
987
  }]
1001
988
  },
1002
989
  password: {
@@ -1053,9 +1040,7 @@ var FIELD_VALIDATORS = {
1053
1040
  }, {
1054
1041
  type: 'test',
1055
1042
  message: 'Please enter a valid card number',
1056
- fn: function fn(value) {
1057
- return lib$1.fns.validateCardNumber(value);
1058
- }
1043
+ fn: value => lib$1.fns.validateCardNumber(value)
1059
1044
  }]
1060
1045
  },
1061
1046
  expiry: {
@@ -1066,9 +1051,7 @@ var FIELD_VALIDATORS = {
1066
1051
  }, {
1067
1052
  type: 'test',
1068
1053
  message: 'Please enter a valid expiry',
1069
- fn: function fn(value) {
1070
- return lib$1.fns.validateCardExpiry(value);
1071
- }
1054
+ fn: value => lib$1.fns.validateCardExpiry(value)
1072
1055
  }]
1073
1056
  },
1074
1057
  cvc: {
@@ -1079,19 +1062,15 @@ var FIELD_VALIDATORS = {
1079
1062
  }, {
1080
1063
  type: 'test',
1081
1064
  message: 'Please enter a valid CVC',
1082
- fn: function fn(value) {
1083
- return lib$1.fns.validateCardCVC(value);
1084
- }
1065
+ fn: value => lib$1.fns.validateCardCVC(value)
1085
1066
  }]
1086
1067
  }
1087
1068
  };
1088
-
1089
- var getFieldSchema = function getFieldSchema(field) {
1090
- var key = field.key || field.name;
1091
- var defaultFieldExists = Boolean(FIELD_VALIDATORS[key]);
1092
- var fieldAttributes = defaultFieldExists ? FIELD_VALIDATORS[key] : field;
1093
- var schema = yup;
1094
-
1069
+ const getFieldSchema = field => {
1070
+ const key = field.key || field.name;
1071
+ const defaultFieldExists = Boolean(FIELD_VALIDATORS[key]);
1072
+ const fieldAttributes = defaultFieldExists ? FIELD_VALIDATORS[key] : field;
1073
+ let schema = yup;
1095
1074
  switch (fieldAttributes.type) {
1096
1075
  case 'string':
1097
1076
  {
@@ -1099,91 +1078,79 @@ var getFieldSchema = function getFieldSchema(field) {
1099
1078
  schema = schema.string();
1100
1079
  break;
1101
1080
  }
1102
-
1103
1081
  case 'object':
1104
1082
  {
1105
1083
  // @ts-expect-error TS(2740): Type 'OptionalObjectSchema<ObjectShape, Record<str... Remove this comment to see the full error message
1106
1084
  schema = schema.object();
1107
1085
  break;
1108
1086
  }
1109
-
1110
1087
  case 'array':
1111
1088
  {
1112
1089
  // @ts-expect-error TS(2740): Type 'OptionalArraySchema<AnySchema<any, any, any>... Remove this comment to see the full error message
1113
1090
  schema = schema.array();
1114
1091
  break;
1115
1092
  }
1116
-
1117
1093
  case 'boolean':
1118
1094
  {
1119
1095
  // @ts-expect-error TS(2740): Type 'BooleanSchema<boolean, Record<string, any>, ... Remove this comment to see the full error message
1120
1096
  schema = schema.boolean();
1121
1097
  break;
1122
1098
  }
1123
-
1124
1099
  case 'date':
1125
1100
  {
1126
1101
  // @ts-expect-error TS(2740): Type 'DateSchema<Date, Record<string, any>, Date>'... Remove this comment to see the full error message
1127
1102
  schema = schema.date();
1128
1103
  break;
1129
1104
  }
1130
-
1131
1105
  case 'number':
1132
1106
  {
1133
1107
  // @ts-expect-error TS(2740): Type 'NumberSchema<number, Record<string, any>, nu... Remove this comment to see the full error message
1134
1108
  schema = schema.number();
1135
1109
  break;
1136
1110
  }
1137
-
1138
1111
  default:
1139
1112
  {
1140
1113
  // @ts-expect-error TS(2322): Type 'StringSchema<string, Record<string, any>, st... Remove this comment to see the full error message
1141
1114
  schema = schema.string();
1142
1115
  }
1143
1116
  }
1144
-
1145
1117
  if (fieldAttributes.validators) {
1146
- fieldAttributes.validators.forEach(function (validator) {
1118
+ fieldAttributes.validators.forEach(validator => {
1147
1119
  switch (validator.type) {
1148
1120
  case 'required':
1149
1121
  {
1150
1122
  if (defaultFieldExists && !field.required) {
1151
1123
  return;
1152
- } // @ts-expect-error TS(2339): Property 'required' does not exist on type 'typeof... Remove this comment to see the full error message
1153
-
1124
+ }
1154
1125
 
1126
+ // @ts-expect-error TS(2339): Property 'required' does not exist on type 'typeof... Remove this comment to see the full error message
1155
1127
  schema = schema.required(validator.message);
1156
1128
  break;
1157
1129
  }
1158
-
1159
1130
  case 'test':
1160
1131
  {
1161
1132
  // @ts-expect-error TS(2339): Property 'test' does not exist on type 'typeof imp... Remove this comment to see the full error message
1162
1133
  schema = schema.test(field.name, validator.message, validator.fn);
1163
1134
  break;
1164
1135
  }
1165
-
1166
1136
  case 'email':
1167
1137
  {
1168
1138
  // @ts-expect-error TS(2339): Property 'email' does not exist on type 'typeof im... Remove this comment to see the full error message
1169
1139
  schema = schema.email(validator.message);
1170
1140
  break;
1171
1141
  }
1172
-
1173
1142
  case 'min':
1174
1143
  {
1175
1144
  // @ts-expect-error TS(2339): Property 'min' does not exist on type 'typeof impo... Remove this comment to see the full error message
1176
1145
  schema = schema.min(validator.length, validator.message);
1177
1146
  break;
1178
1147
  }
1179
-
1180
1148
  case 'matches':
1181
1149
  {
1182
1150
  // @ts-expect-error TS(2339): Property 'matches' does not exist on type 'typeof ... Remove this comment to see the full error message
1183
1151
  schema = schema.matches(validator.pattern, validator.message);
1184
1152
  break;
1185
1153
  }
1186
-
1187
1154
  case 'oneOf':
1188
1155
  {
1189
1156
  // @ts-expect-error TS(2339): Property 'oneOf' does not exist on type 'typeof im... Remove this comment to see the full error message
@@ -1193,104 +1160,95 @@ var getFieldSchema = function getFieldSchema(field) {
1193
1160
  }
1194
1161
  });
1195
1162
  }
1196
-
1197
1163
  return schema;
1198
1164
  };
1199
-
1200
1165
  var buildValidationSchema = (function (fields, overrideSchema) {
1201
1166
  if (overrideSchema === void 0) {
1202
1167
  overrideSchema = {};
1203
1168
  }
1204
-
1205
- var schema = {};
1206
- fields.forEach(function (field) {
1169
+ const schema = {};
1170
+ fields.forEach(field => {
1207
1171
  if (!field) {
1208
1172
  return;
1209
1173
  }
1210
-
1211
1174
  schema[field.name] = getFieldSchema(field);
1212
1175
  });
1213
1176
  return yup.object().shape(_objectSpread({}, schema, {}, overrideSchema));
1214
1177
  });
1215
1178
  /* ===== CUSTOM OVERRIDE SCHEMAS ===== */
1216
1179
 
1217
- var validateHealthFundDate = function validateHealthFundDate(schema, _ref) {
1218
- var cardFields = _ref.cardFields,
1219
- fieldKey = _ref.fieldKey,
1220
- dayKey = _ref.dayKey,
1221
- monthKey = _ref.monthKey,
1222
- yearKey = _ref.yearKey;
1223
- var newSchema = schema;
1224
-
1180
+ const validateHealthFundDate = (schema, _ref) => {
1181
+ let {
1182
+ cardFields,
1183
+ fieldKey,
1184
+ dayKey,
1185
+ monthKey,
1186
+ yearKey
1187
+ } = _ref;
1188
+ let newSchema = schema;
1225
1189
  if (cardFields[dayKey]) {
1226
- newSchema = newSchema.test(fieldKey, _get(cardFields, dayKey + ".validation.message"), function (value) {
1227
- var dateArray = value ? value.split('/') : [];
1228
- var day = dateArray[0];
1229
- return new RegExp(_get(cardFields, dayKey + ".validation.regex")).test(day);
1190
+ newSchema = newSchema.test(fieldKey, _get(cardFields, `${dayKey}.validation.message`), value => {
1191
+ const dateArray = value ? value.split('/') : [];
1192
+ const day = dateArray[0];
1193
+ return new RegExp(_get(cardFields, `${dayKey}.validation.regex`)).test(day);
1230
1194
  });
1231
1195
  }
1232
-
1233
1196
  if (cardFields[monthKey]) {
1234
- newSchema = newSchema.test(fieldKey, _get(cardFields, monthKey + ".validation.message"), function (value) {
1235
- var dateArray = value ? value.split('/') : [];
1236
- var month = dateArray[dateArray.length - 2];
1237
- return new RegExp(_get(cardFields, monthKey + ".validation.regex")).test(month);
1197
+ newSchema = newSchema.test(fieldKey, _get(cardFields, `${monthKey}.validation.message`), value => {
1198
+ const dateArray = value ? value.split('/') : [];
1199
+ const month = dateArray[dateArray.length - 2];
1200
+ return new RegExp(_get(cardFields, `${monthKey}.validation.regex`)).test(month);
1238
1201
  });
1239
1202
  }
1240
-
1241
1203
  if (cardFields[yearKey]) {
1242
- newSchema = newSchema.test(fieldKey, _get(cardFields, yearKey + ".validation.message"), function (value) {
1243
- var dateArray = value ? value.split('/') : [];
1244
- var year = dateArray[dateArray.length - 1];
1245
- return new RegExp(_get(cardFields, yearKey + ".validation.regex")).test(year);
1204
+ newSchema = newSchema.test(fieldKey, _get(cardFields, `${yearKey}.validation.message`), value => {
1205
+ const dateArray = value ? value.split('/') : [];
1206
+ const year = dateArray[dateArray.length - 1];
1207
+ return new RegExp(_get(cardFields, `${yearKey}.validation.regex`)).test(year);
1246
1208
  });
1247
1209
  }
1248
-
1249
1210
  return newSchema;
1250
1211
  };
1251
-
1252
- var paymentMethodValidationSchema = [{
1212
+ const paymentMethodValidationSchema = [{
1253
1213
  name: 'cardNumber'
1254
1214
  }, {
1255
1215
  name: 'expiry'
1256
1216
  }, {
1257
1217
  name: 'cvc'
1258
1218
  }];
1259
- var getHealthFundAccountValidationSchema = function getHealthFundAccountValidationSchema(cardFields) {
1260
- return _objectSpread({}, cardFields.cardNumber ? {
1261
- cardNumber: yup.string().matches(new RegExp(_get(cardFields, 'cardNumber.validation.regex')), _get(cardFields, 'cardNumber.validation.message')).required("Please enter a " + _get(cardFields, 'cardNumber.displayName', 'card number').toLowerCase())
1262
- } : {}, {}, cardFields.membershipNumber ? {
1263
- membershipNumber: yup.string().min(_get(cardFields, 'membershipNumber.minLength'), _get(cardFields, 'membershipNumber.displayName', 'membership number') + " must be at least " + _get(cardFields, 'membershipNumber.minLength') + " numbers").max(_get(cardFields, 'membershipNumber.maxLength', 99), _get(cardFields, 'membershipNumber.displayName', 'membership number') + " must be less than " + _get(cardFields, 'membershipNumber.maxLength') + " numbers").matches(new RegExp(_get(cardFields, 'membershipNumber.validation.regex')), _get(cardFields, 'membershipNumber.validation.message')).required("Please enter a " + _get(cardFields, 'membershipNumber.displayName', 'membership number').toLowerCase())
1264
- } : {}, {}, cardFields.cardRank ? {
1265
- cardRank: yup.string().min(_get(cardFields, 'cardRank.minLength'), _get(cardFields, 'cardRank.displayName', 'card rank') + " must be at least " + _get(cardFields, 'cardRank.minLength') + " numbers").max(_get(cardFields, 'cardRank.maxLength', 99), _get(cardFields, 'cardRank.displayName', 'card rank') + " must be less than " + _get(cardFields, 'cardRank.maxLength') + " numbers").matches(new RegExp(_get(cardFields, 'cardRank.validation.regex')), _get(cardFields, 'cardRank.validation.message')).required("Please enter a " + _get(cardFields, 'cardRank.displayName', 'card rank').toLowerCase())
1266
- } : {}, {}, cardFields.issueDay || cardFields.issueMonth || cardFields.issueYear ? function () {
1267
- var issueDateSchema = yup.string().required('Please enter an issue date');
1268
- issueDateSchema = validateHealthFundDate(issueDateSchema, {
1269
- cardFields: cardFields,
1270
- fieldKey: 'issueDate',
1271
- dayKey: 'issueDay',
1272
- monthKey: 'issueMonth',
1273
- yearKey: 'issueYear'
1274
- });
1275
- return {
1276
- issueDate: issueDateSchema
1277
- };
1278
- }() : {}, {}, cardFields.expiryDay || cardFields.expiryMonth || cardFields.expiryYear ? function () {
1279
- var expiryDateSchema = yup.string().required('Please enter an expiry date');
1280
- expiryDateSchema = validateHealthFundDate(expiryDateSchema, {
1281
- cardFields: cardFields,
1282
- fieldKey: 'expiryDate',
1283
- dayKey: 'expiryDay',
1284
- monthKey: 'expiryMonth',
1285
- yearKey: 'expiryYear'
1286
- });
1287
- return {
1288
- expiryDate: expiryDateSchema
1289
- };
1290
- }() : {}, {}, cardFields.cardIssueNumber ? {
1291
- cardIssueNumber: yup.string().min(_get(cardFields, 'cardIssueNumber.minLength'), _get(cardFields, 'cardIssueNumber.displayName', 'issue number') + " must be at least " + _get(cardFields, 'cardIssueNumber.minLength') + " numbers").max(_get(cardFields, 'cardIssueNumber.maxLength', 99), _get(cardFields, 'cardIssueNumber.displayName', 'issue number') + " must be less than " + _get(cardFields, 'cardIssueNumber.maxLength') + " numbers").matches(new RegExp(_get(cardFields, 'cardIssueNumber.validation.regex')), _get(cardFields, 'cardIssueNumber.validation.message')).required("Please enter a " + _get(cardFields, 'cardIssueNumber.displayName', 'issue number').toLowerCase())
1292
- } : {});
1293
- };
1219
+ const getHealthFundAccountValidationSchema = cardFields => _objectSpread({}, cardFields.cardNumber ? {
1220
+ cardNumber: yup.string().matches(new RegExp(_get(cardFields, 'cardNumber.validation.regex')), _get(cardFields, 'cardNumber.validation.message')).required(`Please enter a ${_get(cardFields, 'cardNumber.displayName', 'card number').toLowerCase()}`)
1221
+ } : {}, {}, cardFields.membershipNumber ? {
1222
+ membershipNumber: yup.string().min(_get(cardFields, 'membershipNumber.minLength'), `${_get(cardFields, 'membershipNumber.displayName', 'membership number')} must be at least ${_get(cardFields, 'membershipNumber.minLength')} numbers`).max(_get(cardFields, 'membershipNumber.maxLength', 99), `${_get(cardFields, 'membershipNumber.displayName', 'membership number')} must be less than ${_get(cardFields, 'membershipNumber.maxLength')} numbers`).matches(new RegExp(_get(cardFields, 'membershipNumber.validation.regex')), _get(cardFields, 'membershipNumber.validation.message')).required(`Please enter a ${_get(cardFields, 'membershipNumber.displayName', 'membership number').toLowerCase()}`)
1223
+ } : {}, {}, cardFields.cardRank ? {
1224
+ cardRank: yup.string().min(_get(cardFields, 'cardRank.minLength'), `${_get(cardFields, 'cardRank.displayName', 'card rank')} must be at least ${_get(cardFields, 'cardRank.minLength')} numbers`).max(_get(cardFields, 'cardRank.maxLength', 99), `${_get(cardFields, 'cardRank.displayName', 'card rank')} must be less than ${_get(cardFields, 'cardRank.maxLength')} numbers`).matches(new RegExp(_get(cardFields, 'cardRank.validation.regex')), _get(cardFields, 'cardRank.validation.message')).required(`Please enter a ${_get(cardFields, 'cardRank.displayName', 'card rank').toLowerCase()}`)
1225
+ } : {}, {}, cardFields.issueDay || cardFields.issueMonth || cardFields.issueYear ? (() => {
1226
+ let issueDateSchema = yup.string().required('Please enter an issue date');
1227
+ issueDateSchema = validateHealthFundDate(issueDateSchema, {
1228
+ cardFields,
1229
+ fieldKey: 'issueDate',
1230
+ dayKey: 'issueDay',
1231
+ monthKey: 'issueMonth',
1232
+ yearKey: 'issueYear'
1233
+ });
1234
+ return {
1235
+ issueDate: issueDateSchema
1236
+ };
1237
+ })() : {}, {}, cardFields.expiryDay || cardFields.expiryMonth || cardFields.expiryYear ? (() => {
1238
+ let expiryDateSchema = yup.string().required('Please enter an expiry date');
1239
+ expiryDateSchema = validateHealthFundDate(expiryDateSchema, {
1240
+ cardFields,
1241
+ fieldKey: 'expiryDate',
1242
+ dayKey: 'expiryDay',
1243
+ monthKey: 'expiryMonth',
1244
+ yearKey: 'expiryYear'
1245
+ });
1246
+ return {
1247
+ expiryDate: expiryDateSchema
1248
+ };
1249
+ })() : {}, {}, cardFields.cardIssueNumber ? {
1250
+ cardIssueNumber: yup.string().min(_get(cardFields, 'cardIssueNumber.minLength'), `${_get(cardFields, 'cardIssueNumber.displayName', 'issue number')} must be at least ${_get(cardFields, 'cardIssueNumber.minLength')} numbers`).max(_get(cardFields, 'cardIssueNumber.maxLength', 99), `${_get(cardFields, 'cardIssueNumber.displayName', 'issue number')} must be less than ${_get(cardFields, 'cardIssueNumber.maxLength')} numbers`).matches(new RegExp(_get(cardFields, 'cardIssueNumber.validation.regex')), _get(cardFields, 'cardIssueNumber.validation.message')).required(`Please enter a ${_get(cardFields, 'cardIssueNumber.displayName', 'issue number').toLowerCase()}`)
1251
+ } : {});
1294
1252
 
1295
1253
  exports.FIELD_VALIDATORS = FIELD_VALIDATORS;
1296
1254
  exports.default = buildValidationSchema;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var defaultBusiness = {
3
+ const defaultBusiness = {
4
4
  _id: 'businessDefaultId',
5
5
  organisationId: 'organisationDefaultId',
6
6
  fullName: 'mockFullName',
package/chart.js CHANGED
@@ -8,37 +8,30 @@ var _capitalize = _interopDefault(require('lodash/capitalize'));
8
8
  var _get = _interopDefault(require('lodash/get'));
9
9
  var moment = _interopDefault(require('moment'));
10
10
 
11
- var buildChartLabelsFromDataset = function buildChartLabelsFromDataset(dataset, labelKey, opts) {
11
+ const buildChartLabelsFromDataset = function (dataset, labelKey, opts) {
12
12
  if (opts === void 0) {
13
13
  opts = {};
14
14
  }
15
-
16
- return dataset.map(function (data) {
15
+ return dataset.map(data => {
17
16
  // @ts-expect-error TS(2339): Property 'format' does not exist on type '{}'.
18
17
  if (opts.format) {
19
18
  // @ts-expect-error TS(2339): Property 'format' does not exist on type '{}'.
20
19
  return moment(data[labelKey]).format(opts.format);
21
20
  }
22
-
23
21
  return data[labelKey];
24
22
  });
25
23
  };
26
- var buildDataPointsFromDataset = function buildDataPointsFromDataset(dataset, dataKey) {
27
- return dataset.map(function (data) {
28
- return _get(data, dataKey);
29
- });
30
- };
31
- var humanizePeriod = function humanizePeriod(period) {
24
+ const buildDataPointsFromDataset = (dataset, dataKey) => dataset.map(data => _get(data, dataKey));
25
+ const humanizePeriod = period => {
32
26
  if (period && period.includes('--')) {
33
27
  return '';
34
28
  }
35
-
36
29
  return _capitalize(period);
37
30
  };
38
31
  var chart = {
39
- buildChartLabelsFromDataset: buildChartLabelsFromDataset,
40
- buildDataPointsFromDataset: buildDataPointsFromDataset,
41
- humanizePeriod: humanizePeriod
32
+ buildChartLabelsFromDataset,
33
+ buildDataPointsFromDataset,
34
+ humanizePeriod
42
35
  };
43
36
 
44
37
  exports.buildChartLabelsFromDataset = buildChartLabelsFromDataset;
@@ -4,9 +4,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var constants = require('./constants.js');
6
6
 
7
- var _PROVIDER;
8
7
  var claimPaymentStatusFormatted = {
9
- PROVIDER: (_PROVIDER = {}, _PROVIDER[constants.TRANSACTION_STATUSES.UNDER_REVIEW] = 'Under review', _PROVIDER[constants.TRANSACTION_STATUSES.PARTIALLY_REFUNDED] = 'Partial refund', _PROVIDER[constants.TRANSACTION_STATUSES.ERRORED] = 'Errored', _PROVIDER)
8
+ PROVIDER: {
9
+ [constants.TRANSACTION_STATUSES.UNDER_REVIEW]: 'Under review',
10
+ [constants.TRANSACTION_STATUSES.PARTIALLY_REFUNDED]: 'Partial refund',
11
+ [constants.TRANSACTION_STATUSES.ERRORED]: 'Errored'
12
+ }
10
13
  };
11
14
 
12
15
  exports.default = claimPaymentStatusFormatted;
@@ -4,7 +4,18 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var constants = require('./constants.js');
6
6
 
7
- var _TRANSACTION_STATUSES;
8
- var claimPaymentStatusIcons = (_TRANSACTION_STATUSES = {}, _TRANSACTION_STATUSES[constants.TRANSACTION_STATUSES.ERRORED] = 'fa-times-circle', _TRANSACTION_STATUSES[constants.TRANSACTION_STATUSES.REQUESTED] = 'fa-clock', _TRANSACTION_STATUSES[constants.TRANSACTION_STATUSES.PENDING] = 'fa-clock', _TRANSACTION_STATUSES[constants.TRANSACTION_STATUSES.ACCEPTED] = 'fa-check-circle', _TRANSACTION_STATUSES[constants.TRANSACTION_STATUSES.APPROVED] = 'fa-check-circle', _TRANSACTION_STATUSES[constants.TRANSACTION_STATUSES.REJECTED] = 'fa-times-circle', _TRANSACTION_STATUSES[constants.TRANSACTION_STATUSES.REVERSED] = 'fa-times-circle', _TRANSACTION_STATUSES[constants.TRANSACTION_STATUSES.VOIDED] = 'fa-times-circle', _TRANSACTION_STATUSES[constants.TRANSACTION_STATUSES.SKIPPED] = 'fa-times-circle', _TRANSACTION_STATUSES[constants.TRANSACTION_STATUSES.REFUNDED] = 'fa-undo', _TRANSACTION_STATUSES[constants.TRANSACTION_STATUSES.UNDER_REVIEW] = 'fa-clock', _TRANSACTION_STATUSES);
7
+ var claimPaymentStatusIcons = {
8
+ [constants.TRANSACTION_STATUSES.ERRORED]: 'fa-times-circle',
9
+ [constants.TRANSACTION_STATUSES.REQUESTED]: 'fa-clock',
10
+ [constants.TRANSACTION_STATUSES.PENDING]: 'fa-clock',
11
+ [constants.TRANSACTION_STATUSES.ACCEPTED]: 'fa-check-circle',
12
+ [constants.TRANSACTION_STATUSES.APPROVED]: 'fa-check-circle',
13
+ [constants.TRANSACTION_STATUSES.REJECTED]: 'fa-times-circle',
14
+ [constants.TRANSACTION_STATUSES.REVERSED]: 'fa-times-circle',
15
+ [constants.TRANSACTION_STATUSES.VOIDED]: 'fa-times-circle',
16
+ [constants.TRANSACTION_STATUSES.SKIPPED]: 'fa-times-circle',
17
+ [constants.TRANSACTION_STATUSES.REFUNDED]: 'fa-undo',
18
+ [constants.TRANSACTION_STATUSES.UNDER_REVIEW]: 'fa-clock'
19
+ };
9
20
 
10
21
  exports.default = claimPaymentStatusIcons;