x25 2.9.2 → 3.0.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 (274) hide show
  1. package/.eslintignore +2 -0
  2. package/.eslintrc.json +275 -0
  3. package/.flowconfig +23 -0
  4. package/conf/dev.js +19 -0
  5. package/conf/dist.js +19 -0
  6. package/conf/polyfills/tempPolyfills.js +7 -0
  7. package/package.json +16 -16
  8. package/src/Account/Load.jsx +79 -0
  9. package/src/Account/actions.js +10 -0
  10. package/src/Account/index.js +11 -0
  11. package/src/Account/reducer.js +139 -0
  12. package/src/Account/request.js +36 -0
  13. package/src/Async/InitModule.jsx +114 -0
  14. package/src/Async/RouteLoading.jsx +52 -0
  15. package/src/Async/SimulatedException.jsx +19 -0
  16. package/src/Async/index.jsx +75 -0
  17. package/src/Async/types.js +39 -0
  18. package/src/Company/Load.jsx +84 -0
  19. package/src/Company/actions.js +10 -0
  20. package/src/Company/index.js +11 -0
  21. package/src/Company/reducer.js +201 -0
  22. package/src/Company/request.js +30 -0
  23. package/src/Company/util.js +7 -0
  24. package/src/Header/AccountOptionsContainer.jsx +124 -0
  25. package/src/Header/AdminSelectCompany.jsx +101 -0
  26. package/src/Header/ClientSelectCompany.jsx +90 -0
  27. package/src/Header/Header.jsx +120 -0
  28. package/src/Header/HeaderContainer.jsx +30 -0
  29. package/src/Header/Logo.jsx +16 -0
  30. package/src/Header/LogoutButton.jsx +34 -0
  31. package/src/Header/index.jsx +9 -0
  32. package/src/Header/request.js +28 -0
  33. package/src/Header/types.js +6 -0
  34. package/src/Header/util.jsx +61 -0
  35. package/src/Inputs/Business/BankAccount.jsx +39 -0
  36. package/src/Inputs/Business/BankName.jsx +40 -0
  37. package/src/Inputs/Business/CifField.jsx +93 -0
  38. package/src/Inputs/Business/CifFieldContainer.jsx +142 -0
  39. package/src/Inputs/Business/Email.jsx +23 -0
  40. package/src/Inputs/Business/NidField.jsx +77 -0
  41. package/src/Inputs/Business/Phone.jsx +23 -0
  42. package/src/Inputs/Business/index.js +16 -0
  43. package/src/Inputs/Business/request.js +39 -0
  44. package/src/Inputs/CaptchaBox.jsx +131 -0
  45. package/src/Inputs/DateInput.jsx +188 -0
  46. package/src/Inputs/DateTemplate.jsx +213 -0
  47. package/src/Inputs/DelayInputChange.jsx +130 -0
  48. package/src/Inputs/FocusTemplate.jsx +41 -0
  49. package/src/Inputs/InputTemplate.jsx +79 -0
  50. package/src/Inputs/LabelTemplate.jsx +47 -0
  51. package/src/Inputs/NumericInput.jsx +142 -0
  52. package/src/Inputs/NumericTemplate.jsx +155 -0
  53. package/src/Inputs/Selects/County.jsx +19 -0
  54. package/src/Inputs/Selects/Custom.jsx +55 -0
  55. package/src/Inputs/Selects/Simple.jsx +73 -0
  56. package/src/Inputs/Selects/index.jsx +37 -0
  57. package/src/Inputs/SimpleInput.jsx +40 -0
  58. package/src/Inputs/SimpleTextarea.jsx +55 -0
  59. package/src/Inputs/TextareaTemplate.jsx +57 -0
  60. package/src/Inputs/Tooltip.jsx +61 -0
  61. package/src/Inputs/index.js +22 -0
  62. package/src/Messages/Error.jsx +83 -0
  63. package/src/Messages/Loading.jsx +43 -0
  64. package/src/Messages/index.jsx +4 -0
  65. package/src/Modal/Delete.jsx +237 -0
  66. package/src/Modal/Root.jsx +57 -0
  67. package/src/Modal/SimpleModal.jsx +47 -0
  68. package/src/Modal/actions.js +7 -0
  69. package/src/Modal/getComponent.jsx +32 -0
  70. package/src/Modal/index.jsx +12 -0
  71. package/src/Modal/reducer.js +40 -0
  72. package/src/Modal/types.js +6 -0
  73. package/src/Modal/util.js +15 -0
  74. package/src/Payment/EstimatePrice/Description.jsx +101 -0
  75. package/src/Payment/EstimatePrice/PayBox.jsx +173 -0
  76. package/src/Payment/EstimatePrice/index.jsx +63 -0
  77. package/src/Payment/EstimatePrice/util.js +15 -0
  78. package/src/Payment/MobilpayForm.jsx +77 -0
  79. package/src/Payment/Modal/BankTransfer.jsx +129 -0
  80. package/src/Payment/Modal/CompanyValability.jsx +14 -0
  81. package/src/Payment/Modal/DoneForm.jsx +209 -0
  82. package/src/Payment/Modal/PaymentDone.jsx +27 -0
  83. package/src/Payment/Modal/index.js +13 -0
  84. package/src/Payment/actions.jsx +22 -0
  85. package/{Payment → src/Payment}/codes.js +16 -19
  86. package/src/Payment/index.jsx +124 -0
  87. package/src/Payment/request.js +50 -0
  88. package/src/Payment/types.js +14 -0
  89. package/src/Payment/util.jsx +52 -0
  90. package/src/Payment/validate.js +25 -0
  91. package/src/Sidebar.jsx +158 -0
  92. package/src/Things.jsx +35 -0
  93. package/src/actions.js +36 -0
  94. package/src/config.js +7 -0
  95. package/src/dev/ErrorBoundary.jsx +98 -0
  96. package/src/dev/TheError.jsx +87 -0
  97. package/src/dev/index.js +127 -0
  98. package/src/dev/types.js +10 -0
  99. package/src/prod/SentryErrorBoundary.jsx +98 -0
  100. package/src/reducer/captchas.js +44 -0
  101. package/src/reducer/counties.js +46 -0
  102. package/src/reducer/index.js +25 -0
  103. package/src/reducer/module.jsx +43 -0
  104. package/src/style/.sass-lint.yml +84 -0
  105. package/src/style/.stylelintrc.json +161 -0
  106. package/src/style/_fancy-text.scss +37 -0
  107. package/src/style/_fix_bootstrap_placeholder_color.scss +14 -0
  108. package/src/style/_header-company.scss +69 -0
  109. package/src/style/_inputs.scss +12 -0
  110. package/src/style/_minimal.scss +31 -0
  111. package/src/style/_navigation.scss +24 -0
  112. package/src/style/_others.scss +79 -0
  113. package/src/style/index.scss +7 -0
  114. package/src/style/sidebar/_animations.scss +21 -0
  115. package/src/style/sidebar/_dark-theme.scss +77 -0
  116. package/src/style/sidebar/_scroll.scss +37 -0
  117. package/src/style/sidebar/_structure.scss +299 -0
  118. package/src/style/sidebar.scss +4 -0
  119. package/src/types.js +31 -0
  120. package/src/utility/calendar.js +39 -0
  121. package/src/utility/date.js +100 -0
  122. package/src/utility/index.js +12 -0
  123. package/src/utility/language.js +17 -0
  124. package/src/utility/mql.js +3 -0
  125. package/src/utility/normalize-test.js +58 -0
  126. package/src/utility/normalize.js +119 -0
  127. package/src/utility/numbers.js +87 -0
  128. package/src/utility/numeric.js +114 -0
  129. package/src/utility/others.jsx +160 -0
  130. package/src/utility/strings-test.js +136 -0
  131. package/src/utility/strings.js +80 -0
  132. package/src/utility/validation/common.js +360 -0
  133. package/src/utility/validation/index.js +70 -0
  134. package/src/utility/validation/specific.js +9 -0
  135. package/src/utility/validation/validate/bank-test.js +129 -0
  136. package/src/utility/validation/validate/bank.js +176 -0
  137. package/src/utility/validation/validate/cif-test.js +105 -0
  138. package/src/utility/validation/validate/cif.js +44 -0
  139. package/src/utility/validation/validate/cnp-test.js +216 -0
  140. package/src/utility/validation/validate/cnp.js +261 -0
  141. package/{utility → src/utility}/validation/validate/date.js +73 -61
  142. package/src/utility/validation/validate/email-test.js +36 -0
  143. package/src/utility/validation/validate/email.js +6 -0
  144. package/src/utility/validation/validate/index.js +7 -0
  145. package/webpack.config.js +90 -0
  146. package/x25.wiki/Account.md +41 -0
  147. package/x25.wiki/Company.md +39 -0
  148. package/x25.wiki/Header.md +21 -0
  149. package/x25.wiki/Home.md +1 -0
  150. package/x25.wiki/Inputs.md +33 -0
  151. package/x25.wiki/Messages.md +27 -0
  152. package/x25.wiki/Payment.md +42 -0
  153. package/Account/Load.js +0 -75
  154. package/Account/actions.js +0 -15
  155. package/Account/index.js +0 -20
  156. package/Account/reducer.js +0 -122
  157. package/Account/request.js +0 -44
  158. package/Async/InitModule.js +0 -190
  159. package/Async/RouteLoading.js +0 -64
  160. package/Async/SimulatedException.js +0 -44
  161. package/Async/index.js +0 -95
  162. package/Async/types.js +0 -1
  163. package/Company/Load.js +0 -82
  164. package/Company/actions.js +0 -15
  165. package/Company/index.js +0 -20
  166. package/Company/reducer.js +0 -165
  167. package/Company/request.js +0 -36
  168. package/Company/util.js +0 -10
  169. package/Header/AccountOptionsContainer.js +0 -144
  170. package/Header/AdminSelectCompany.js +0 -109
  171. package/Header/ClientSelectCompany.js +0 -104
  172. package/Header/Header.js +0 -127
  173. package/Header/HeaderContainer.js +0 -39
  174. package/Header/Logo.js +0 -30
  175. package/Header/LogoutButton.js +0 -39
  176. package/Header/index.js +0 -19
  177. package/Header/request.js +0 -26
  178. package/Header/types.js +0 -1
  179. package/Header/util.js +0 -58
  180. package/Inputs/Business/BankAccount.js +0 -48
  181. package/Inputs/Business/BankName.js +0 -49
  182. package/Inputs/Business/CifField.js +0 -112
  183. package/Inputs/Business/CifFieldContainer.js +0 -157
  184. package/Inputs/Business/Email.js +0 -37
  185. package/Inputs/Business/NidField.js +0 -91
  186. package/Inputs/Business/Phone.js +0 -37
  187. package/Inputs/Business/index.js +0 -34
  188. package/Inputs/Business/request.js +0 -39
  189. package/Inputs/CaptchaBox.js +0 -151
  190. package/Inputs/DateInput.js +0 -172
  191. package/Inputs/DateTemplate.js +0 -200
  192. package/Inputs/DelayInputChange.js +0 -135
  193. package/Inputs/FocusTemplate.js +0 -47
  194. package/Inputs/InputTemplate.js +0 -78
  195. package/Inputs/LabelTemplate.js +0 -59
  196. package/Inputs/NumericInput.js +0 -139
  197. package/Inputs/NumericTemplate.js +0 -148
  198. package/Inputs/Selects/County.js +0 -29
  199. package/Inputs/Selects/Custom.js +0 -56
  200. package/Inputs/Selects/Simple.js +0 -75
  201. package/Inputs/Selects/index.js +0 -52
  202. package/Inputs/SimpleInput.js +0 -42
  203. package/Inputs/SimpleTextarea.js +0 -47
  204. package/Inputs/TextareaTemplate.js +0 -55
  205. package/Inputs/Tooltip.js +0 -82
  206. package/Inputs/index.js +0 -185
  207. package/Messages/Error.js +0 -106
  208. package/Messages/Loading.js +0 -68
  209. package/Messages/index.js +0 -29
  210. package/Modal/Delete.js +0 -240
  211. package/Modal/Root.js +0 -81
  212. package/Modal/SimpleModal.js +0 -57
  213. package/Modal/actions.js +0 -10
  214. package/Modal/getComponent.js +0 -42
  215. package/Modal/index.js +0 -22
  216. package/Modal/reducer.js +0 -53
  217. package/Modal/types.js +0 -7
  218. package/Modal/util.js +0 -17
  219. package/Payment/EstimatePrice/Description.js +0 -92
  220. package/Payment/EstimatePrice/PayBox.js +0 -220
  221. package/Payment/EstimatePrice/index.js +0 -92
  222. package/Payment/EstimatePrice/util.js +0 -21
  223. package/Payment/MobilpayForm.js +0 -86
  224. package/Payment/Modal/BankTransfer.js +0 -233
  225. package/Payment/Modal/CompanyValability.js +0 -28
  226. package/Payment/Modal/DoneForm.js +0 -222
  227. package/Payment/Modal/PaymentDone.js +0 -53
  228. package/Payment/Modal/index.js +0 -27
  229. package/Payment/actions.js +0 -23
  230. package/Payment/index.js +0 -141
  231. package/Payment/request.js +0 -49
  232. package/Payment/types.js +0 -1
  233. package/Payment/util.js +0 -50
  234. package/Payment/validate.js +0 -23
  235. package/Sidebar.js +0 -156
  236. package/Things.js +0 -53
  237. package/actions.js +0 -73
  238. package/config.js +0 -10
  239. package/dev/ErrorBoundary.js +0 -109
  240. package/dev/TheError.js +0 -113
  241. package/dev/index.js +0 -132
  242. package/dev/types.js +0 -1
  243. package/prod/SentryErrorBoundary.js +0 -150
  244. package/reducer/captchas.js +0 -51
  245. package/reducer/counties.js +0 -57
  246. package/reducer/index.js +0 -38
  247. package/reducer/module.js +0 -48
  248. package/style/index.css +0 -1
  249. package/style/sidebar.css +0 -1
  250. package/types.js +0 -1
  251. package/utility/calendar.js +0 -45
  252. package/utility/date.js +0 -111
  253. package/utility/index.js +0 -125
  254. package/utility/language.js +0 -20
  255. package/utility/mql.js +0 -6
  256. package/utility/normalize-test.js +0 -54
  257. package/utility/normalize.js +0 -108
  258. package/utility/numbers.js +0 -93
  259. package/utility/numeric.js +0 -103
  260. package/utility/others.js +0 -142
  261. package/utility/strings-test.js +0 -216
  262. package/utility/strings.js +0 -85
  263. package/utility/validation/common.js +0 -278
  264. package/utility/validation/index.js +0 -110
  265. package/utility/validation/specific.js +0 -14
  266. package/utility/validation/validate/bank-test.js +0 -41
  267. package/utility/validation/validate/bank.js +0 -176
  268. package/utility/validation/validate/cif-test.js +0 -37
  269. package/utility/validation/validate/cif.js +0 -44
  270. package/utility/validation/validate/cnp-test.js +0 -68
  271. package/utility/validation/validate/cnp.js +0 -193
  272. package/utility/validation/validate/email-test.js +0 -30
  273. package/utility/validation/validate/email.js +0 -11
  274. package/utility/validation/validate/index.js +0 -65
@@ -0,0 +1,261 @@
1
+ // @flow
2
+ /* eslint-disable no-magic-numbers, max-statements */
3
+
4
+ export const isValidCNP = (rawValue : string) : boolean => {
5
+
6
+ type CNP = Array<number>;
7
+
8
+ type PositionPropTypes = {
9
+ [key: string]: number;
10
+ };
11
+
12
+ const decimalSystem = 10,
13
+ position : PositionPropTypes = {
14
+ yearMillenium : 0,
15
+ sex : 0,
16
+
17
+ yearDecades : 1,
18
+ yearUnits : 2,
19
+
20
+ monthDecimals : 3,
21
+ monthUnits : 4,
22
+
23
+ dayDecimals : 5,
24
+ dayUnits : 6,
25
+
26
+ countyDecimals : 7,
27
+ countyUnits : 8,
28
+
29
+ numberHundreds : 9,
30
+ numberDecimals : 10,
31
+ numberUnits : 11,
32
+
33
+ controlDigit: 12,
34
+ },
35
+ getCNP = (raw : string) : CNP => {
36
+
37
+ let hashResult = 0;
38
+
39
+ const hashTable = [
40
+ 2,
41
+ 7,
42
+ 9,
43
+ 1,
44
+ 4,
45
+ 6,
46
+ 3,
47
+ 5,
48
+ 8,
49
+ 2,
50
+ 7,
51
+ 9,
52
+ ],
53
+ normalLength = 13,
54
+ cnp = [];
55
+
56
+ const reduceHash = (rawHash : number) : number => {
57
+ const
58
+ nrOfDigits = 11,
59
+ reduced = parseInt(rawHash % nrOfDigits,
60
+ decimalSystem);
61
+
62
+ if (reduced === 10) {
63
+ return 1;
64
+ }
65
+
66
+ return reduced;
67
+ };
68
+
69
+ if (raw.length !== normalLength) {
70
+ throw new Error(`The length [actual:${raw.length}]
71
+ should be ${normalLength} characters`);
72
+ }
73
+
74
+ if (raw[0] === "0") {
75
+ throw new Error("The sex can not be 0");
76
+ }
77
+
78
+ const controlDigit = parseInt(
79
+ raw.charAt(position.controlDigit),
80
+ decimalSystem,
81
+ );
82
+
83
+ if (isNaN(controlDigit)) {
84
+ throw new Error("The control digit should be number");
85
+ }
86
+
87
+ for (let index = 0; index < 12; index += 1) {
88
+
89
+ const rawChar = raw.charAt(index),
90
+ parsedValue = parseInt(rawChar,
91
+ decimalSystem),
92
+ correspondingHashNumber = hashTable[index];
93
+
94
+ if (isNaN(parsedValue)) {
95
+ throw new Error(`The char at position ${index} should be numeric`);
96
+ }
97
+
98
+ cnp[index] = parsedValue;
99
+ hashResult += (parsedValue * correspondingHashNumber);
100
+ }
101
+
102
+ if (controlDigit !== reduceHash(hashResult)) {
103
+ throw new Error(`
104
+ The control digit is not good
105
+ [${controlDigit} === ${reduceHash(hashResult)}]
106
+ `);
107
+ }
108
+
109
+ return cnp;
110
+ },
111
+ validate = (cnp : CNP) => {
112
+ const getCNPDigit = (currentPosition : number) : number => cnp[currentPosition],
113
+ isValidDate = () => {
114
+ const getYear = () : number => {
115
+ const computeYear = () : number => {
116
+ const {
117
+ yearMillenium,
118
+ yearDecades,
119
+ yearUnits,
120
+ } = position;
121
+
122
+ let year = (
123
+ (getCNPDigit(yearDecades) * 10) +
124
+ getCNPDigit(yearUnits)
125
+ );
126
+
127
+ switch (getCNPDigit(yearMillenium)) {
128
+ case 1:
129
+ case 2:
130
+ year += 1900;
131
+ break;
132
+ case 3:
133
+ case 4:
134
+ year += 1800;
135
+ break;
136
+ case 5:
137
+ case 6:
138
+ year += 2000;
139
+ break;
140
+
141
+ // 7,8,9
142
+ default: {
143
+ year += 2000;
144
+
145
+ const today : any = new Date(),
146
+ tempYear = parseInt(today.getYear(),
147
+ 10) - 14;
148
+
149
+ if (year > tempYear) {
150
+ year -= 100;
151
+ }
152
+ }
153
+ break;
154
+ }
155
+
156
+ return year;
157
+ },
158
+ year : number = computeYear();
159
+
160
+ if (year < 1800 || year > 2099) {
161
+ throw new Error(`
162
+ Year [actual: ${String(year)}] is not valid.
163
+ It should be between 1800 and 2099
164
+ `);
165
+ }
166
+
167
+ return year;
168
+ };
169
+
170
+ const year : number = getYear();
171
+
172
+ const {
173
+ monthDecimals,
174
+ monthUnits,
175
+ dayDecimals,
176
+ dayUnits,
177
+ } = position,
178
+ month = (
179
+ (getCNPDigit(monthDecimals) * 10) +
180
+ getCNPDigit(monthUnits)
181
+ ),
182
+ day = (
183
+ (getCNPDigit(dayDecimals) * 10) +
184
+ getCNPDigit(dayUnits)
185
+ ),
186
+ // js months are starting from 0 -> 11
187
+ jsMonth = month - 1,
188
+ date = new Date(year,
189
+ jsMonth,
190
+ day,
191
+ 0,
192
+ 0,
193
+ 0,
194
+ 0);
195
+
196
+ if (
197
+ (date.getFullYear() !== year) ||
198
+ (date.getMonth() !== jsMonth) ||
199
+ (date.getDate() !== day)
200
+ ) {
201
+ throw new Error(`
202
+ The given date
203
+ [
204
+ year -> ${String(year)}
205
+ month -> ${String(month)}
206
+ day -> ${String(day)}
207
+ ]`);
208
+ }
209
+ },
210
+ isValidCounty = () => {
211
+ const {
212
+ countyDecimals,
213
+ countyUnits,
214
+ } = position,
215
+ lowerLimit = 1,
216
+ upperLimit = 52,
217
+ code = (
218
+ (getCNPDigit(countyDecimals) * 10) +
219
+ getCNPDigit(countyUnits)
220
+ );
221
+
222
+ if (
223
+ code < lowerLimit ||
224
+ code > upperLimit
225
+ ) {
226
+ throw new Error(`
227
+ The country code is invalid [actual: ${code}],
228
+ should be between: ${lowerLimit} <= ${code} >= ${upperLimit}
229
+ `);
230
+ }
231
+ },
232
+ isValidNumber = () => {
233
+ const {
234
+ numberHundreds,
235
+ numberDecimals,
236
+ numberUnits,
237
+ } = position,
238
+ number = (
239
+ (getCNPDigit(numberHundreds) * 100) +
240
+ (getCNPDigit(numberDecimals) * 10) +
241
+ getCNPDigit(numberUnits)
242
+ );
243
+
244
+ if (number === 0) {
245
+ throw new Error("The number should not be 0");
246
+ }
247
+ };
248
+
249
+ isValidDate();
250
+ isValidCounty();
251
+ isValidNumber();
252
+ };
253
+
254
+ try {
255
+ validate(getCNP(rawValue));
256
+
257
+ return true;
258
+ } catch (error) {
259
+ return false;
260
+ }
261
+ };
@@ -1,61 +1,73 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- /* eslint-disable no-magic-numbers */
8
-
9
- var pattern = /^[0-9]{1,2}\.[0-9]{2}\.[0-9]{4}$/,
10
- monthLength = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
11
-
12
- // 2018-03-31T00:00:00.000Z
13
- // 2015-02-25T00:00:00Z
14
- var isValidDateStamp = exports.isValidDateStamp = function isValidDateStamp(raw) {
15
-
16
- if (typeof raw !== "string" || raw.length < 20 || raw.length > 24) {
17
- return false;
18
- }
19
-
20
- var value = new Date(raw);
21
-
22
- if (Object.prototype.toString.call(value) === "[object Date]") {
23
- if (isNaN(value.getTime())) {
24
- return false;
25
- }
26
-
27
- return true;
28
- }
29
- return false;
30
- };
31
-
32
- // e.g. 25.08.2015
33
- var isValidDate = exports.isValidDate = function isValidDate(dateString) {
34
-
35
- if (typeof dateString !== "string" || dateString.length !== 10) {
36
- return false;
37
- }
38
-
39
- if (!pattern.test(dateString)) {
40
- return false;
41
- }
42
-
43
- // Parse the date parts to integers
44
- var parts = dateString.split("."),
45
- day = parseInt(parts[0], 10),
46
- month = parseInt(parts[1], 10),
47
- year = parseInt(parts[2], 10);
48
-
49
- // Check the ranges of month and year
50
- if (year < 1000 || year > 3000 || month === 0 || month > 12) {
51
- return false;
52
- }
53
-
54
- // Adjust for leap years
55
- if (year % 400 === 0 || year % 100 !== 0 || year % 4 !== 0) {
56
- monthLength[1] = 29;
57
- }
58
-
59
- // Check the range of the day
60
- return day > 0 && day <= monthLength[month - 1];
61
- };
1
+ // @flow
2
+ /* eslint-disable no-magic-numbers */
3
+
4
+ const
5
+ pattern = /^\d{1,2}\.\d{2}\.\d{4}$/u,
6
+ monthLength = [
7
+ 31,
8
+ 28,
9
+ 31,
10
+ 30,
11
+ 31,
12
+ 30,
13
+ 31,
14
+ 31,
15
+ 30,
16
+ 31,
17
+ 30,
18
+ 31,
19
+ ];
20
+
21
+ // 2018-03-31T00:00:00.000Z
22
+ // 2015-02-25T00:00:00Z
23
+ export const isValidDateStamp = (raw: any) => {
24
+
25
+ if (typeof raw !== "string" || raw.length < 20 || raw.length > 24) {
26
+ return false;
27
+ }
28
+
29
+ const value = new Date(raw);
30
+
31
+ if (Object.prototype.toString.call(value) === "[object Date]") {
32
+ if (isNaN(value.getTime())) {
33
+ return false;
34
+ }
35
+
36
+ return true;
37
+ }
38
+ return false;
39
+ };
40
+
41
+ // e.g. 25.08.2015
42
+ export const isValidDate = (dateString : string) : boolean => {
43
+
44
+ if (typeof dateString !== "string" || dateString.length !== 10) {
45
+ return false;
46
+ }
47
+
48
+ if (!pattern.test(dateString)) {
49
+ return false;
50
+ }
51
+
52
+ // Parse the date parts to integers
53
+ const parts = dateString.split("."),
54
+ day = parseInt(parts[0],
55
+ 10),
56
+ month = parseInt(parts[1],
57
+ 10),
58
+ year = parseInt(parts[2],
59
+ 10);
60
+
61
+ // Check the ranges of month and year
62
+ if (year < 1000 || year > 3000 || month === 0 || month > 12) {
63
+ return false;
64
+ }
65
+
66
+ // Adjust for leap years
67
+ if ((year % 400 === 0) || (year % 100 !== 0) || (year % 4 !== 0)) {
68
+ monthLength[1] = 29;
69
+ }
70
+
71
+ // Check the range of the day
72
+ return day > 0 && day <= monthLength[month - 1];
73
+ };
@@ -0,0 +1,36 @@
1
+ import { isValidEmail } from "./email";
2
+
3
+ const valid = true,
4
+ notValid = false;
5
+
6
+ describe("given an email without @ [email]",
7
+ () => {
8
+ it("should not be valid",
9
+ () => {
10
+ expect(isValidEmail("email")).toBe(notValid);
11
+ });
12
+ });
13
+
14
+ describe("given an email without the user [email@]",
15
+ () => {
16
+ it("should not be valid",
17
+ () => {
18
+ expect(isValidEmail("email@")).toBe(notValid);
19
+ });
20
+ });
21
+
22
+ describe("given an email without domain [email@email]",
23
+ () => {
24
+ it("should not be valid",
25
+ () => {
26
+ expect(isValidEmail("email@email")).toBe(notValid);
27
+ });
28
+ });
29
+
30
+ describe("given a good email (email@email.ro)",
31
+ () => {
32
+ it("should be valid",
33
+ () => {
34
+ expect(isValidEmail("email@email.ro")).toBe(valid);
35
+ });
36
+ });
@@ -0,0 +1,6 @@
1
+ // @flow
2
+
3
+ export const isValidEmail = (value : string) : boolean => (
4
+ /* eslint-disable-next-line */
5
+ new RegExp(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/igm).test(value)
6
+ );
@@ -0,0 +1,7 @@
1
+ // @flow
2
+
3
+ export * from "./date";
4
+ export * from "./email";
5
+ export * from "./cif";
6
+ export * from "./cnp";
7
+ export * from "./bank";
@@ -0,0 +1,90 @@
1
+ 'use strict'
2
+
3
+ var webpack = require('webpack')
4
+ var env = process.env.NODE_ENV
5
+
6
+ var config = {
7
+ module: {
8
+ loaders: [
9
+ {
10
+ test : /\.jsx?$/u,
11
+ use : ["babel-loader"],
12
+ exclude: /node_modules/
13
+ },
14
+ {
15
+ test : /\.scss$/u,
16
+ use : [
17
+ "style-loader",
18
+ "css-loader",
19
+ "sass-loader",
20
+ ],
21
+ },
22
+ {
23
+ test : /\.css$/u,
24
+ use : [
25
+ "style-loader",
26
+ "css-loader",
27
+ ],
28
+ },
29
+ {
30
+ test : /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/u,
31
+ use : "url-loader?limit=10000&minetype=application/font-woff",
32
+ },
33
+ {
34
+ test : /\.jpe?g$|\.gif$|\.png$/u,
35
+ use : "url-loader",
36
+ },
37
+ {
38
+ test : /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/u,
39
+ use : "file-loader",
40
+ }
41
+ ]
42
+ },
43
+ resolve: {
44
+ extensions: [
45
+ ".js",
46
+ ".jsx",
47
+ ],
48
+ modules: [
49
+ "client",
50
+ "node_modules",
51
+ ],
52
+ },
53
+ output: {
54
+ library: 'ReactPaginator',
55
+ libraryTarget: 'umd'
56
+ },
57
+ plugins: [
58
+ new webpack.DefinePlugin({
59
+ "process.env": {
60
+ "NODE_ENV": JSON.stringify("development"),
61
+ },
62
+ }),
63
+ new webpack.DefinePlugin({
64
+ "process.env": {
65
+ "BABEL_ENV": JSON.stringify("developmentTime"),
66
+ },
67
+ })
68
+ ]
69
+ }
70
+
71
+ if (env === 'production') {
72
+ config.plugins.push(
73
+ new webpack.DefinePlugin({
74
+ "process.env": {
75
+ "NODE_ENV": JSON.stringify("production"),
76
+ },
77
+ }),
78
+ new webpack.DefinePlugin({
79
+ "process.env": {
80
+ "BABEL_ENV": JSON.stringify("production"),
81
+ },
82
+ }),
83
+ new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /ro/),
84
+ new webpack.optimize.UglifyJsPlugin({
85
+ mangle: false,
86
+ }),
87
+ )
88
+ }
89
+
90
+ module.exports = config
@@ -0,0 +1,41 @@
1
+ Contains all information about the current account.
2
+
3
+ The module `x25/Account` has:
4
+ - `<LoadAccount appName="auto" />`
5
+ - `accountSelectors`
6
+ - `accountReducer`
7
+
8
+ # LoadAccount
9
+
10
+ It loads the account. The `appName` is the application for which is done the init-session
11
+
12
+ Example:
13
+ ```jsx
14
+
15
+ import { LoadAccount } from "x25/Account";
16
+
17
+ <LoadAccount appName="auto">
18
+ <div />
19
+ </LoadAccount>
20
+ ```
21
+
22
+ It does not display `<div />` until the account is loaded
23
+
24
+
25
+ # accountSelectors
26
+
27
+
28
+ ```jsx
29
+ export const selectors = {
30
+ getCurrentAccount,
31
+ getCurrentAccountIsFetching,
32
+ getCurrentAccountShouldFetch,
33
+ getCurrentAccountIsFetched,
34
+ getCurrentAccountHasError,
35
+
36
+ getIsCurrentAccountAdministrator,
37
+
38
+ getCurrentAccountCompanies,
39
+ };
40
+
41
+ ```
@@ -0,0 +1,39 @@
1
+ Contains all information about the current company.
2
+
3
+ The module `x25/Company` has:
4
+ - `<LoadCompany />`
5
+ - `companySelectors`
6
+ - `companyReducer`
7
+
8
+ # LoadCompany
9
+
10
+ It loads the company
11
+
12
+ Example:
13
+ ```jsx
14
+
15
+ import { LoadCompany } from "x25/Company";
16
+
17
+ <LoadCompany>
18
+ <div />
19
+ </LoadCompany>
20
+ ```
21
+
22
+ It does not display `<div />` until the company is loaded
23
+
24
+
25
+ # companySelectors
26
+
27
+
28
+ ```jsx
29
+ export const selectors = {
30
+ getCurrentCompany,
31
+ getCurrentCompanyIsFetched,
32
+ getCurrentCompanyIsFetching,
33
+ getCurrentCompanyHasError,
34
+ getCurrentCompanyShouldFetch,
35
+ getCompanyModules,
36
+ getCurrentCompanyID,
37
+ };
38
+
39
+ ```
@@ -0,0 +1,21 @@
1
+ The module `x25/Header` exports:
2
+ - `<SideworkLogo />`
3
+ - `<Header ...props />`
4
+
5
+ ## `<Header ...props />`
6
+
7
+ ```jsx
8
+ type HeaderPropTypes = {
9
+ brand : string;
10
+ accountName : string;
11
+ isAdmin: bool;
12
+ sidebarDocked: boolean;
13
+ ui: {
14
+ showNavbar: boolean;
15
+ };
16
+
17
+ toggleNavbar: () => void;
18
+
19
+ showSidebar: () => void;
20
+ };
21
+ ```
@@ -0,0 +1 @@
1
+ Welcome to the x25 wiki!
@@ -0,0 +1,33 @@
1
+ The module `x25/Inputs` exports:
2
+
3
+ ```jsx
4
+ export {
5
+ SimpleInput,
6
+ DelayInputChange,
7
+ FocusTemplate,
8
+ InputTemplate,
9
+ DateTemplate,
10
+ DateInput,
11
+ NumericInput,
12
+ NumericTemplate,
13
+ TextareaTemplate,
14
+ SimpleTextarea,
15
+ CaptchaBox,
16
+ LabelTemplate,
17
+ Tooltip,
18
+
19
+ // business
20
+ EmailInput,
21
+ PhoneInput,
22
+ BankAccountInput,
23
+ BankNameField,
24
+ CifFieldContainer,
25
+
26
+ // selects
27
+ SelectMonth,
28
+ SelectYear,
29
+ SelectCounty,
30
+ CustomSelect,
31
+ SimpleCustomSelect,
32
+ };
33
+ ```
@@ -0,0 +1,27 @@
1
+
2
+ The module `x25/Messages` has:
3
+ - `<LoadingMessage ...props />`
4
+ - `<ErrorMessage ...props />`
5
+ - `<LargeErrorMessage ...props />`
6
+
7
+ ## `<LoadingMessage ...props />`
8
+
9
+ ```jsx
10
+ type LoadingMessagePropTypes = {
11
+ className? : string;
12
+ message? : string;
13
+ sm?: bool;
14
+ };
15
+ ```
16
+
17
+ ## `<LargeErrorMessage ...props />`, `<ErrorMessage ...props />`
18
+
19
+ ```jsx
20
+ type ErrorMessageProps = {
21
+ message: string;
22
+ details?: string;
23
+ itemNotFound?: boolean;
24
+
25
+ onRetry?: () => void;
26
+ };
27
+ ```