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.
- package/.eslintignore +2 -0
- package/.eslintrc.json +275 -0
- package/.flowconfig +23 -0
- package/conf/dev.js +19 -0
- package/conf/dist.js +19 -0
- package/conf/polyfills/tempPolyfills.js +7 -0
- package/package.json +16 -16
- package/src/Account/Load.jsx +79 -0
- package/src/Account/actions.js +10 -0
- package/src/Account/index.js +11 -0
- package/src/Account/reducer.js +139 -0
- package/src/Account/request.js +36 -0
- package/src/Async/InitModule.jsx +114 -0
- package/src/Async/RouteLoading.jsx +52 -0
- package/src/Async/SimulatedException.jsx +19 -0
- package/src/Async/index.jsx +75 -0
- package/src/Async/types.js +39 -0
- package/src/Company/Load.jsx +84 -0
- package/src/Company/actions.js +10 -0
- package/src/Company/index.js +11 -0
- package/src/Company/reducer.js +201 -0
- package/src/Company/request.js +30 -0
- package/src/Company/util.js +7 -0
- package/src/Header/AccountOptionsContainer.jsx +124 -0
- package/src/Header/AdminSelectCompany.jsx +101 -0
- package/src/Header/ClientSelectCompany.jsx +90 -0
- package/src/Header/Header.jsx +120 -0
- package/src/Header/HeaderContainer.jsx +30 -0
- package/src/Header/Logo.jsx +16 -0
- package/src/Header/LogoutButton.jsx +34 -0
- package/src/Header/index.jsx +9 -0
- package/src/Header/request.js +28 -0
- package/src/Header/types.js +6 -0
- package/src/Header/util.jsx +61 -0
- package/src/Inputs/Business/BankAccount.jsx +39 -0
- package/src/Inputs/Business/BankName.jsx +40 -0
- package/src/Inputs/Business/CifField.jsx +93 -0
- package/src/Inputs/Business/CifFieldContainer.jsx +142 -0
- package/src/Inputs/Business/Email.jsx +23 -0
- package/src/Inputs/Business/NidField.jsx +77 -0
- package/src/Inputs/Business/Phone.jsx +23 -0
- package/src/Inputs/Business/index.js +16 -0
- package/src/Inputs/Business/request.js +39 -0
- package/src/Inputs/CaptchaBox.jsx +131 -0
- package/src/Inputs/DateInput.jsx +188 -0
- package/src/Inputs/DateTemplate.jsx +213 -0
- package/src/Inputs/DelayInputChange.jsx +130 -0
- package/src/Inputs/FocusTemplate.jsx +41 -0
- package/src/Inputs/InputTemplate.jsx +79 -0
- package/src/Inputs/LabelTemplate.jsx +47 -0
- package/src/Inputs/NumericInput.jsx +142 -0
- package/src/Inputs/NumericTemplate.jsx +155 -0
- package/src/Inputs/Selects/County.jsx +19 -0
- package/src/Inputs/Selects/Custom.jsx +55 -0
- package/src/Inputs/Selects/Simple.jsx +73 -0
- package/src/Inputs/Selects/index.jsx +37 -0
- package/src/Inputs/SimpleInput.jsx +40 -0
- package/src/Inputs/SimpleTextarea.jsx +55 -0
- package/src/Inputs/TextareaTemplate.jsx +57 -0
- package/src/Inputs/Tooltip.jsx +61 -0
- package/src/Inputs/index.js +22 -0
- package/src/Messages/Error.jsx +83 -0
- package/src/Messages/Loading.jsx +43 -0
- package/src/Messages/index.jsx +4 -0
- package/src/Modal/Delete.jsx +237 -0
- package/src/Modal/Root.jsx +57 -0
- package/src/Modal/SimpleModal.jsx +47 -0
- package/src/Modal/actions.js +7 -0
- package/src/Modal/getComponent.jsx +32 -0
- package/src/Modal/index.jsx +12 -0
- package/src/Modal/reducer.js +40 -0
- package/src/Modal/types.js +6 -0
- package/src/Modal/util.js +15 -0
- package/src/Payment/EstimatePrice/Description.jsx +101 -0
- package/src/Payment/EstimatePrice/PayBox.jsx +173 -0
- package/src/Payment/EstimatePrice/index.jsx +63 -0
- package/src/Payment/EstimatePrice/util.js +15 -0
- package/src/Payment/MobilpayForm.jsx +77 -0
- package/src/Payment/Modal/BankTransfer.jsx +129 -0
- package/src/Payment/Modal/CompanyValability.jsx +14 -0
- package/src/Payment/Modal/DoneForm.jsx +209 -0
- package/src/Payment/Modal/PaymentDone.jsx +27 -0
- package/src/Payment/Modal/index.js +13 -0
- package/src/Payment/actions.jsx +22 -0
- package/{Payment → src/Payment}/codes.js +16 -19
- package/src/Payment/index.jsx +124 -0
- package/src/Payment/request.js +50 -0
- package/src/Payment/types.js +14 -0
- package/src/Payment/util.jsx +52 -0
- package/src/Payment/validate.js +25 -0
- package/src/Sidebar.jsx +158 -0
- package/src/Things.jsx +35 -0
- package/src/actions.js +36 -0
- package/src/config.js +7 -0
- package/src/dev/ErrorBoundary.jsx +98 -0
- package/src/dev/TheError.jsx +87 -0
- package/src/dev/index.js +127 -0
- package/src/dev/types.js +10 -0
- package/src/prod/SentryErrorBoundary.jsx +98 -0
- package/src/reducer/captchas.js +44 -0
- package/src/reducer/counties.js +46 -0
- package/src/reducer/index.js +25 -0
- package/src/reducer/module.jsx +43 -0
- package/src/style/.sass-lint.yml +84 -0
- package/src/style/.stylelintrc.json +161 -0
- package/src/style/_fancy-text.scss +37 -0
- package/src/style/_fix_bootstrap_placeholder_color.scss +14 -0
- package/src/style/_header-company.scss +69 -0
- package/src/style/_inputs.scss +12 -0
- package/src/style/_minimal.scss +31 -0
- package/src/style/_navigation.scss +24 -0
- package/src/style/_others.scss +79 -0
- package/src/style/index.scss +7 -0
- package/src/style/sidebar/_animations.scss +21 -0
- package/src/style/sidebar/_dark-theme.scss +77 -0
- package/src/style/sidebar/_scroll.scss +37 -0
- package/src/style/sidebar/_structure.scss +299 -0
- package/src/style/sidebar.scss +4 -0
- package/src/types.js +31 -0
- package/src/utility/calendar.js +39 -0
- package/src/utility/date.js +100 -0
- package/src/utility/index.js +12 -0
- package/src/utility/language.js +17 -0
- package/src/utility/mql.js +3 -0
- package/src/utility/normalize-test.js +58 -0
- package/src/utility/normalize.js +119 -0
- package/src/utility/numbers.js +87 -0
- package/src/utility/numeric.js +114 -0
- package/src/utility/others.jsx +160 -0
- package/src/utility/strings-test.js +136 -0
- package/src/utility/strings.js +80 -0
- package/src/utility/validation/common.js +360 -0
- package/src/utility/validation/index.js +70 -0
- package/src/utility/validation/specific.js +9 -0
- package/src/utility/validation/validate/bank-test.js +129 -0
- package/src/utility/validation/validate/bank.js +176 -0
- package/src/utility/validation/validate/cif-test.js +105 -0
- package/src/utility/validation/validate/cif.js +44 -0
- package/src/utility/validation/validate/cnp-test.js +216 -0
- package/src/utility/validation/validate/cnp.js +261 -0
- package/{utility → src/utility}/validation/validate/date.js +73 -61
- package/src/utility/validation/validate/email-test.js +36 -0
- package/src/utility/validation/validate/email.js +6 -0
- package/src/utility/validation/validate/index.js +7 -0
- package/webpack.config.js +90 -0
- package/x25.wiki/Account.md +41 -0
- package/x25.wiki/Company.md +39 -0
- package/x25.wiki/Header.md +21 -0
- package/x25.wiki/Home.md +1 -0
- package/x25.wiki/Inputs.md +33 -0
- package/x25.wiki/Messages.md +27 -0
- package/x25.wiki/Payment.md +42 -0
- package/Account/Load.js +0 -75
- package/Account/actions.js +0 -15
- package/Account/index.js +0 -20
- package/Account/reducer.js +0 -122
- package/Account/request.js +0 -44
- package/Async/InitModule.js +0 -190
- package/Async/RouteLoading.js +0 -64
- package/Async/SimulatedException.js +0 -44
- package/Async/index.js +0 -95
- package/Async/types.js +0 -1
- package/Company/Load.js +0 -82
- package/Company/actions.js +0 -15
- package/Company/index.js +0 -20
- package/Company/reducer.js +0 -165
- package/Company/request.js +0 -36
- package/Company/util.js +0 -10
- package/Header/AccountOptionsContainer.js +0 -144
- package/Header/AdminSelectCompany.js +0 -109
- package/Header/ClientSelectCompany.js +0 -104
- package/Header/Header.js +0 -127
- package/Header/HeaderContainer.js +0 -39
- package/Header/Logo.js +0 -30
- package/Header/LogoutButton.js +0 -39
- package/Header/index.js +0 -19
- package/Header/request.js +0 -26
- package/Header/types.js +0 -1
- package/Header/util.js +0 -58
- package/Inputs/Business/BankAccount.js +0 -48
- package/Inputs/Business/BankName.js +0 -49
- package/Inputs/Business/CifField.js +0 -112
- package/Inputs/Business/CifFieldContainer.js +0 -157
- package/Inputs/Business/Email.js +0 -37
- package/Inputs/Business/NidField.js +0 -91
- package/Inputs/Business/Phone.js +0 -37
- package/Inputs/Business/index.js +0 -34
- package/Inputs/Business/request.js +0 -39
- package/Inputs/CaptchaBox.js +0 -151
- package/Inputs/DateInput.js +0 -172
- package/Inputs/DateTemplate.js +0 -200
- package/Inputs/DelayInputChange.js +0 -135
- package/Inputs/FocusTemplate.js +0 -47
- package/Inputs/InputTemplate.js +0 -78
- package/Inputs/LabelTemplate.js +0 -59
- package/Inputs/NumericInput.js +0 -139
- package/Inputs/NumericTemplate.js +0 -148
- package/Inputs/Selects/County.js +0 -29
- package/Inputs/Selects/Custom.js +0 -56
- package/Inputs/Selects/Simple.js +0 -75
- package/Inputs/Selects/index.js +0 -52
- package/Inputs/SimpleInput.js +0 -42
- package/Inputs/SimpleTextarea.js +0 -47
- package/Inputs/TextareaTemplate.js +0 -55
- package/Inputs/Tooltip.js +0 -82
- package/Inputs/index.js +0 -185
- package/Messages/Error.js +0 -106
- package/Messages/Loading.js +0 -68
- package/Messages/index.js +0 -29
- package/Modal/Delete.js +0 -240
- package/Modal/Root.js +0 -81
- package/Modal/SimpleModal.js +0 -57
- package/Modal/actions.js +0 -10
- package/Modal/getComponent.js +0 -42
- package/Modal/index.js +0 -22
- package/Modal/reducer.js +0 -53
- package/Modal/types.js +0 -7
- package/Modal/util.js +0 -17
- package/Payment/EstimatePrice/Description.js +0 -92
- package/Payment/EstimatePrice/PayBox.js +0 -220
- package/Payment/EstimatePrice/index.js +0 -92
- package/Payment/EstimatePrice/util.js +0 -21
- package/Payment/MobilpayForm.js +0 -86
- package/Payment/Modal/BankTransfer.js +0 -233
- package/Payment/Modal/CompanyValability.js +0 -28
- package/Payment/Modal/DoneForm.js +0 -222
- package/Payment/Modal/PaymentDone.js +0 -53
- package/Payment/Modal/index.js +0 -27
- package/Payment/actions.js +0 -23
- package/Payment/index.js +0 -141
- package/Payment/request.js +0 -49
- package/Payment/types.js +0 -1
- package/Payment/util.js +0 -50
- package/Payment/validate.js +0 -23
- package/Sidebar.js +0 -156
- package/Things.js +0 -53
- package/actions.js +0 -73
- package/config.js +0 -10
- package/dev/ErrorBoundary.js +0 -109
- package/dev/TheError.js +0 -113
- package/dev/index.js +0 -132
- package/dev/types.js +0 -1
- package/prod/SentryErrorBoundary.js +0 -150
- package/reducer/captchas.js +0 -51
- package/reducer/counties.js +0 -57
- package/reducer/index.js +0 -38
- package/reducer/module.js +0 -48
- package/style/index.css +0 -1
- package/style/sidebar.css +0 -1
- package/types.js +0 -1
- package/utility/calendar.js +0 -45
- package/utility/date.js +0 -111
- package/utility/index.js +0 -125
- package/utility/language.js +0 -20
- package/utility/mql.js +0 -6
- package/utility/normalize-test.js +0 -54
- package/utility/normalize.js +0 -108
- package/utility/numbers.js +0 -93
- package/utility/numeric.js +0 -103
- package/utility/others.js +0 -142
- package/utility/strings-test.js +0 -216
- package/utility/strings.js +0 -85
- package/utility/validation/common.js +0 -278
- package/utility/validation/index.js +0 -110
- package/utility/validation/specific.js +0 -14
- package/utility/validation/validate/bank-test.js +0 -41
- package/utility/validation/validate/bank.js +0 -176
- package/utility/validation/validate/cif-test.js +0 -37
- package/utility/validation/validate/cif.js +0 -44
- package/utility/validation/validate/cnp-test.js +0 -68
- package/utility/validation/validate/cnp.js +0 -193
- package/utility/validation/validate/email-test.js +0 -30
- package/utility/validation/validate/email.js +0 -11
- 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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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,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
|
+
```
|
package/x25.wiki/Home.md
ADDED
|
@@ -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
|
+
```
|