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/Company/reducer.js
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
/* eslint-disable global-require */
|
|
3
|
-
|
|
4
|
-
import * as Immutable from "immutable";
|
|
5
|
-
|
|
6
|
-
import type { Action, State } from "src\\types";
|
|
7
|
-
|
|
8
|
-
import { createSelector } from "reselect";
|
|
9
|
-
|
|
10
|
-
import { noError } from "../utility";
|
|
11
|
-
|
|
12
|
-
import { getIDFromURL } from "./util";
|
|
13
|
-
|
|
14
|
-
const reducerKey = "companyInfo";
|
|
15
|
-
|
|
16
|
-
type CurrentState = any;
|
|
17
|
-
|
|
18
|
-
const initialState : CurrentState = Immutable.Map({
|
|
19
|
-
error : noError,
|
|
20
|
-
fetched : false,
|
|
21
|
-
fetching : false,
|
|
22
|
-
|
|
23
|
-
company: Immutable.Map(),
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
fetchCompanyPending = () => (
|
|
28
|
-
initialState.set("fetching",
|
|
29
|
-
true)
|
|
30
|
-
),
|
|
31
|
-
fetchCompanyRejected = (state : any, { payload : { error } }) => (
|
|
32
|
-
state.merge({
|
|
33
|
-
error,
|
|
34
|
-
fetching: false,
|
|
35
|
-
})
|
|
36
|
-
),
|
|
37
|
-
fetchCompanyFulfilled = (state : any, { payload }) => (
|
|
38
|
-
state.mergeDeep({
|
|
39
|
-
fetched : true,
|
|
40
|
-
fetching : false,
|
|
41
|
-
company : payload,
|
|
42
|
-
})
|
|
43
|
-
),
|
|
44
|
-
modifyCompany = (state : any, { payload }) => (
|
|
45
|
-
state.set("company",
|
|
46
|
-
payload)
|
|
47
|
-
),
|
|
48
|
-
clearInfoIfCurrentCompany = (state : any, { payload }) => {
|
|
49
|
-
const
|
|
50
|
-
companyID = String(state.getIn([
|
|
51
|
-
"company",
|
|
52
|
-
"ID",
|
|
53
|
-
])),
|
|
54
|
-
fetched = state.get("fetched"),
|
|
55
|
-
dataID = String(payload.get("ID")),
|
|
56
|
-
theCurrentCompanyHasChanged = fetched && (dataID === companyID);
|
|
57
|
-
|
|
58
|
-
if (theCurrentCompanyHasChanged) {
|
|
59
|
-
return state.clear();
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return state;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const reducer = (state : any = initialState, action : Action) => {
|
|
66
|
-
switch (action.type) {
|
|
67
|
-
case "FETCH_CURRENT_COMPANY_INFO_PENDING":
|
|
68
|
-
return fetchCompanyPending();
|
|
69
|
-
|
|
70
|
-
case "FETCH_CURRENT_COMPANY_INFO_REJECTED":
|
|
71
|
-
return fetchCompanyRejected(state,
|
|
72
|
-
action);
|
|
73
|
-
|
|
74
|
-
case "FETCH_CURRENT_COMPANY_INFO_FULFILLED":
|
|
75
|
-
return fetchCompanyFulfilled(state,
|
|
76
|
-
action);
|
|
77
|
-
|
|
78
|
-
case "MODIFY_CURRENT_COMPANY_INFO":
|
|
79
|
-
return modifyCompany(state,
|
|
80
|
-
action);
|
|
81
|
-
|
|
82
|
-
case "TOGGLE_COMPANY_STATE":
|
|
83
|
-
case "DELETE_COMPANY":
|
|
84
|
-
return clearInfoIfCurrentCompany(state,
|
|
85
|
-
action);
|
|
86
|
-
|
|
87
|
-
default:
|
|
88
|
-
return state;
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
const
|
|
93
|
-
getFetching = (state : State) => state.getIn([
|
|
94
|
-
reducerKey,
|
|
95
|
-
"fetching",
|
|
96
|
-
]) || false,
|
|
97
|
-
getFetched = (state : State) => state.getIn([
|
|
98
|
-
reducerKey,
|
|
99
|
-
"fetched",
|
|
100
|
-
]) || false,
|
|
101
|
-
getError = (state : State) => state.getIn([
|
|
102
|
-
reducerKey,
|
|
103
|
-
"error",
|
|
104
|
-
]) || noError,
|
|
105
|
-
getCurrentAccountFetched = (state : State) => state.getIn([
|
|
106
|
-
"account",
|
|
107
|
-
"fetched",
|
|
108
|
-
]) || false;
|
|
109
|
-
|
|
110
|
-
const checkForNoErrors = (error) => error !== noError;
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
getCurrentCompany = (state : State) : any => (
|
|
114
|
-
state.getIn([
|
|
115
|
-
reducerKey,
|
|
116
|
-
"company",
|
|
117
|
-
]) || Immutable.Map()
|
|
118
|
-
),
|
|
119
|
-
getCurrentCompanyIsFetched = createSelector(
|
|
120
|
-
getFetching,
|
|
121
|
-
getFetched,
|
|
122
|
-
getError,
|
|
123
|
-
(isFetching, isFetched, error) => (
|
|
124
|
-
!isFetching && isFetched && error === noError
|
|
125
|
-
),
|
|
126
|
-
),
|
|
127
|
-
getCurrentCompanyIsFetching = createSelector(
|
|
128
|
-
getFetching,
|
|
129
|
-
getError,
|
|
130
|
-
(isFetching, error) => (
|
|
131
|
-
isFetching && error === noError
|
|
132
|
-
),
|
|
133
|
-
),
|
|
134
|
-
getCurrentCompanyHasError = createSelector(
|
|
135
|
-
getError,
|
|
136
|
-
checkForNoErrors,
|
|
137
|
-
),
|
|
138
|
-
getCurrentCompanyShouldFetch = createSelector(
|
|
139
|
-
getCurrentAccountFetched,
|
|
140
|
-
getCurrentCompanyIsFetched,
|
|
141
|
-
getCurrentCompanyHasError,
|
|
142
|
-
getFetching,
|
|
143
|
-
getCurrentCompany,
|
|
144
|
-
(accountFetched, isFetched, hasError, isFetching, company) => (rawID : string) => {
|
|
145
|
-
const
|
|
146
|
-
hasIDChanged = () => {
|
|
147
|
-
const
|
|
148
|
-
id = company.get("ID"),
|
|
149
|
-
newID = Number(rawID);
|
|
150
|
-
|
|
151
|
-
return (
|
|
152
|
-
id === 0 ||
|
|
153
|
-
id !== newID ||
|
|
154
|
-
(id === newID && !isFetched)
|
|
155
|
-
);
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
return (
|
|
159
|
-
accountFetched && !hasError && !isFetching && hasIDChanged()
|
|
160
|
-
);
|
|
161
|
-
},
|
|
162
|
-
),
|
|
163
|
-
getCompanyModules = createSelector(
|
|
164
|
-
getCurrentCompany,
|
|
165
|
-
(company) => company.get("Modules") || "",
|
|
166
|
-
),
|
|
167
|
-
|
|
168
|
-
/*
|
|
169
|
-
This function is special, because it is called also in the
|
|
170
|
-
requests
|
|
171
|
-
In case the state is not ready, we take the id of the current company
|
|
172
|
-
from the URL
|
|
173
|
-
|
|
174
|
-
The url must have this pathname:
|
|
175
|
-
|
|
176
|
-
something/:companyID/something...
|
|
177
|
-
*/
|
|
178
|
-
getCurrentCompanyID = (state : any) => {
|
|
179
|
-
if (typeof state === "undefined" || state === null) {
|
|
180
|
-
return getIDFromURL();
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
return state.getIn([
|
|
184
|
-
reducerKey,
|
|
185
|
-
"company",
|
|
186
|
-
"ID",
|
|
187
|
-
]);
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
export const selectors = {
|
|
192
|
-
getCurrentCompany,
|
|
193
|
-
getCurrentCompanyIsFetched,
|
|
194
|
-
getCurrentCompanyIsFetching,
|
|
195
|
-
getCurrentCompanyHasError,
|
|
196
|
-
getCurrentCompanyShouldFetch,
|
|
197
|
-
getCompanyModules,
|
|
198
|
-
getCurrentCompanyID,
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
export default reducer;
|
package/src/Company/request.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import agent from "superagent";
|
|
4
|
-
import * as Immutable from "immutable";
|
|
5
|
-
|
|
6
|
-
import { withPromiseCallback } from "../utility";
|
|
7
|
-
import { selectors } from "./reducer";
|
|
8
|
-
|
|
9
|
-
export const fetchCurrentCompany = (id : string) => (
|
|
10
|
-
new Promise((resolve, reject) => (
|
|
11
|
-
agent.
|
|
12
|
-
get(`/api/company/${id}/get-information`).
|
|
13
|
-
set("Accept",
|
|
14
|
-
"application/json").
|
|
15
|
-
end(withPromiseCallback((data) => resolve(Immutable.Map(data)),
|
|
16
|
-
reject))
|
|
17
|
-
)) : Promise<any>
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
export const modifyCurrentCompany = (data : any) => (
|
|
21
|
-
new Promise((resolve, reject) => (
|
|
22
|
-
agent.
|
|
23
|
-
post(`/api/company/${selectors.getCurrentCompanyID()}/modify-info`).
|
|
24
|
-
set("Accept",
|
|
25
|
-
"application/json").
|
|
26
|
-
send(data).
|
|
27
|
-
end(withPromiseCallback(resolve,
|
|
28
|
-
reject))
|
|
29
|
-
)) : Promise<any>
|
|
30
|
-
);
|
package/src/Company/util.js
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import type { Dispatch } from "src\\types";
|
|
4
|
-
|
|
5
|
-
type OptionsContainerPropTypes = {
|
|
6
|
-
+accountName: string;
|
|
7
|
-
+showLogoutProblem: () => void;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
type OptionsContainerStateTypes = {
|
|
11
|
-
open: boolean;
|
|
12
|
-
readyToLogout: boolean;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
import React, { Component } from "react";
|
|
16
|
-
import { ButtonDropdown, DropdownToggle, DropdownMenu } from "reactstrap";
|
|
17
|
-
import { connect } from "react-redux";
|
|
18
|
-
|
|
19
|
-
import LogoutButton from "./LogoutButton";
|
|
20
|
-
|
|
21
|
-
import { notifyError } from "../actions";
|
|
22
|
-
|
|
23
|
-
import { logOut as logoutRequest } from "./request";
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
mapDispatchToProps = (dispatch : Dispatch) => ({
|
|
27
|
-
showLogoutProblem () {
|
|
28
|
-
dispatch(notifyError("Am pierdut conexiunea cu server-ul"));
|
|
29
|
-
},
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
class OptionsContainer extends Component<OptionsContainerPropTypes, OptionsContainerStateTypes> {
|
|
33
|
-
|
|
34
|
-
props: OptionsContainerPropTypes;
|
|
35
|
-
|
|
36
|
-
state: OptionsContainerStateTypes;
|
|
37
|
-
|
|
38
|
-
toggle: () => void;
|
|
39
|
-
logoutAccount: () => void;
|
|
40
|
-
|
|
41
|
-
constructor () {
|
|
42
|
-
super();
|
|
43
|
-
|
|
44
|
-
this.toggle = () => this.setState((prevState) => ({
|
|
45
|
-
open: !prevState.open,
|
|
46
|
-
}));
|
|
47
|
-
|
|
48
|
-
this.logoutAccount = () => {
|
|
49
|
-
const that = this;
|
|
50
|
-
|
|
51
|
-
this.setState({
|
|
52
|
-
readyToLogout: false,
|
|
53
|
-
}, () => {
|
|
54
|
-
logoutRequest().
|
|
55
|
-
then(() => {
|
|
56
|
-
const delay = 800;
|
|
57
|
-
|
|
58
|
-
setTimeout(() => {
|
|
59
|
-
document.location.href = "/";
|
|
60
|
-
}, delay);
|
|
61
|
-
}).
|
|
62
|
-
catch(() => {
|
|
63
|
-
that.setState({
|
|
64
|
-
readyToLogout: true,
|
|
65
|
-
});
|
|
66
|
-
that.props.showLogoutProblem();
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
this.state = {
|
|
72
|
-
open : false,
|
|
73
|
-
readyToLogout : true,
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
shouldComponentUpdate (
|
|
78
|
-
nextProps : OptionsContainerPropTypes,
|
|
79
|
-
nextState: OptionsContainerStateTypes,
|
|
80
|
-
) {
|
|
81
|
-
return (
|
|
82
|
-
this.props.accountName !== nextProps.accountName ||
|
|
83
|
-
|
|
84
|
-
this.state.readyToLogout !== nextState.readyToLogout ||
|
|
85
|
-
this.state.open !== nextState.open
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
render () {
|
|
90
|
-
const { accountName } = this.props;
|
|
91
|
-
|
|
92
|
-
const { open, readyToLogout } = this.state;
|
|
93
|
-
|
|
94
|
-
return (
|
|
95
|
-
<div className="btn-group">
|
|
96
|
-
<ButtonDropdown isOpen={open} toggle={this.toggle}>
|
|
97
|
-
<DropdownToggle caret>
|
|
98
|
-
{"Opțiuni"}
|
|
99
|
-
</DropdownToggle>
|
|
100
|
-
<DropdownMenu className="dropdown-menu-left">
|
|
101
|
-
<h6 className="dropdown-header">{accountName}</h6>
|
|
102
|
-
<a className="dropdown-item" href="/settings/termeni-si-conditii/all" target="_blank">
|
|
103
|
-
{"Termeni & condiții"}
|
|
104
|
-
</a>
|
|
105
|
-
<a
|
|
106
|
-
className="dropdown-item"
|
|
107
|
-
href="/settings/politica-de-confidentialitate/all" target="_blank">
|
|
108
|
-
{"Politica de confidențialitate"}
|
|
109
|
-
</a>
|
|
110
|
-
|
|
111
|
-
<div className="dropdown-divider" />
|
|
112
|
-
<LogoutButton
|
|
113
|
-
logoutAccount={this.logoutAccount}
|
|
114
|
-
readyToLogout={readyToLogout}
|
|
115
|
-
/>
|
|
116
|
-
</DropdownMenu>
|
|
117
|
-
</ButtonDropdown>
|
|
118
|
-
</div>
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export default connect(null,
|
|
124
|
-
mapDispatchToProps)(OptionsContainer);
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import type { CompanyRoutePropTypes } from "./types";
|
|
4
|
-
|
|
5
|
-
import React, { Component } from "react";
|
|
6
|
-
import agent from "superagent";
|
|
7
|
-
import { withRouter } from "react-router-dom";
|
|
8
|
-
|
|
9
|
-
import AsyncSelect from "react-select/async";
|
|
10
|
-
|
|
11
|
-
import { withPromiseCallback } from "../utility";
|
|
12
|
-
import { loadingMessage,
|
|
13
|
-
getDefaultCompanyRoute, noOptionsMessage, Option, wrapperClassname, isSmall } from "./util";
|
|
14
|
-
|
|
15
|
-
type AdminSelectCompanyPropTypes = {
|
|
16
|
-
+companies: any;
|
|
17
|
-
+history: any;
|
|
18
|
-
+toggleNavbar: () => void;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
type AdminSelectCompanyState = {
|
|
22
|
-
inputValue: string,
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const loadOptions = (search, callback) => {
|
|
26
|
-
const reject = ({
|
|
27
|
-
args: {
|
|
28
|
-
// eslint-disable-next-line
|
|
29
|
-
error,
|
|
30
|
-
},
|
|
31
|
-
// eslint-disable-next-line
|
|
32
|
-
}) => {};
|
|
33
|
-
|
|
34
|
-
const prepare = ({ Suggestions }) => callback(
|
|
35
|
-
Suggestions.reduce((accumulator, currentValue) => {
|
|
36
|
-
accumulator.push({
|
|
37
|
-
...currentValue,
|
|
38
|
-
value : currentValue.ID,
|
|
39
|
-
label : currentValue.Name,
|
|
40
|
-
});
|
|
41
|
-
return accumulator;
|
|
42
|
-
}, []),
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
agent.
|
|
46
|
-
get("/api/account/get-companies").
|
|
47
|
-
type("form").
|
|
48
|
-
set("Accept", "application/json").
|
|
49
|
-
query({ search }).
|
|
50
|
-
// eslint-disable-next-line
|
|
51
|
-
end(withPromiseCallback(prepare, reject));
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
class AdminSelectCompany extends Component<AdminSelectCompanyPropTypes, AdminSelectCompanyState> {
|
|
55
|
-
props: AdminSelectCompanyPropTypes;
|
|
56
|
-
state : AdminSelectCompanyState;
|
|
57
|
-
|
|
58
|
-
handleChange: (options: CompanyRoutePropTypes) => void;
|
|
59
|
-
handleInputChange: (newValue : string) => string;
|
|
60
|
-
|
|
61
|
-
constructor (props) {
|
|
62
|
-
super(props);
|
|
63
|
-
|
|
64
|
-
this.state = { inputValue: "" };
|
|
65
|
-
|
|
66
|
-
this.handleChange = (options : CompanyRoutePropTypes) => {
|
|
67
|
-
if (isSmall()) {
|
|
68
|
-
this.props.toggleNavbar();
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
this.props.history.push(getDefaultCompanyRoute(options));
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
this.handleInputChange = (newValue: string) => {
|
|
75
|
-
const inputValue = newValue.replace(/\W/gu, "");
|
|
76
|
-
|
|
77
|
-
this.setState({ inputValue });
|
|
78
|
-
return inputValue;
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
render () {
|
|
83
|
-
return (
|
|
84
|
-
<div
|
|
85
|
-
className={wrapperClassname} >
|
|
86
|
-
<AsyncSelect
|
|
87
|
-
cacheOptions
|
|
88
|
-
components={{ Option }}
|
|
89
|
-
loadingMessage={loadingMessage}
|
|
90
|
-
loadOptions={loadOptions}
|
|
91
|
-
noOptionsMessage={noOptionsMessage}
|
|
92
|
-
onChange={this.handleChange}
|
|
93
|
-
onInputChange={this.handleInputChange}
|
|
94
|
-
placeholder="Selectează firmă"
|
|
95
|
-
/>
|
|
96
|
-
</div>
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export default withRouter(AdminSelectCompany);
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import type { State } from "src\\types";
|
|
4
|
-
|
|
5
|
-
import React, { Component } from "react";
|
|
6
|
-
|
|
7
|
-
import Select from "react-select";
|
|
8
|
-
import { withRouter } from "react-router-dom";
|
|
9
|
-
|
|
10
|
-
import { getDefaultCompanyRoute, noOptionsMessage, Option, wrapperClassname, isSmall } from "./util";
|
|
11
|
-
|
|
12
|
-
import { connect } from "react-redux";
|
|
13
|
-
|
|
14
|
-
import { selectors } from "../Account/reducer";
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
mapStateToProps = (state : State) => ({
|
|
18
|
-
companies: selectors.getCurrentAccountCompanies(state),
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
type ClientSelectCompanyPropTypes = {
|
|
22
|
-
+companies: any;
|
|
23
|
-
+history: any;
|
|
24
|
-
+toggleNavbar: () => void;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
type ClientSelectCompanyState = {
|
|
28
|
-
inputValue: string,
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
class ClientSelectCompany extends Component<ClientSelectCompanyPropTypes, ClientSelectCompanyState> {
|
|
32
|
-
props: ClientSelectCompanyPropTypes;
|
|
33
|
-
state : ClientSelectCompanyState;
|
|
34
|
-
|
|
35
|
-
handleChange: (options : any) => any;
|
|
36
|
-
handleInputChange: (newValue: string) => string;
|
|
37
|
-
|
|
38
|
-
constructor (props) {
|
|
39
|
-
super(props);
|
|
40
|
-
|
|
41
|
-
this.state = { inputValue: "" };
|
|
42
|
-
|
|
43
|
-
this.handleChange = (options : any) => {
|
|
44
|
-
if (isSmall()) {
|
|
45
|
-
this.props.toggleNavbar();
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
this.props.history.push(getDefaultCompanyRoute(options));
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
this.handleInputChange = (newValue: string) => {
|
|
52
|
-
const inputValue = newValue.replace(/\W/gu, "");
|
|
53
|
-
|
|
54
|
-
this.setState({ inputValue });
|
|
55
|
-
return inputValue;
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
render () {
|
|
60
|
-
const { companies } = this.props;
|
|
61
|
-
|
|
62
|
-
const options = companies.reduce((accumulator, currentValue) => {
|
|
63
|
-
accumulator.push({
|
|
64
|
-
...currentValue.toJS(),
|
|
65
|
-
value : currentValue.get("ID"),
|
|
66
|
-
label : currentValue.get("Name"),
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
return accumulator;
|
|
70
|
-
}, []);
|
|
71
|
-
|
|
72
|
-
if (companies.size > 1) {
|
|
73
|
-
return (
|
|
74
|
-
<div className={wrapperClassname} >
|
|
75
|
-
<Select
|
|
76
|
-
components={{ Option }}
|
|
77
|
-
noOptionsMessage={noOptionsMessage}
|
|
78
|
-
onChange={this.handleChange}
|
|
79
|
-
options={options}
|
|
80
|
-
placeholder="Selectează firmă"
|
|
81
|
-
/>
|
|
82
|
-
</div>
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export default withRouter(connect(mapStateToProps)(ClientSelectCompany));
|
package/src/Header/Header.jsx
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
type HeaderPropTypes = {
|
|
4
|
-
+brand : string;
|
|
5
|
-
+company: any;
|
|
6
|
-
+account : any;
|
|
7
|
-
+isAdmin: bool;
|
|
8
|
-
+sidebarDocked: boolean;
|
|
9
|
-
+showNavbar: boolean;
|
|
10
|
-
|
|
11
|
-
+toggleNavbar: () => void;
|
|
12
|
-
|
|
13
|
-
+showSidebar: () => void;
|
|
14
|
-
+showPayModal: (id : number) => () => void;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
import React from "react";
|
|
18
|
-
import moment from "moment";
|
|
19
|
-
import { Collapse } from "reactstrap";
|
|
20
|
-
|
|
21
|
-
import AccountOptionsContainer from "./AccountOptionsContainer";
|
|
22
|
-
import AdminSelectCompany from "./AdminSelectCompany";
|
|
23
|
-
import ClientSelectCompany from "./ClientSelectCompany";
|
|
24
|
-
|
|
25
|
-
import { isSmall } from "./util";
|
|
26
|
-
|
|
27
|
-
const monthsUntilShowNotice = 30;
|
|
28
|
-
|
|
29
|
-
const Header = ({
|
|
30
|
-
brand, company, account, isAdmin, showPayModal, sidebarDocked,
|
|
31
|
-
toggleNavbar, showNavbar, showSidebar,
|
|
32
|
-
} : HeaderPropTypes) => {
|
|
33
|
-
|
|
34
|
-
let
|
|
35
|
-
showNoticeToPay = false;
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
countDays = typeof company !== "undefined" && account.get("ID") === company.get("OwnerID");
|
|
39
|
-
|
|
40
|
-
if (countDays) {
|
|
41
|
-
const daysLeft = moment(company.get("ValabilityDate")).diff(moment().endOf("day"), "days") + 1;
|
|
42
|
-
|
|
43
|
-
showNoticeToPay = daysLeft <= monthsUntilShowNotice;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return (
|
|
47
|
-
<React.Fragment>
|
|
48
|
-
<nav className="d-print-none navbar navbar-expand-md navbar-dark bg-dark">
|
|
49
|
-
{
|
|
50
|
-
sidebarDocked ? null : (
|
|
51
|
-
<button
|
|
52
|
-
aria-label="Comută meniul"
|
|
53
|
-
className="btn btn-outline-secondary btn-sm mr-2"
|
|
54
|
-
onClick={showSidebar}
|
|
55
|
-
type="button">
|
|
56
|
-
<i className="fa fa-bars" />
|
|
57
|
-
</button>
|
|
58
|
-
)
|
|
59
|
-
}
|
|
60
|
-
<div
|
|
61
|
-
className="brand-wrapper truncate text-left d-inline-block text-light"
|
|
62
|
-
onClick={isSmall() ? toggleNavbar : null}>
|
|
63
|
-
<a className="navbar-brand">
|
|
64
|
-
{brand}
|
|
65
|
-
</a>
|
|
66
|
-
</div>
|
|
67
|
-
<button
|
|
68
|
-
className="mt-3 text-dark navbar-toggler"
|
|
69
|
-
onClick={toggleNavbar}
|
|
70
|
-
type="button">
|
|
71
|
-
{
|
|
72
|
-
showNavbar ? (
|
|
73
|
-
<i className="fa fa-arrow-up text-light" />
|
|
74
|
-
) : (
|
|
75
|
-
<i className="fa fa-arrow-down text-light" />
|
|
76
|
-
)
|
|
77
|
-
}
|
|
78
|
-
</button>
|
|
79
|
-
<Collapse isOpen={showNavbar} navbar>
|
|
80
|
-
<ul className="ml-auto navbar-nav">
|
|
81
|
-
<a className="nav-link" href="/settings/companies">
|
|
82
|
-
{"Setări"}
|
|
83
|
-
</a>
|
|
84
|
-
{
|
|
85
|
-
isAdmin ? (
|
|
86
|
-
<AdminSelectCompany toggleNavbar={toggleNavbar} />
|
|
87
|
-
) : (
|
|
88
|
-
<ClientSelectCompany toggleNavbar={toggleNavbar} />
|
|
89
|
-
)
|
|
90
|
-
}
|
|
91
|
-
<div className="d-inline-block">
|
|
92
|
-
<AccountOptionsContainer accountName={account.get("Name")} />
|
|
93
|
-
</div>
|
|
94
|
-
</ul>
|
|
95
|
-
</Collapse>
|
|
96
|
-
</nav>
|
|
97
|
-
{
|
|
98
|
-
typeof company === "undefined" || company.size === 0 ? null : (
|
|
99
|
-
showNoticeToPay ? (
|
|
100
|
-
<div className="alert alert-warning m-2">
|
|
101
|
-
{`Abonamentul la serviciile online Sidework va expira ${(
|
|
102
|
-
moment(company.get("ValabilityDate")).
|
|
103
|
-
endOf("day").
|
|
104
|
-
fromNow()
|
|
105
|
-
)}. `}
|
|
106
|
-
<button
|
|
107
|
-
className="btn btn-primary"
|
|
108
|
-
onClick={showPayModal(company.get("ID"))}
|
|
109
|
-
type="button">
|
|
110
|
-
{"Reînnoiește abonamentul"}
|
|
111
|
-
</button>
|
|
112
|
-
</div>
|
|
113
|
-
) : null
|
|
114
|
-
)
|
|
115
|
-
}
|
|
116
|
-
</React.Fragment>
|
|
117
|
-
);
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
export default Header;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import type { State, Dispatch } from "src\\types";
|
|
4
|
-
|
|
5
|
-
import { connect } from "react-redux";
|
|
6
|
-
|
|
7
|
-
import Header from "./Header";
|
|
8
|
-
|
|
9
|
-
import { selectors } from "../Account/reducer";
|
|
10
|
-
|
|
11
|
-
import { isAdministratorAccount } from "../utility";
|
|
12
|
-
|
|
13
|
-
import { estimateCompanyPriceModal } from "../Payment/actions";
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
mapStateToProps = (state : State) => {
|
|
17
|
-
const data = selectors.getCurrentAccount(state);
|
|
18
|
-
|
|
19
|
-
return {
|
|
20
|
-
account : data,
|
|
21
|
-
isAdmin : isAdministratorAccount(data.get("Type")),
|
|
22
|
-
};
|
|
23
|
-
},
|
|
24
|
-
mapDispatchToProps = (dispatch : Dispatch) => ({
|
|
25
|
-
showPayModal: (id) => () => {
|
|
26
|
-
dispatch(estimateCompanyPriceModal(id));
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
export default connect(mapStateToProps, mapDispatchToProps)(Header);
|