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,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;
@@ -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
- );
@@ -1,7 +0,0 @@
1
- // @flow
2
-
3
- export const getIDFromURL = () => {
4
- const parts = String(window.location.pathname).split("/");
5
-
6
- return parts[2];
7
- };
@@ -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));
@@ -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);