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.
- package/Account/Load.js +75 -0
- package/Account/actions.js +15 -0
- package/Account/index.js +20 -0
- package/Account/reducer.js +122 -0
- package/Account/request.js +44 -0
- package/Async/InitModule.js +190 -0
- package/Async/RouteLoading.js +64 -0
- package/Async/SimulatedException.js +44 -0
- package/Async/index.js +95 -0
- package/Async/types.js +1 -0
- package/Company/Load.js +82 -0
- package/Company/actions.js +15 -0
- package/Company/index.js +20 -0
- package/Company/reducer.js +165 -0
- package/Company/request.js +36 -0
- package/Company/util.js +10 -0
- package/Header/AccountOptionsContainer.js +144 -0
- package/Header/AdminSelectCompany.js +109 -0
- package/Header/ClientSelectCompany.js +104 -0
- package/Header/Header.js +127 -0
- package/Header/HeaderContainer.js +39 -0
- package/Header/Logo.js +30 -0
- package/Header/LogoutButton.js +39 -0
- package/Header/index.js +19 -0
- package/Header/request.js +26 -0
- package/Header/types.js +1 -0
- package/Header/util.js +58 -0
- package/Inputs/Business/BankAccount.js +48 -0
- package/Inputs/Business/BankName.js +49 -0
- package/Inputs/Business/CifField.js +112 -0
- package/Inputs/Business/CifFieldContainer.js +157 -0
- package/Inputs/Business/Email.js +37 -0
- package/Inputs/Business/NidField.js +91 -0
- package/Inputs/Business/Phone.js +37 -0
- package/Inputs/Business/index.js +34 -0
- package/Inputs/Business/request.js +39 -0
- package/Inputs/CaptchaBox.js +151 -0
- package/Inputs/DateInput.js +172 -0
- package/Inputs/DateTemplate.js +200 -0
- package/Inputs/DelayInputChange.js +135 -0
- package/Inputs/FocusTemplate.js +47 -0
- package/Inputs/InputTemplate.js +78 -0
- package/Inputs/LabelTemplate.js +59 -0
- package/Inputs/NumericInput.js +139 -0
- package/Inputs/NumericTemplate.js +148 -0
- package/Inputs/Selects/County.js +29 -0
- package/Inputs/Selects/Custom.js +56 -0
- package/Inputs/Selects/Simple.js +75 -0
- package/Inputs/Selects/index.js +52 -0
- package/Inputs/SimpleInput.js +42 -0
- package/Inputs/SimpleTextarea.js +47 -0
- package/Inputs/TextareaTemplate.js +55 -0
- package/Inputs/Tooltip.js +82 -0
- package/Inputs/index.js +185 -0
- package/Messages/Error.js +106 -0
- package/Messages/Loading.js +68 -0
- package/Messages/index.js +29 -0
- package/Modal/Delete.js +240 -0
- package/Modal/Root.js +81 -0
- package/Modal/SimpleModal.js +57 -0
- package/Modal/actions.js +10 -0
- package/Modal/getComponent.js +42 -0
- package/Modal/index.js +22 -0
- package/Modal/reducer.js +53 -0
- package/Modal/types.js +7 -0
- package/Modal/util.js +17 -0
- package/Payment/EstimatePrice/Description.js +92 -0
- package/Payment/EstimatePrice/PayBox.js +220 -0
- package/Payment/EstimatePrice/index.js +92 -0
- package/Payment/EstimatePrice/util.js +21 -0
- package/Payment/MobilpayForm.js +86 -0
- package/Payment/Modal/BankTransfer.js +233 -0
- package/Payment/Modal/CompanyValability.js +28 -0
- package/Payment/Modal/DoneForm.js +222 -0
- package/Payment/Modal/PaymentDone.js +53 -0
- package/Payment/Modal/index.js +27 -0
- package/Payment/actions.js +23 -0
- package/{src/Payment → Payment}/codes.js +19 -16
- package/Payment/index.js +141 -0
- package/Payment/request.js +49 -0
- package/Payment/types.js +1 -0
- package/Payment/util.js +50 -0
- package/Payment/validate.js +23 -0
- package/Sidebar.js +156 -0
- package/Things.js +53 -0
- package/actions.js +73 -0
- package/config.js +10 -0
- package/dev/ErrorBoundary.js +109 -0
- package/dev/TheError.js +113 -0
- package/dev/index.js +132 -0
- package/dev/types.js +1 -0
- package/package.json +13 -13
- package/prod/SentryErrorBoundary.js +150 -0
- package/reducer/captchas.js +51 -0
- package/reducer/counties.js +57 -0
- package/reducer/index.js +38 -0
- package/reducer/module.js +48 -0
- package/style/index.css +1 -0
- package/style/sidebar.css +1 -0
- package/types.js +1 -0
- package/utility/calendar.js +45 -0
- package/utility/date.js +111 -0
- package/utility/index.js +125 -0
- package/utility/language.js +20 -0
- package/utility/mql.js +6 -0
- package/utility/normalize-test.js +54 -0
- package/utility/normalize.js +108 -0
- package/utility/numbers.js +93 -0
- package/utility/numeric.js +103 -0
- package/utility/others.js +142 -0
- package/utility/strings-test.js +216 -0
- package/utility/strings.js +85 -0
- package/utility/validation/common.js +278 -0
- package/utility/validation/index.js +110 -0
- package/utility/validation/specific.js +14 -0
- package/utility/validation/validate/bank-test.js +41 -0
- package/utility/validation/validate/bank.js +176 -0
- package/utility/validation/validate/cif-test.js +37 -0
- package/utility/validation/validate/cif.js +44 -0
- package/utility/validation/validate/cnp-test.js +68 -0
- package/utility/validation/validate/cnp.js +193 -0
- package/{src/utility → utility}/validation/validate/date.js +61 -73
- package/utility/validation/validate/email-test.js +30 -0
- package/utility/validation/validate/email.js +11 -0
- package/utility/validation/validate/index.js +65 -0
- package/.eslintignore +0 -2
- package/.eslintrc.json +0 -275
- package/.flowconfig +0 -23
- package/conf/dev.js +0 -19
- package/conf/dist.js +0 -19
- package/conf/polyfills/tempPolyfills.js +0 -7
- package/src/Account/Load.jsx +0 -79
- package/src/Account/actions.js +0 -10
- package/src/Account/index.js +0 -11
- package/src/Account/reducer.js +0 -139
- package/src/Account/request.js +0 -36
- package/src/Async/InitModule.jsx +0 -114
- package/src/Async/RouteLoading.jsx +0 -52
- package/src/Async/SimulatedException.jsx +0 -19
- package/src/Async/index.jsx +0 -75
- package/src/Async/types.js +0 -39
- package/src/Company/Load.jsx +0 -84
- package/src/Company/actions.js +0 -10
- package/src/Company/index.js +0 -11
- package/src/Company/reducer.js +0 -201
- package/src/Company/request.js +0 -30
- package/src/Company/util.js +0 -7
- package/src/Header/AccountOptionsContainer.jsx +0 -124
- package/src/Header/AdminSelectCompany.jsx +0 -101
- package/src/Header/ClientSelectCompany.jsx +0 -90
- package/src/Header/Header.jsx +0 -120
- package/src/Header/HeaderContainer.jsx +0 -30
- package/src/Header/Logo.jsx +0 -16
- package/src/Header/LogoutButton.jsx +0 -34
- package/src/Header/index.jsx +0 -9
- package/src/Header/request.js +0 -28
- package/src/Header/types.js +0 -6
- package/src/Header/util.jsx +0 -61
- package/src/Inputs/Business/BankAccount.jsx +0 -39
- package/src/Inputs/Business/BankName.jsx +0 -40
- package/src/Inputs/Business/CifField.jsx +0 -93
- package/src/Inputs/Business/CifFieldContainer.jsx +0 -142
- package/src/Inputs/Business/Email.jsx +0 -23
- package/src/Inputs/Business/NidField.jsx +0 -77
- package/src/Inputs/Business/Phone.jsx +0 -23
- package/src/Inputs/Business/index.js +0 -16
- package/src/Inputs/Business/request.js +0 -39
- package/src/Inputs/CaptchaBox.jsx +0 -131
- package/src/Inputs/DateInput.jsx +0 -188
- package/src/Inputs/DateTemplate.jsx +0 -213
- package/src/Inputs/DelayInputChange.jsx +0 -130
- package/src/Inputs/FocusTemplate.jsx +0 -41
- package/src/Inputs/InputTemplate.jsx +0 -79
- package/src/Inputs/LabelTemplate.jsx +0 -47
- package/src/Inputs/NumericInput.jsx +0 -142
- package/src/Inputs/NumericTemplate.jsx +0 -155
- package/src/Inputs/Selects/County.jsx +0 -19
- package/src/Inputs/Selects/Custom.jsx +0 -55
- package/src/Inputs/Selects/Simple.jsx +0 -73
- package/src/Inputs/Selects/index.jsx +0 -37
- package/src/Inputs/SimpleInput.jsx +0 -40
- package/src/Inputs/SimpleTextarea.jsx +0 -55
- package/src/Inputs/TextareaTemplate.jsx +0 -57
- package/src/Inputs/Tooltip.jsx +0 -61
- package/src/Inputs/index.js +0 -22
- package/src/Messages/Error.jsx +0 -83
- package/src/Messages/Loading.jsx +0 -43
- package/src/Messages/index.jsx +0 -4
- package/src/Modal/Delete.jsx +0 -237
- package/src/Modal/Root.jsx +0 -57
- package/src/Modal/SimpleModal.jsx +0 -47
- package/src/Modal/actions.js +0 -7
- package/src/Modal/getComponent.jsx +0 -32
- package/src/Modal/index.jsx +0 -12
- package/src/Modal/reducer.js +0 -40
- package/src/Modal/types.js +0 -6
- package/src/Modal/util.js +0 -15
- package/src/Payment/EstimatePrice/Description.jsx +0 -101
- package/src/Payment/EstimatePrice/PayBox.jsx +0 -173
- package/src/Payment/EstimatePrice/index.jsx +0 -63
- package/src/Payment/EstimatePrice/util.js +0 -15
- package/src/Payment/MobilpayForm.jsx +0 -77
- package/src/Payment/Modal/BankTransfer.jsx +0 -129
- package/src/Payment/Modal/CompanyValability.jsx +0 -14
- package/src/Payment/Modal/DoneForm.jsx +0 -209
- package/src/Payment/Modal/PaymentDone.jsx +0 -27
- package/src/Payment/Modal/index.js +0 -13
- package/src/Payment/actions.jsx +0 -22
- package/src/Payment/index.jsx +0 -124
- package/src/Payment/request.js +0 -50
- package/src/Payment/types.js +0 -14
- package/src/Payment/util.jsx +0 -52
- package/src/Payment/validate.js +0 -25
- package/src/Sidebar.jsx +0 -158
- package/src/Things.jsx +0 -35
- package/src/actions.js +0 -36
- package/src/config.js +0 -7
- package/src/dev/ErrorBoundary.jsx +0 -98
- package/src/dev/TheError.jsx +0 -87
- package/src/dev/index.js +0 -127
- package/src/dev/types.js +0 -10
- package/src/prod/SentryErrorBoundary.jsx +0 -98
- package/src/reducer/captchas.js +0 -44
- package/src/reducer/counties.js +0 -46
- package/src/reducer/index.js +0 -25
- package/src/reducer/module.jsx +0 -43
- package/src/style/.sass-lint.yml +0 -84
- package/src/style/.stylelintrc.json +0 -161
- package/src/style/_fancy-text.scss +0 -37
- package/src/style/_fix_bootstrap_placeholder_color.scss +0 -14
- package/src/style/_header-company.scss +0 -69
- package/src/style/_inputs.scss +0 -12
- package/src/style/_minimal.scss +0 -31
- package/src/style/_navigation.scss +0 -24
- package/src/style/_others.scss +0 -79
- package/src/style/index.scss +0 -7
- package/src/style/sidebar/_animations.scss +0 -21
- package/src/style/sidebar/_dark-theme.scss +0 -77
- package/src/style/sidebar/_scroll.scss +0 -37
- package/src/style/sidebar/_structure.scss +0 -299
- package/src/style/sidebar.scss +0 -4
- package/src/types.js +0 -31
- package/src/utility/calendar.js +0 -39
- package/src/utility/date.js +0 -100
- package/src/utility/index.js +0 -12
- package/src/utility/language.js +0 -17
- package/src/utility/mql.js +0 -3
- package/src/utility/normalize-test.js +0 -58
- package/src/utility/normalize.js +0 -119
- package/src/utility/numbers.js +0 -87
- package/src/utility/numeric.js +0 -114
- package/src/utility/others.jsx +0 -160
- package/src/utility/strings-test.js +0 -136
- package/src/utility/strings.js +0 -80
- package/src/utility/validation/common.js +0 -360
- package/src/utility/validation/index.js +0 -70
- package/src/utility/validation/specific.js +0 -9
- package/src/utility/validation/validate/bank-test.js +0 -129
- package/src/utility/validation/validate/bank.js +0 -176
- package/src/utility/validation/validate/cif-test.js +0 -105
- package/src/utility/validation/validate/cif.js +0 -44
- package/src/utility/validation/validate/cnp-test.js +0 -216
- package/src/utility/validation/validate/cnp.js +0 -261
- package/src/utility/validation/validate/email-test.js +0 -36
- package/src/utility/validation/validate/email.js +0 -6
- package/src/utility/validation/validate/index.js +0 -7
- package/webpack.config.js +0 -90
- package/x25.wiki/Account.md +0 -41
- package/x25.wiki/Company.md +0 -39
- package/x25.wiki/Header.md +0 -21
- package/x25.wiki/Home.md +0 -1
- package/x25.wiki/Inputs.md +0 -33
- package/x25.wiki/Messages.md +0 -27
- package/x25.wiki/Payment.md +0 -42
package/src/utility/numbers.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
/* eslint-disable no-magic-numbers */
|
|
3
|
-
|
|
4
|
-
declare var Intl:any
|
|
5
|
-
|
|
6
|
-
const numberFormat : any = new Intl.NumberFormat("ro",
|
|
7
|
-
{
|
|
8
|
-
minimumFractionDigits: 2,
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
const plainNumberFormat : any = new Intl.NumberFormat("ro");
|
|
12
|
-
|
|
13
|
-
const replaceCharInString = ({ word, oldChar, newChar } : {
|
|
14
|
-
word: string,
|
|
15
|
-
oldChar: string,
|
|
16
|
-
newChar: string
|
|
17
|
-
}) : string => {
|
|
18
|
-
|
|
19
|
-
const regex = new RegExp(oldChar,
|
|
20
|
-
"gu");
|
|
21
|
-
|
|
22
|
-
return word.replace(regex,
|
|
23
|
-
newChar);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
// 127.99 ----> 127,99
|
|
27
|
-
// 0 ----> ""
|
|
28
|
-
export const formatZeroValue = (word : any, optional?: bool) : string => (
|
|
29
|
-
optional && word === ""
|
|
30
|
-
) ? "" : replaceCharInString({
|
|
31
|
-
word : String(word),
|
|
32
|
-
oldChar : "\\.",
|
|
33
|
-
newChar : ",",
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
export const formatNumber = (word : any) : string => replaceCharInString({
|
|
37
|
-
word : String(word),
|
|
38
|
-
oldChar : "\\.",
|
|
39
|
-
newChar : ",",
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
// 78,45 ---> 78.45
|
|
43
|
-
export const normalizeNumber = (word : any) : string => replaceCharInString({
|
|
44
|
-
word : String(word),
|
|
45
|
-
oldChar : ",",
|
|
46
|
-
newChar : ".",
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
export const numberToLocale = (value : number) : string => numberFormat.format(value);
|
|
50
|
-
|
|
51
|
-
export const plainNumberToLocale = (value : number) : string => (
|
|
52
|
-
plainNumberFormat.format(value)
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
export const numberToLocaleForm = (value : number) : string => {
|
|
56
|
-
const upperLimit = 20,
|
|
57
|
-
formatted = plainNumberFormat.format(value);
|
|
58
|
-
|
|
59
|
-
if (value < upperLimit) {
|
|
60
|
-
return formatted;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return `${formatted} de`;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
export const numericBehavior = {
|
|
67
|
-
normalize : normalizeNumber,
|
|
68
|
-
format : formatNumber,
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export const tryToParseNumber = (raw : string) => {
|
|
72
|
-
const result = Number(raw);
|
|
73
|
-
|
|
74
|
-
if (!isNaN(result) && raw !== "") {
|
|
75
|
-
return result;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return raw;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export const numberToLocaleHideBlank = (raw : any) => (
|
|
82
|
-
(typeof raw === "number" && raw !== 0) ? numberToLocale(raw) : ""
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
export const plainNumberToLocaleHideZero = (raw : any) => (
|
|
86
|
-
(typeof raw === "number" && raw !== 0) ? plainNumberToLocale(raw) : ""
|
|
87
|
-
);
|
package/src/utility/numeric.js
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
type This = any;
|
|
4
|
-
|
|
5
|
-
import { normalizeNumber } from "./numbers";
|
|
6
|
-
|
|
7
|
-
export const handleBlur = (that : This) => {
|
|
8
|
-
const { state, props } = that;
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
{ input, normalizeValue, optional } = props,
|
|
12
|
-
{ onBlur } = input,
|
|
13
|
-
{ value: currentValue } = state;
|
|
14
|
-
|
|
15
|
-
const performBlur = (value : number | null, shouldRenderAgain : bool) => {
|
|
16
|
-
|
|
17
|
-
input.onChange(value);
|
|
18
|
-
|
|
19
|
-
/*
|
|
20
|
-
* Swallow the event to prevent Redux Form from
|
|
21
|
-
* extracting the form value
|
|
22
|
-
*/
|
|
23
|
-
onBlur();
|
|
24
|
-
|
|
25
|
-
if (shouldRenderAgain) {
|
|
26
|
-
const setState = that.setState.bind(that);
|
|
27
|
-
|
|
28
|
-
return setState({
|
|
29
|
-
value,
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return null;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const shouldNotChange = currentValue === "" && optional;
|
|
37
|
-
|
|
38
|
-
if (shouldNotChange) {
|
|
39
|
-
if (input.value === "") {
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return performBlur(null,
|
|
44
|
-
true);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
normalizedValue = normalizeValue(currentValue),
|
|
49
|
-
shouldRenderAgain = (
|
|
50
|
-
(!isNaN(normalizedValue)) &&
|
|
51
|
-
(currentValue !== normalizedValue)
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
return performBlur(normalizedValue,
|
|
55
|
-
shouldRenderAgain);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export const normalizeFloat = (raw : string) : number => {
|
|
59
|
-
|
|
60
|
-
/* eslint-disable no-magic-numbers */
|
|
61
|
-
|
|
62
|
-
const value = normalizeNumber(raw),
|
|
63
|
-
shouldNotNormalize = (
|
|
64
|
-
(value.trim() === "") ||
|
|
65
|
-
isNaN(Number(value))
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
if (shouldNotNormalize) {
|
|
69
|
-
return NaN;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const result = Number(value),
|
|
73
|
-
truncateTo = (unRouned : number, nrOfDecimals? : number = 2) : number => {
|
|
74
|
-
const parts = String(unRouned).split(".");
|
|
75
|
-
|
|
76
|
-
if (parts.length !== 2) {
|
|
77
|
-
// ex. 12
|
|
78
|
-
return unRouned;
|
|
79
|
-
}
|
|
80
|
-
const newDecimals = parts[1].slice(0,
|
|
81
|
-
nrOfDecimals),
|
|
82
|
-
newString = `${parts[0]}.${newDecimals}`;
|
|
83
|
-
|
|
84
|
-
return Number(newString);
|
|
85
|
-
},
|
|
86
|
-
normalized = truncateTo(result);
|
|
87
|
-
|
|
88
|
-
return normalized;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
export const cwrp = (that : This, nextany : any) => {
|
|
92
|
-
const { state } = that;
|
|
93
|
-
|
|
94
|
-
const {
|
|
95
|
-
input: {
|
|
96
|
-
value: newValue,
|
|
97
|
-
},
|
|
98
|
-
} = nextany;
|
|
99
|
-
|
|
100
|
-
const { value: currentValue } = state;
|
|
101
|
-
|
|
102
|
-
const shouldRenderAgain = (
|
|
103
|
-
!isNaN(newValue) &&
|
|
104
|
-
(currentValue !== newValue)
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
const setState = that.setState.bind(that);
|
|
108
|
-
|
|
109
|
-
if (shouldRenderAgain) {
|
|
110
|
-
setState({
|
|
111
|
-
value: newValue,
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
};
|
package/src/utility/others.jsx
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import type { List as ImmutableList, Map as ImmutableMap } from "immutable";
|
|
4
|
-
|
|
5
|
-
type ReduxError = {
|
|
6
|
-
error: any;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
import React from "react";
|
|
10
|
-
import { SubmissionError } from "redux-form/immutable";
|
|
11
|
-
|
|
12
|
-
export const getDateSortNumber = (item : string) => (
|
|
13
|
-
Number(new Date(item).getTime())
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
export const isAdministratorAccount = (current : number) => (
|
|
17
|
-
current === 0
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
export const createModal = (modalType : string, modalProps? : any) => ({
|
|
21
|
-
type : "SHOW_MODAL",
|
|
22
|
-
payload : {
|
|
23
|
-
modalType,
|
|
24
|
-
modalProps,
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
export const
|
|
29
|
-
noError = "",
|
|
30
|
-
rowsPerLoad = 50,
|
|
31
|
-
nothingFetched = -1;
|
|
32
|
-
|
|
33
|
-
export const removeID = (payload : ImmutableMap<string, any>) => (list : ImmutableList<string>) => (
|
|
34
|
-
// $FlowFixMe
|
|
35
|
-
list.delete(list.findIndex((current : string) => current === String(payload.get("ID"))))
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
export const addID = (payload : ImmutableMap<string, any>) => (list : ImmutableList<string>) => (
|
|
39
|
-
list.push(String(payload.get("ID")))
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
export const ReduxFormSubmissionError = (error? : ReduxError) => {
|
|
43
|
-
if (error) {
|
|
44
|
-
if (error instanceof SubmissionError) {
|
|
45
|
-
throw error;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const _error = typeof error.error === "string" ? error.error : "Am pierdut conexiunea cu server-ul";
|
|
49
|
-
|
|
50
|
-
throw new SubmissionError({
|
|
51
|
-
_error,
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export const delay = () => (
|
|
57
|
-
new Promise((resolve) => {
|
|
58
|
-
setTimeout(resolve);
|
|
59
|
-
}) : Promise<any>
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
export const showCheck = (value : boolean) => (
|
|
63
|
-
value ? (
|
|
64
|
-
<i className="fa fa-check text-success" />
|
|
65
|
-
) : null
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
export const userHasPressedCKeyAlone = (currentEvent : KeyboardEvent) : boolean => {
|
|
69
|
-
const {
|
|
70
|
-
ctrlKey,
|
|
71
|
-
keyCode,
|
|
72
|
-
srcElement: {
|
|
73
|
-
localName,
|
|
74
|
-
},
|
|
75
|
-
} = currentEvent;
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
createInvoiceKey = 67,
|
|
79
|
-
tag = localName.toLowerCase(),
|
|
80
|
-
isNotInputOrTextarea = (
|
|
81
|
-
tag !== "input" &&
|
|
82
|
-
tag !== "textarea"
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
return (
|
|
86
|
-
!ctrlKey &&
|
|
87
|
-
keyCode === createInvoiceKey &&
|
|
88
|
-
isNotInputOrTextarea
|
|
89
|
-
);
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export const years = [
|
|
93
|
-
{
|
|
94
|
-
value : 2018,
|
|
95
|
-
name : "2018",
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
value : 2019,
|
|
99
|
-
name : "2019",
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
value : 2020,
|
|
103
|
-
name : "2020",
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
value : 2021,
|
|
107
|
-
name : "2021",
|
|
108
|
-
},
|
|
109
|
-
];
|
|
110
|
-
|
|
111
|
-
export const months = [
|
|
112
|
-
{
|
|
113
|
-
value : 0,
|
|
114
|
-
name : "Ianuarie",
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
value : 1,
|
|
118
|
-
name : "Februarie",
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
value : 2,
|
|
122
|
-
name : "Martie",
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
value : 3,
|
|
126
|
-
name : "Aprilie",
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
value : 4,
|
|
130
|
-
name : "Mai",
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
value : 5,
|
|
134
|
-
name : "Iunie",
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
value : 6,
|
|
138
|
-
name : "Iulie",
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
value : 7,
|
|
142
|
-
name : "August",
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
value : 8,
|
|
146
|
-
name : "Septembrie",
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
value : 9,
|
|
150
|
-
name : "Octombrie",
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
value : 10,
|
|
154
|
-
name : "Noiembrie",
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
value : 11,
|
|
158
|
-
name : "Decembrie",
|
|
159
|
-
},
|
|
160
|
-
];
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
firstToUppercase,
|
|
3
|
-
toLower,
|
|
4
|
-
toTitle,
|
|
5
|
-
toUpper,
|
|
6
|
-
} from "./strings";
|
|
7
|
-
|
|
8
|
-
// toTitle
|
|
9
|
-
(() => {
|
|
10
|
-
describe("Test toTitle",
|
|
11
|
-
() => {
|
|
12
|
-
const tests = [
|
|
13
|
-
{
|
|
14
|
-
input : "",
|
|
15
|
-
output : "",
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
input : "cosovei",
|
|
19
|
-
output : "Cosovei",
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
input : "simona cosovei",
|
|
23
|
-
output : "Simona Cosovei",
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
input : "ștefănică țepeș",
|
|
27
|
-
output : "Ștefănică Țepeș",
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
input : "this is 4 long name 5",
|
|
31
|
-
output : "This Is 4 Long Name 5",
|
|
32
|
-
},
|
|
33
|
-
];
|
|
34
|
-
|
|
35
|
-
for (const { input, output } of tests) {
|
|
36
|
-
describe(`Given the raw string "${input}"`,
|
|
37
|
-
() => {
|
|
38
|
-
it(`should be transformed to "${output}"`,
|
|
39
|
-
() => {
|
|
40
|
-
expect(toTitle(input)).toEqual(output);
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
})();
|
|
46
|
-
|
|
47
|
-
// firstToUppercase
|
|
48
|
-
(() => {
|
|
49
|
-
describe("Test firstToUppercase",
|
|
50
|
-
() => {
|
|
51
|
-
const tests = [
|
|
52
|
-
{
|
|
53
|
-
input : "",
|
|
54
|
-
output : "",
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
input : "sima",
|
|
58
|
-
output : "Sima",
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
input : "Simona Cosovei",
|
|
62
|
-
output : "Simona Cosovei",
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
input : "this is 4 long name 5",
|
|
66
|
-
output : "This is 4 long name 5",
|
|
67
|
-
},
|
|
68
|
-
];
|
|
69
|
-
|
|
70
|
-
for (const { input, output } of tests) {
|
|
71
|
-
describe(`given "${input}"`,
|
|
72
|
-
() => {
|
|
73
|
-
it(`should be transformed to "${output}"`,
|
|
74
|
-
() => {
|
|
75
|
-
expect(firstToUppercase(input)).toEqual(output);
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
})();
|
|
81
|
-
|
|
82
|
-
// toUpper
|
|
83
|
-
(() => {
|
|
84
|
-
const tests = [
|
|
85
|
-
{
|
|
86
|
-
input : "",
|
|
87
|
-
output : "",
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
input : "sima",
|
|
91
|
-
output : "SIMA",
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
input : "this is 4 long name 5",
|
|
95
|
-
output : "THIS IS 4 LONG NAME 5",
|
|
96
|
-
},
|
|
97
|
-
];
|
|
98
|
-
|
|
99
|
-
for (const { input, output } of tests) {
|
|
100
|
-
describe(`given "${input}"`,
|
|
101
|
-
() => {
|
|
102
|
-
it(`should be transformed to "${output}"`,
|
|
103
|
-
() => {
|
|
104
|
-
expect(toUpper(input)).toEqual(output);
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
})();
|
|
109
|
-
|
|
110
|
-
// toLower
|
|
111
|
-
(() => {
|
|
112
|
-
const tests = [
|
|
113
|
-
{
|
|
114
|
-
input : "",
|
|
115
|
-
output : "",
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
input : "siMa",
|
|
119
|
-
output : "sima",
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
input : "This is 4 long Name 5",
|
|
123
|
-
output : "this is 4 long name 5",
|
|
124
|
-
},
|
|
125
|
-
];
|
|
126
|
-
|
|
127
|
-
for (const { input, output } of tests) {
|
|
128
|
-
describe(`given "${input}"`,
|
|
129
|
-
() => {
|
|
130
|
-
it(`should be transformed to "${output}"`,
|
|
131
|
-
() => {
|
|
132
|
-
expect(toLower(input)).toEqual(output);
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
})();
|
package/src/utility/strings.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @flow
|
|
3
|
-
* Simona Cosovei ---> Simona Cosovei
|
|
4
|
-
*/
|
|
5
|
-
export const toTitle = (str : string) : string => {
|
|
6
|
-
const transform = (txt : string) : string => {
|
|
7
|
-
const firstPart = txt.charAt(0).toUpperCase(),
|
|
8
|
-
secondPart = txt.substr(1).toLowerCase();
|
|
9
|
-
|
|
10
|
-
return `${firstPart}${secondPart}`;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
return str.replace(/\S+/gu,
|
|
14
|
-
transform);
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
// this is an example ---> This is an example
|
|
18
|
-
export const firstToUppercase = (str : string) : string => {
|
|
19
|
-
const firstPart = str.charAt(0).toUpperCase(),
|
|
20
|
-
secondPart = str.slice(1);
|
|
21
|
-
|
|
22
|
-
return `${firstPart}${secondPart}`;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const normalizeDiacritics = (str: string) : string => {
|
|
26
|
-
const chars = {
|
|
27
|
-
"ă" : "a",
|
|
28
|
-
"â" : "a",
|
|
29
|
-
"î" : "i",
|
|
30
|
-
"ț" : "t",
|
|
31
|
-
"ș" : "s",
|
|
32
|
-
|
|
33
|
-
"Ă" : "A",
|
|
34
|
-
"Â" : "A",
|
|
35
|
-
"Î" : "I",
|
|
36
|
-
"Ț" : "T",
|
|
37
|
-
"Ș" : "S",
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
return str.replace(/ă|â|î|ț|ș|Ă|Â|Î|Ț|Ș/gui,
|
|
41
|
-
(matched) => chars[matched]);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
// This is ---> THIS IS
|
|
45
|
-
export const toUpper = (str : string) : string => str.toUpperCase();
|
|
46
|
-
|
|
47
|
-
// This is ---> this is
|
|
48
|
-
export const toLower = (str : string) : string => str.toLowerCase();
|
|
49
|
-
|
|
50
|
-
export const formatBankAccount = (raw: string) : string => {
|
|
51
|
-
|
|
52
|
-
if (typeof raw === "undefined" || raw === "") {
|
|
53
|
-
return "";
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
let output = "";
|
|
57
|
-
|
|
58
|
-
const nrOfCharsPerGroup = 4,
|
|
59
|
-
withoutSpaces = raw.replace(/ /gu,
|
|
60
|
-
"");
|
|
61
|
-
|
|
62
|
-
for (let index = 0; index < withoutSpaces.length; index += 1) {
|
|
63
|
-
const currentChar = withoutSpaces.charAt(index);
|
|
64
|
-
|
|
65
|
-
if (output !== "" && index % nrOfCharsPerGroup === 0) {
|
|
66
|
-
output += " ";
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
output += currentChar;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return output;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export const normalizeCompanyName = (raw : string) : string => (
|
|
76
|
-
toTitle(raw).replace(/\ssrl/gui,
|
|
77
|
-
" S.R.L.").
|
|
78
|
-
replace(/\ss\.r\.l/gui,
|
|
79
|
-
" S.R.L")
|
|
80
|
-
);
|