x25 3.0.0 → 17.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/Account/Load.js +75 -0
  2. package/Account/actions.js +15 -0
  3. package/Account/index.js +20 -0
  4. package/Account/reducer.js +122 -0
  5. package/Account/request.js +44 -0
  6. package/Async/InitModule.js +190 -0
  7. package/Async/RouteLoading.js +64 -0
  8. package/Async/SimulatedException.js +44 -0
  9. package/Async/index.js +95 -0
  10. package/Async/types.js +1 -0
  11. package/Company/Load.js +82 -0
  12. package/Company/actions.js +15 -0
  13. package/Company/index.js +20 -0
  14. package/Company/reducer.js +165 -0
  15. package/Company/request.js +36 -0
  16. package/Company/util.js +10 -0
  17. package/Header/AccountOptionsContainer.js +144 -0
  18. package/Header/AdminSelectCompany.js +109 -0
  19. package/Header/ClientSelectCompany.js +104 -0
  20. package/Header/Header.js +127 -0
  21. package/Header/HeaderContainer.js +39 -0
  22. package/Header/Logo.js +30 -0
  23. package/Header/LogoutButton.js +39 -0
  24. package/Header/index.js +19 -0
  25. package/Header/request.js +26 -0
  26. package/Header/types.js +1 -0
  27. package/Header/util.js +58 -0
  28. package/Inputs/Business/BankAccount.js +48 -0
  29. package/Inputs/Business/BankName.js +49 -0
  30. package/Inputs/Business/CifField.js +112 -0
  31. package/Inputs/Business/CifFieldContainer.js +157 -0
  32. package/Inputs/Business/Email.js +37 -0
  33. package/Inputs/Business/NidField.js +91 -0
  34. package/Inputs/Business/Phone.js +37 -0
  35. package/Inputs/Business/index.js +34 -0
  36. package/Inputs/Business/request.js +39 -0
  37. package/Inputs/CaptchaBox.js +151 -0
  38. package/Inputs/DateInput.js +172 -0
  39. package/Inputs/DateTemplate.js +200 -0
  40. package/Inputs/DelayInputChange.js +135 -0
  41. package/Inputs/FocusTemplate.js +47 -0
  42. package/Inputs/InputTemplate.js +78 -0
  43. package/Inputs/LabelTemplate.js +59 -0
  44. package/Inputs/NumericInput.js +139 -0
  45. package/Inputs/NumericTemplate.js +148 -0
  46. package/Inputs/Selects/County.js +29 -0
  47. package/Inputs/Selects/Custom.js +56 -0
  48. package/Inputs/Selects/Simple.js +75 -0
  49. package/Inputs/Selects/index.js +52 -0
  50. package/Inputs/SimpleInput.js +42 -0
  51. package/Inputs/SimpleTextarea.js +47 -0
  52. package/Inputs/TextareaTemplate.js +55 -0
  53. package/Inputs/Tooltip.js +82 -0
  54. package/Inputs/index.js +185 -0
  55. package/Messages/Error.js +106 -0
  56. package/Messages/Loading.js +68 -0
  57. package/Messages/index.js +29 -0
  58. package/Modal/Delete.js +240 -0
  59. package/Modal/Root.js +81 -0
  60. package/Modal/SimpleModal.js +57 -0
  61. package/Modal/actions.js +10 -0
  62. package/Modal/getComponent.js +42 -0
  63. package/Modal/index.js +22 -0
  64. package/Modal/reducer.js +53 -0
  65. package/Modal/types.js +7 -0
  66. package/Modal/util.js +17 -0
  67. package/Payment/EstimatePrice/Description.js +92 -0
  68. package/Payment/EstimatePrice/PayBox.js +220 -0
  69. package/Payment/EstimatePrice/index.js +92 -0
  70. package/Payment/EstimatePrice/util.js +21 -0
  71. package/Payment/MobilpayForm.js +86 -0
  72. package/Payment/Modal/BankTransfer.js +233 -0
  73. package/Payment/Modal/CompanyValability.js +28 -0
  74. package/Payment/Modal/DoneForm.js +222 -0
  75. package/Payment/Modal/PaymentDone.js +53 -0
  76. package/Payment/Modal/index.js +27 -0
  77. package/Payment/actions.js +23 -0
  78. package/{src/Payment → Payment}/codes.js +19 -16
  79. package/Payment/index.js +141 -0
  80. package/Payment/request.js +49 -0
  81. package/Payment/types.js +1 -0
  82. package/Payment/util.js +50 -0
  83. package/Payment/validate.js +23 -0
  84. package/Sidebar.js +156 -0
  85. package/Things.js +53 -0
  86. package/actions.js +73 -0
  87. package/config.js +10 -0
  88. package/dev/ErrorBoundary.js +109 -0
  89. package/dev/TheError.js +113 -0
  90. package/dev/index.js +132 -0
  91. package/dev/types.js +1 -0
  92. package/package.json +13 -13
  93. package/prod/SentryErrorBoundary.js +150 -0
  94. package/reducer/captchas.js +51 -0
  95. package/reducer/counties.js +57 -0
  96. package/reducer/index.js +38 -0
  97. package/reducer/module.js +48 -0
  98. package/style/index.css +1 -0
  99. package/style/sidebar.css +1 -0
  100. package/types.js +1 -0
  101. package/utility/calendar.js +45 -0
  102. package/utility/date.js +111 -0
  103. package/utility/index.js +125 -0
  104. package/utility/language.js +20 -0
  105. package/utility/mql.js +6 -0
  106. package/utility/normalize-test.js +54 -0
  107. package/utility/normalize.js +108 -0
  108. package/utility/numbers.js +93 -0
  109. package/utility/numeric.js +103 -0
  110. package/utility/others.js +142 -0
  111. package/utility/strings-test.js +216 -0
  112. package/utility/strings.js +85 -0
  113. package/utility/validation/common.js +278 -0
  114. package/utility/validation/index.js +110 -0
  115. package/utility/validation/specific.js +14 -0
  116. package/utility/validation/validate/bank-test.js +41 -0
  117. package/utility/validation/validate/bank.js +176 -0
  118. package/utility/validation/validate/cif-test.js +37 -0
  119. package/utility/validation/validate/cif.js +44 -0
  120. package/utility/validation/validate/cnp-test.js +68 -0
  121. package/utility/validation/validate/cnp.js +193 -0
  122. package/{src/utility → utility}/validation/validate/date.js +61 -73
  123. package/utility/validation/validate/email-test.js +30 -0
  124. package/utility/validation/validate/email.js +11 -0
  125. package/utility/validation/validate/index.js +65 -0
  126. package/.eslintignore +0 -2
  127. package/.eslintrc.json +0 -275
  128. package/.flowconfig +0 -23
  129. package/conf/dev.js +0 -19
  130. package/conf/dist.js +0 -19
  131. package/conf/polyfills/tempPolyfills.js +0 -7
  132. package/src/Account/Load.jsx +0 -79
  133. package/src/Account/actions.js +0 -10
  134. package/src/Account/index.js +0 -11
  135. package/src/Account/reducer.js +0 -139
  136. package/src/Account/request.js +0 -36
  137. package/src/Async/InitModule.jsx +0 -114
  138. package/src/Async/RouteLoading.jsx +0 -52
  139. package/src/Async/SimulatedException.jsx +0 -19
  140. package/src/Async/index.jsx +0 -75
  141. package/src/Async/types.js +0 -39
  142. package/src/Company/Load.jsx +0 -84
  143. package/src/Company/actions.js +0 -10
  144. package/src/Company/index.js +0 -11
  145. package/src/Company/reducer.js +0 -201
  146. package/src/Company/request.js +0 -30
  147. package/src/Company/util.js +0 -7
  148. package/src/Header/AccountOptionsContainer.jsx +0 -124
  149. package/src/Header/AdminSelectCompany.jsx +0 -101
  150. package/src/Header/ClientSelectCompany.jsx +0 -90
  151. package/src/Header/Header.jsx +0 -120
  152. package/src/Header/HeaderContainer.jsx +0 -30
  153. package/src/Header/Logo.jsx +0 -16
  154. package/src/Header/LogoutButton.jsx +0 -34
  155. package/src/Header/index.jsx +0 -9
  156. package/src/Header/request.js +0 -28
  157. package/src/Header/types.js +0 -6
  158. package/src/Header/util.jsx +0 -61
  159. package/src/Inputs/Business/BankAccount.jsx +0 -39
  160. package/src/Inputs/Business/BankName.jsx +0 -40
  161. package/src/Inputs/Business/CifField.jsx +0 -93
  162. package/src/Inputs/Business/CifFieldContainer.jsx +0 -142
  163. package/src/Inputs/Business/Email.jsx +0 -23
  164. package/src/Inputs/Business/NidField.jsx +0 -77
  165. package/src/Inputs/Business/Phone.jsx +0 -23
  166. package/src/Inputs/Business/index.js +0 -16
  167. package/src/Inputs/Business/request.js +0 -39
  168. package/src/Inputs/CaptchaBox.jsx +0 -131
  169. package/src/Inputs/DateInput.jsx +0 -188
  170. package/src/Inputs/DateTemplate.jsx +0 -213
  171. package/src/Inputs/DelayInputChange.jsx +0 -130
  172. package/src/Inputs/FocusTemplate.jsx +0 -41
  173. package/src/Inputs/InputTemplate.jsx +0 -79
  174. package/src/Inputs/LabelTemplate.jsx +0 -47
  175. package/src/Inputs/NumericInput.jsx +0 -142
  176. package/src/Inputs/NumericTemplate.jsx +0 -155
  177. package/src/Inputs/Selects/County.jsx +0 -19
  178. package/src/Inputs/Selects/Custom.jsx +0 -55
  179. package/src/Inputs/Selects/Simple.jsx +0 -73
  180. package/src/Inputs/Selects/index.jsx +0 -37
  181. package/src/Inputs/SimpleInput.jsx +0 -40
  182. package/src/Inputs/SimpleTextarea.jsx +0 -55
  183. package/src/Inputs/TextareaTemplate.jsx +0 -57
  184. package/src/Inputs/Tooltip.jsx +0 -61
  185. package/src/Inputs/index.js +0 -22
  186. package/src/Messages/Error.jsx +0 -83
  187. package/src/Messages/Loading.jsx +0 -43
  188. package/src/Messages/index.jsx +0 -4
  189. package/src/Modal/Delete.jsx +0 -237
  190. package/src/Modal/Root.jsx +0 -57
  191. package/src/Modal/SimpleModal.jsx +0 -47
  192. package/src/Modal/actions.js +0 -7
  193. package/src/Modal/getComponent.jsx +0 -32
  194. package/src/Modal/index.jsx +0 -12
  195. package/src/Modal/reducer.js +0 -40
  196. package/src/Modal/types.js +0 -6
  197. package/src/Modal/util.js +0 -15
  198. package/src/Payment/EstimatePrice/Description.jsx +0 -101
  199. package/src/Payment/EstimatePrice/PayBox.jsx +0 -173
  200. package/src/Payment/EstimatePrice/index.jsx +0 -63
  201. package/src/Payment/EstimatePrice/util.js +0 -15
  202. package/src/Payment/MobilpayForm.jsx +0 -77
  203. package/src/Payment/Modal/BankTransfer.jsx +0 -129
  204. package/src/Payment/Modal/CompanyValability.jsx +0 -14
  205. package/src/Payment/Modal/DoneForm.jsx +0 -209
  206. package/src/Payment/Modal/PaymentDone.jsx +0 -27
  207. package/src/Payment/Modal/index.js +0 -13
  208. package/src/Payment/actions.jsx +0 -22
  209. package/src/Payment/index.jsx +0 -124
  210. package/src/Payment/request.js +0 -50
  211. package/src/Payment/types.js +0 -14
  212. package/src/Payment/util.jsx +0 -52
  213. package/src/Payment/validate.js +0 -25
  214. package/src/Sidebar.jsx +0 -158
  215. package/src/Things.jsx +0 -35
  216. package/src/actions.js +0 -36
  217. package/src/config.js +0 -7
  218. package/src/dev/ErrorBoundary.jsx +0 -98
  219. package/src/dev/TheError.jsx +0 -87
  220. package/src/dev/index.js +0 -127
  221. package/src/dev/types.js +0 -10
  222. package/src/prod/SentryErrorBoundary.jsx +0 -98
  223. package/src/reducer/captchas.js +0 -44
  224. package/src/reducer/counties.js +0 -46
  225. package/src/reducer/index.js +0 -25
  226. package/src/reducer/module.jsx +0 -43
  227. package/src/style/.sass-lint.yml +0 -84
  228. package/src/style/.stylelintrc.json +0 -161
  229. package/src/style/_fancy-text.scss +0 -37
  230. package/src/style/_fix_bootstrap_placeholder_color.scss +0 -14
  231. package/src/style/_header-company.scss +0 -69
  232. package/src/style/_inputs.scss +0 -12
  233. package/src/style/_minimal.scss +0 -31
  234. package/src/style/_navigation.scss +0 -24
  235. package/src/style/_others.scss +0 -79
  236. package/src/style/index.scss +0 -7
  237. package/src/style/sidebar/_animations.scss +0 -21
  238. package/src/style/sidebar/_dark-theme.scss +0 -77
  239. package/src/style/sidebar/_scroll.scss +0 -37
  240. package/src/style/sidebar/_structure.scss +0 -299
  241. package/src/style/sidebar.scss +0 -4
  242. package/src/types.js +0 -31
  243. package/src/utility/calendar.js +0 -39
  244. package/src/utility/date.js +0 -100
  245. package/src/utility/index.js +0 -12
  246. package/src/utility/language.js +0 -17
  247. package/src/utility/mql.js +0 -3
  248. package/src/utility/normalize-test.js +0 -58
  249. package/src/utility/normalize.js +0 -119
  250. package/src/utility/numbers.js +0 -87
  251. package/src/utility/numeric.js +0 -114
  252. package/src/utility/others.jsx +0 -160
  253. package/src/utility/strings-test.js +0 -136
  254. package/src/utility/strings.js +0 -80
  255. package/src/utility/validation/common.js +0 -360
  256. package/src/utility/validation/index.js +0 -70
  257. package/src/utility/validation/specific.js +0 -9
  258. package/src/utility/validation/validate/bank-test.js +0 -129
  259. package/src/utility/validation/validate/bank.js +0 -176
  260. package/src/utility/validation/validate/cif-test.js +0 -105
  261. package/src/utility/validation/validate/cif.js +0 -44
  262. package/src/utility/validation/validate/cnp-test.js +0 -216
  263. package/src/utility/validation/validate/cnp.js +0 -261
  264. package/src/utility/validation/validate/email-test.js +0 -36
  265. package/src/utility/validation/validate/email.js +0 -6
  266. package/src/utility/validation/validate/index.js +0 -7
  267. package/webpack.config.js +0 -90
  268. package/x25.wiki/Account.md +0 -41
  269. package/x25.wiki/Company.md +0 -39
  270. package/x25.wiki/Header.md +0 -21
  271. package/x25.wiki/Home.md +0 -1
  272. package/x25.wiki/Inputs.md +0 -33
  273. package/x25.wiki/Messages.md +0 -27
  274. package/x25.wiki/Payment.md +0 -42
@@ -1,299 +0,0 @@
1
- %animated {
2
- -webkit-transition: all 0.3s ease;
3
- -moz-transition: all 0.3s ease;
4
- -ms-transition: all 0.3s ease;
5
- -o-transition: all 0.3s ease;
6
- transition: all 0.3s ease;
7
- }
8
-
9
- @keyframes swing {
10
- 0% {
11
- transform: rotate(0deg);
12
- }
13
-
14
- 10% {
15
- transform: rotate(10deg);
16
- }
17
-
18
- 30% {
19
- transform: rotate(0deg);
20
- }
21
-
22
- 40% {
23
- transform: rotate(-10deg);
24
- }
25
-
26
- 50% {
27
- transform: rotate(0deg);
28
- }
29
-
30
- 60% {
31
- transform: rotate(5deg);
32
- }
33
-
34
- 70% {
35
- transform: rotate(0deg);
36
- }
37
-
38
- 80% {
39
- transform: rotate(-5deg);
40
- }
41
-
42
- 100% {
43
- transform: rotate(0deg);
44
- }
45
- }
46
-
47
- @keyframes sonar {
48
- 0% {
49
- transform: scale(0.9);
50
- opacity: 1;
51
- }
52
-
53
- 100% {
54
- transform: scale(2);
55
- opacity: 0;
56
- }
57
- }
58
-
59
- .page-wrapper {
60
- height: 100vh;
61
-
62
- .theme {
63
- width: 40px;
64
- height: 40px;
65
- display: inline-block;
66
- border-radius: 4px;
67
- margin: 2px;
68
-
69
- &.dark-theme {
70
- background: #1e2229;
71
- }
72
- }
73
-
74
- .sidebar-wrapper {
75
- width: 240px;
76
- height: 100%;
77
- max-height: 100%;
78
- position: fixed;
79
- top: 0;
80
- z-index: 999;
81
-
82
- .sidebar-footer {
83
- position: absolute;
84
- width: 100%;
85
- bottom: 0;
86
- display: flex;
87
-
88
- > a {
89
- flex-grow: 1;
90
- text-align: center;
91
- height: 30px;
92
- line-height: 30px;
93
- position: relative;
94
-
95
- .notification {
96
- position: absolute;
97
- top: 0;
98
- }
99
- }
100
- }
101
-
102
- .sidebar-content {
103
- max-height: calc(100% - 30px);
104
- height: calc(100% - 30px);
105
- overflow-y: auto;
106
- position: relative;
107
-
108
- .sidebar-brand {
109
- padding: 10px 20px;
110
- display: flex;
111
- align-items: center;
112
-
113
- .sidework {
114
- text-transform: uppercase;
115
- font-weight: bold;
116
- flex-grow: 1;
117
-
118
- @extend %animated;
119
- }
120
-
121
- #close-sidebar {
122
- cursor: pointer;
123
- font-size: 20px;
124
- }
125
- }
126
-
127
- ul {
128
- list-style-type: none;
129
- padding: 0;
130
- margin: 0;
131
- }
132
-
133
- a {
134
- text-decoration: none;
135
- }
136
-
137
- .sidebar-menu {
138
- padding-bottom: 10px;
139
-
140
- ul li a {
141
- font-size: 15px;
142
- font-weight: 500;
143
- -webkit-transition: all 0.3s ease;
144
- -moz-transition: all 0.3s ease;
145
- -ms-transition: all 0.3s ease;
146
- -o-transition: all 0.3s ease;
147
- transition: all 0.3s ease;
148
- display: inline-block;
149
- width: 100%;
150
- text-decoration: none;
151
- position: relative;
152
- padding: 8px 30px 8px 20px;
153
-
154
- span {
155
- &.label,
156
- &.badge {
157
- float: right;
158
- margin-top: 8px;
159
- margin-left: 5px;
160
- }
161
- }
162
-
163
- i {
164
- @extend %animated;
165
-
166
- margin-right: 10px;
167
- font-size: 12px;
168
- width: 30px;
169
- height: 30px;
170
- line-height: 30px;
171
- text-align: center;
172
- border-radius: 4px;
173
- }
174
-
175
- &:hover > i::before {
176
- display: inline-block;
177
- animation: swing ease-in-out 0.5s 1 alternate;
178
- }
179
-
180
- .badge-sonar {
181
- display: inline-block;
182
- background: #980303;
183
- border-radius: 50%;
184
- height: 8px;
185
- width: 8px;
186
- position: absolute;
187
- top: 0;
188
-
189
- &::after {
190
- content: "";
191
- position: absolute;
192
- top: 0;
193
- left: 0;
194
- border: 2px solid #980303;
195
- opacity: 0;
196
- border-radius: 50%;
197
- width: 100%;
198
- height: 100%;
199
- animation: sonar 1.5s infinite;
200
- }
201
- }
202
- }
203
-
204
- .header-menu span {
205
- font-weight: bold;
206
- font-size: 14px;
207
- padding: 15px 20px 5px 20px;
208
- display: inline-block;
209
- }
210
-
211
- .sidebar-dropdown {
212
- font-weight: 500;
213
- font-size: 15px;
214
-
215
- > a::after {
216
- @extend %animated;
217
-
218
- font-family: "FontAwesome", sans-serif;
219
- font-weight: 900;
220
- content: "\f105";
221
- font-style: normal;
222
- display: inline-block;
223
- font-variant: normal;
224
- text-rendering: auto;
225
- -webkit-font-smoothing: antialiased;
226
- -moz-osx-font-smoothing: grayscale;
227
- text-align: center;
228
- background: 0 0;
229
- position: absolute;
230
- right: 15px;
231
- top: 14px;
232
- }
233
-
234
- .sidebar-submenu {
235
- display: none;
236
-
237
- li a {
238
- .badge,
239
- .label {
240
- float: right;
241
- margin-top: 0;
242
- }
243
- }
244
-
245
- ul {
246
- padding: 5px 0;
247
- }
248
-
249
- li {
250
- padding-left: 25px;
251
- font-size: 12px;
252
-
253
- a::before {
254
- @extend %animated;
255
-
256
- content: "\f1db";
257
- font-family: "FontAwesome", sans-serif;
258
- font-weight: 400;
259
- font-style: normal;
260
- display: inline-block;
261
- text-align: center;
262
- text-decoration: none;
263
- -webkit-font-smoothing: antialiased;
264
- -moz-osx-font-smoothing: grayscale;
265
- margin-right: 10px;
266
- font-size: 10px;
267
- }
268
-
269
- a.active::before {
270
- content: "\f111";
271
- font-family: "FontAwesome", sans-serif;
272
- font-weight: 400;
273
- font-style: normal;
274
- display: inline-block;
275
- text-align: center;
276
- text-decoration: none;
277
- -webkit-font-smoothing: antialiased;
278
- -moz-osx-font-smoothing: grayscale;
279
- margin-right: 10px;
280
- font-size: 10px;
281
- }
282
- }
283
- }
284
-
285
- &.active > a::after {
286
- transform: rotate(90deg);
287
- right: 17px;
288
- }
289
- }
290
- }
291
-
292
- -webkit-transition: all 0.3s ease;
293
- -moz-transition: all 0.3s ease;
294
- -ms-transition: all 0.3s ease;
295
- -o-transition: all 0.3s ease;
296
- transition: all 0.3s ease;
297
- }
298
- }
299
- }
@@ -1,4 +0,0 @@
1
- @import "./sidebar/_structure";
2
- @import "./sidebar/_animations";
3
- @import "./sidebar/_scroll";
4
- @import "./sidebar/_dark-theme";
package/src/types.js DELETED
@@ -1,31 +0,0 @@
1
- // @flow
2
- /* eslint-disable no-use-before-define */
3
-
4
- import type { List as ListType, Map as MapType } from "immutable";
5
-
6
- export type State = any;
7
-
8
- export type Action = any;
9
-
10
- export type ErrorType = string;
11
- export type ThunkAction = (dispatch: Dispatch, getState: GetState) => any;
12
- export type Dispatch = (action: any | ThunkAction | PromiseAction) => any;
13
- export type GetState = () => State;
14
- export type PromiseAction = Promise<any>;
15
-
16
- export type ModalActionType = string;
17
-
18
- export type NullUInt = {
19
- Valid: bool;
20
- UInt: number;
21
- };
22
-
23
- export type ModalPayload = {
24
- modalType: ModalActionType;
25
- modalProps: any;
26
- };
27
-
28
- export type NormalizedResult = {
29
- entities : MapType<string, any>;
30
- result : ListType<string>;
31
- };
@@ -1,39 +0,0 @@
1
- // @flow
2
-
3
- import moment from "moment";
4
- import { toTitle } from "./strings";
5
-
6
- const
7
- now = new Date(),
8
- currentMonth = now.getMonth(),
9
- currentYear = now.getFullYear();
10
-
11
- export const calendar = {
12
- month : currentMonth,
13
- year : currentYear,
14
-
15
- currentMonth: {
16
- firstDay: new Date(Date.UTC(currentYear,
17
- currentMonth,
18
- 1)).toISOString(),
19
- lastDay: new Date(Date.UTC(currentYear,
20
- currentMonth + 1,
21
- 0)).toISOString(),
22
- },
23
- };
24
-
25
- export const newDate = (year : any, month: any, day? : any = 1) => (
26
- new Date(Date.UTC(Number(year),
27
- Number(month),
28
- day))
29
- );
30
-
31
- export const monthYearToDate = (data : { Year : string, Month : string }) => ({
32
- ...data,
33
- Date: newDate(data.Year,
34
- data.Month),
35
- });
36
-
37
- export const getMonthName = (data : Date) => (
38
- toTitle(moment.months(data.getMonth()))
39
- );
@@ -1,100 +0,0 @@
1
- // @flow
2
- /* eslint-disable */
3
-
4
- type MonthAndYear = { year: string, month: string };
5
-
6
- import { isValidDate } from "./validation/validate";
7
-
8
- const ten = 10;
9
-
10
- export const getPreviousMonth = (year : string, month: string) => {
11
- if (month === "0") {
12
- return {
13
- previousMonth : "11",
14
- previousYear : String(Number(year) - 1),
15
- };
16
- }
17
-
18
- return {
19
- previousMonth : String(Number(month) - 1),
20
- previousYear : String(year),
21
- };
22
- };
23
-
24
- export const getLastMonthAndYear = () : MonthAndYear => {
25
- const
26
- currentDate = new Date(),
27
- currentYear = String(currentDate.getFullYear()),
28
- currentMonth = String(currentDate.getMonth()),
29
- { previousMonth, previousYear } = getPreviousMonth(currentYear, currentMonth);
30
-
31
- return {
32
- month: previousMonth,
33
- year: previousYear,
34
- };
35
- };
36
-
37
- // new Date("2016-08-25T00:00:00Z") ---> 25.08.2016
38
- export const formatDateObject = (date : Date) : string => {
39
-
40
- const dd = date.getDate(),
41
- mm = date.getMonth() + 1,
42
- yyyy = date.getFullYear(),
43
- addZero = (value) => {
44
- if (value < ten) {
45
- return `0${value}`;
46
- }
47
-
48
- return value;
49
- },
50
- newDD = addZero(dd),
51
- newMM = addZero(mm);
52
-
53
- return `${newDD}.${newMM}.${yyyy}`;
54
- };
55
-
56
- // "2016-08-25T00:00:00Z" ---> 25.08.2016
57
- export const formatDate = (normalizedValue : string) : string => {
58
-
59
- const parts = normalizedValue.split("T");
60
-
61
- if (parts.length !== 2) {
62
- return normalizedValue;
63
- }
64
-
65
- const dateParts = parts[0].split("-"),
66
- nrOfParts = 3;
67
-
68
- if (dateParts.length !== nrOfParts) {
69
- return normalizedValue;
70
- }
71
-
72
- const [yyyy, mm, dd] = dateParts;
73
-
74
- if (!isValidDate(`${dd}.${mm}.${yyyy}`)) {
75
- return normalizedValue;
76
- }
77
-
78
- const date = new Date(Number(yyyy), Number(mm) - 1, Number(dd), 0, 0, 0, 0);
79
-
80
- return formatDateObject(date);
81
- };
82
-
83
- // 25.08.2016 ---> 2016-08-25T00:00:00Z
84
- export const normalizeDate = (currentValue : string) : string => {
85
-
86
- const normalizeCurrent = () : string => {
87
- const parts = currentValue.split("."),
88
- dd = parts[0],
89
- mm = parts[1],
90
- yyyy = parts[2];
91
-
92
- return `${yyyy}-${mm}-${dd}T00:00:00Z`;
93
- };
94
-
95
- if (isValidDate(currentValue)) {
96
- return normalizeCurrent();
97
- }
98
-
99
- return currentValue;
100
- };
@@ -1,12 +0,0 @@
1
- // @flow
2
-
3
- export * from "./calendar";
4
- export * from "./date";
5
- export * from "./language";
6
- export * from "./normalize";
7
- export * from "./numbers";
8
- export * from "./numeric";
9
- export * from "./others";
10
- export * from "./strings";
11
- export * from "./mql";
12
- export * from "./validation";
@@ -1,17 +0,0 @@
1
- // @flow
2
-
3
- export const language = {
4
- message: {
5
- failPerform : "Nu am putut îndeplini sarcina",
6
- confirmDelete : "Am șters cu succes",
7
- confirmAdd : "Am adăugat cu succes",
8
- confirmUpdate : "Am actualizat datele",
9
- },
10
- label: {
11
- modify : "Modifică",
12
- add : "Adaugă",
13
- remove : "Șterge",
14
- confirmation : "Confirmare",
15
- cancel : "Renunță",
16
- },
17
- };
@@ -1,3 +0,0 @@
1
- // @flow
2
-
3
- export const mql : any = window ? window.matchMedia("(min-width: 800px)") : null;
@@ -1,58 +0,0 @@
1
-
2
- import { normalizeArray } from "./normalize";
3
-
4
- import * as Immutable from "immutable";
5
- import * as matchers from "jest-immutable-matchers";
6
-
7
- describe("test util/normalize",
8
- () => {
9
- beforeEach(() => {
10
- jest.addMatchers(matchers);
11
- });
12
-
13
- const input = [
14
- {
15
- ID : 1,
16
- Name : "BlaBla 1",
17
- },
18
- {
19
- ID : 2,
20
- Name : "BlaBla 2",
21
- },
22
- {
23
- ID : 3,
24
- Name : "BlaBla 3",
25
- },
26
- ];
27
-
28
- describe("given an array",
29
- () => {
30
- const result = normalizeArray(input);
31
-
32
- it("normalizes the entities",
33
- () => {
34
- expect(result.entities).toEqualImmutable(Immutable.Map({
35
- "1": Immutable.Map({
36
- ID : 1,
37
- Name : "BlaBla 1",
38
- }),
39
- "2": Immutable.Map({
40
- ID : 2,
41
- Name : "BlaBla 2",
42
- }),
43
- "3": Immutable.Map({
44
- ID : 3,
45
- Name : "BlaBla 3",
46
- }),
47
- }));
48
- });
49
- it("normalizes the result",
50
- () => {
51
- expect(result.result).toEqualImmutable(Immutable.List([
52
- "1",
53
- "2",
54
- "3",
55
- ]));
56
- });
57
- });
58
- });
@@ -1,119 +0,0 @@
1
- /* eslint-disable max-len, no-duplicate-imports */
2
- // @flow
3
-
4
- import type { NormalizedResult } from "src\\types";
5
-
6
- type Normalizr = (item : any) => any;
7
-
8
- type NormalizeBoolean = (input : "" | bool) => bool;
9
- type NormalizeArray = (raw : Array<any>) => NormalizedResult;
10
- type Normalize = (raw : Array<any>, field : string, normalizr : Normalizr) => NormalizedResult;
11
- type DefaultNormalize = (raw : Array<any>, field : string) => NormalizedResult;
12
-
13
- type Resolve = (data : any) => void;
14
- type Reject = (arg : any) => void;
15
-
16
- type Response = {
17
- body: any;
18
- };
19
-
20
- type Error = {
21
- status: any;
22
- }
23
-
24
- import * as Immutable from "immutable";
25
-
26
- const timeout = 500;
27
-
28
- const defaultNormalizr : Normalizr = (item) => Immutable.Map(item);
29
-
30
- const defaultValue = () => ({
31
- entities : Immutable.Map(),
32
- result : Immutable.List(),
33
- });
34
-
35
- export const customNormalizeArrayByField : Normalize = (raw : Array<any>, field : string, normalizr : Normalizr) => (
36
- raw === null ? defaultValue() : (
37
- raw.reduce((previous, current) => {
38
- const stringID = String(current[field]);
39
-
40
- previous.entities = previous.entities.set(stringID,
41
- normalizr(current));
42
-
43
- previous.result = previous.result.push(stringID);
44
-
45
- return previous;
46
- }, defaultValue())
47
- )
48
- );
49
-
50
- export const normalizeArrayByField : DefaultNormalize = (raw : Array<any>, field : string) => (
51
- customNormalizeArrayByField(raw,
52
- field,
53
- defaultNormalizr)
54
- );
55
-
56
- export const withPromiseCallback = (resolve : Resolve, reject : Reject) => (error : Error, response : Response) => {
57
- if (error) {
58
- const StatusUnauthorized = 401;
59
-
60
- if (error.status === StatusUnauthorized) {
61
- document.location.href = "/";
62
- } else {
63
- // error.message
64
- reject({ error: "Ceva nu a funcționat cum trebuia" });
65
- }
66
- } else {
67
- resolve(response.body);
68
- }
69
- };
70
-
71
- export const withHandlePDFCallback = (
72
- { resolve, reject, title } : { resolve : Resolve, reject : Reject, title : string },
73
- ) => (error : Error, response : Response) => {
74
- // It is necessary to create a new blob object with mime-type explicitly set
75
- // otherwise only Chrome works like it should
76
- const newBlob = new Blob([response.body],
77
- { type: "application/pdf" });
78
-
79
- // IE doesn't allow using a blob object directly as link href
80
- // instead it is necessary to use msSaveOrOpenBlob
81
- if (window.navigator && window.navigator.msSaveOrOpenBlob) {
82
- window.navigator.msSaveOrOpenBlob(newBlob);
83
- return;
84
- }
85
-
86
- // For other browsers:
87
- // Create a link pointing to the ObjectURL containing the blob.
88
- const data = window.URL.createObjectURL(newBlob);
89
- const link = document.createElement("a");
90
-
91
- link.href = data;
92
- link.download = `${title}.pdf`;
93
- link.click();
94
- setTimeout(() => {
95
- // For Firefox it is necessary to delay revoking the ObjectURL
96
- window.URL.revokeObjectURL(data);
97
- withPromiseCallback(resolve,
98
- reject)(error,
99
- response);
100
- }, timeout);
101
- };
102
-
103
- /*
104
- * entities ---> Object { "1": Immutable.Map(), ... ]) }
105
- * result ---> List([ "1", "2", "3" ])
106
- */
107
-
108
- export const normalizeArray : NormalizeArray = (raw : Array<any>, normalizr?: Normalizr) => (
109
- customNormalizeArrayByField(raw,
110
- "ID",
111
- typeof normalizr === "undefined" ? defaultNormalizr : normalizr)
112
- );
113
-
114
- export const normalizeBoolean : NormalizeBoolean = (value : boolean | "") => value || false;
115
-
116
- export const normalizeSelectNumeric = (raw : string) => (
117
- (typeof raw === "string" && raw !== "") ? parseInt(raw,
118
- 10) : raw
119
- );