Compare commits
429 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
96635ffa84 | ||
|
|
e874b89d2d | ||
|
|
60d37e3424 | ||
|
|
8ae39bf04c | ||
|
|
e3f2c82a38 | ||
|
|
68c0678dc3 | ||
|
|
030be9652c | ||
|
|
554527f17d | ||
|
|
79144ad4a5 | ||
|
|
e6fcbfeea6 | ||
|
|
7eacaa0660 | ||
|
|
673808cceb | ||
|
|
f27ef2c9b0 | ||
|
|
2986b537d0 | ||
|
|
b1f07d281f | ||
|
|
1b0ffb5574 | ||
|
|
b249335a73 | ||
|
|
4cc0a8c41e | ||
|
|
2e7061260e | ||
|
|
46570c5218 | ||
|
|
72a7c4890e | ||
|
|
a9a877f4fc | ||
|
|
cc42c21f24 | ||
|
|
2f0322b4fc | ||
|
|
b9418d3eb6 | ||
|
|
526181aa68 | ||
|
|
d445fec8c0 | ||
|
|
1f81fd213d | ||
|
|
83cd7ca893 | ||
|
|
d22143c97e | ||
|
|
200a59d6da | ||
|
|
8b4d841023 | ||
|
|
c361a5852c | ||
|
|
b759d7327e | ||
|
|
93df479c05 | ||
|
|
d300231838 | ||
|
|
47f6845633 | ||
|
|
f204b81407 | ||
|
|
2c2740ea73 | ||
|
|
c72802d683 | ||
|
|
b4f6d2c7f1 | ||
|
|
4456343eb6 | ||
|
|
a3d250cdc8 | ||
|
|
ce223e7e2f | ||
|
|
8d6ed9be41 | ||
|
|
e296507a96 | ||
|
|
3d78d2d051 | ||
|
|
fa455152a3 | ||
|
|
34501a9a61 | ||
|
|
066df28257 | ||
|
|
77d826e6d4 | ||
|
|
735803f1a5 | ||
|
|
354d1e8f75 | ||
|
|
225619be60 | ||
|
|
85a78b3809 | ||
|
|
da699a766a | ||
|
|
a958c6088a | ||
|
|
572d59577c | ||
|
|
7a0d506395 | ||
|
|
21ae8aabfc | ||
|
|
8f267b98e4 | ||
|
|
dcfe92076b | ||
|
|
79cb7f1a1d | ||
|
|
1380e288e0 | ||
|
|
b055908e12 | ||
|
|
20c140474b | ||
|
|
9ee5eba92b | ||
|
|
e755a2a318 | ||
|
|
1656691940 | ||
|
|
dd7d11ffb7 | ||
|
|
5c847be420 | ||
|
|
da3193195c | ||
|
|
e3141250b6 | ||
|
|
f1899e1ce1 | ||
|
|
76d6cd0eaa | ||
|
|
90b4f86a0d | ||
|
|
5766d25bd1 | ||
|
|
6a5d96e869 | ||
|
|
69f16d1977 | ||
|
|
9973693a86 | ||
|
|
11851d114d | ||
|
|
3a3dd7a565 | ||
|
|
687dda1e7c | ||
|
|
bfa809c831 | ||
|
|
07145e92ab | ||
|
|
21779007be | ||
|
|
4fc1ecdc2d | ||
|
|
c9b5cecf7a | ||
|
|
4a46c00a07 | ||
|
|
5c7ac0593d | ||
|
|
fa25fb4ede | ||
|
|
c31e9dcd29 | ||
|
|
3566d3b855 | ||
|
|
c5da97bce0 | ||
|
|
0cfbe633bd | ||
|
|
55098d7b78 | ||
|
|
78610cd519 | ||
|
|
828a28b976 | ||
|
|
daf5fc8aba | ||
|
|
430ab95dc3 | ||
|
|
8100a57195 | ||
|
|
97d890bcef | ||
|
|
521df8511d | ||
|
|
73ec49b36a | ||
|
|
cfc625edf9 | ||
|
|
e1b6f0d879 | ||
|
|
ecda9296b8 | ||
|
|
aba732724b | ||
|
|
40bc7d4e99 | ||
|
|
7f1844aa6b | ||
|
|
7ab7456d08 | ||
|
|
de53a24d58 | ||
|
|
e0c565388a | ||
|
|
3c73540b4e | ||
|
|
a4a2d0c888 | ||
|
|
e9797fd9a0 | ||
|
|
40ae1aeb52 | ||
|
|
b2c08d5645 | ||
|
|
ee6f4028eb | ||
|
|
cdb8ea6721 | ||
|
|
0173630e80 | ||
|
|
4403bf2b06 | ||
|
|
f8e44c4f4e | ||
|
|
0bd11419bb | ||
|
|
c1e229814f | ||
|
|
871dcb62c4 | ||
|
|
5bf591d8c9 | ||
|
|
75b1cce380 | ||
|
|
119e6fa216 | ||
|
|
6b98e1f1c2 | ||
|
|
fa23aa67d3 | ||
|
|
9474a4fcd1 | ||
|
|
81c81bd09f | ||
|
|
1492c24cfb | ||
|
|
b4e9ee7ff3 | ||
|
|
e97bf56adb | ||
|
|
11d44c128b | ||
|
|
e615f62ef5 | ||
|
|
c69d29fb22 | ||
|
|
1e472d278a | ||
|
|
1688f49bc1 | ||
|
|
9182e13c07 | ||
|
|
f2150a982a | ||
|
|
d8efb17651 | ||
|
|
1e361dac66 | ||
|
|
a6cd483eb9 | ||
|
|
765f00d203 | ||
|
|
088d7d4b1d | ||
|
|
92c9001c52 | ||
|
|
93bd2af1d7 | ||
|
|
f261555b86 | ||
|
|
62ab31efd2 | ||
|
|
96cb3177aa | ||
|
|
d5f7cdf131 | ||
|
|
6ad3065f1f | ||
|
|
0860db87fb | ||
|
|
2707415319 | ||
|
|
99716e99a9 | ||
|
|
d1a67ca2ed | ||
|
|
a1ed9bf4da | ||
|
|
99df627633 | ||
|
|
e1646e92a8 | ||
|
|
d4138fdf4e | ||
|
|
49b6deed6d | ||
|
|
0dddf3d1d0 | ||
|
|
d5acb3696e | ||
|
|
2a9c1a9833 | ||
|
|
80d86b01de | ||
|
|
4a42fa4edc | ||
|
|
8ea92513fe | ||
|
|
a075b998d3 | ||
|
|
93aa60124b | ||
|
|
f9a7306e47 | ||
|
|
10f0d47b54 | ||
|
|
1d505db7bf | ||
|
|
6975ebb9e7 | ||
|
|
5defb5a279 | ||
|
|
1497a27e7d | ||
|
|
af9f4c45fc | ||
|
|
d719ac60bd | ||
|
|
789c8db693 | ||
|
|
7eea202f9d | ||
|
|
5b581b86f4 | ||
|
|
1ad2117c37 | ||
|
|
b1afa88c16 | ||
|
|
4b7af1c634 | ||
|
|
29a4ab7590 | ||
|
|
7150f12a01 | ||
|
|
934b0abbe6 | ||
|
|
b36468ff7f | ||
|
|
10c421dea0 | ||
|
|
661cbaf11e | ||
|
|
1e5b394575 | ||
|
|
dd7b44eb29 | ||
|
|
a456b9d942 | ||
|
|
5429643db5 | ||
|
|
13310b1aac | ||
|
|
7987f68aa3 | ||
|
|
1d159c2757 | ||
|
|
588995e759 | ||
|
|
e2349f1951 | ||
|
|
e80901c7a6 | ||
|
|
c87a98a5e4 | ||
|
|
da3564d315 | ||
|
|
0d924464ea | ||
|
|
961082c50b | ||
|
|
828c33bee1 | ||
|
|
1540a20a6e | ||
|
|
2a37497648 | ||
|
|
dbe067a27c | ||
|
|
3511348d04 | ||
|
|
ace3fdc569 | ||
|
|
a0098382e7 | ||
|
|
a953236bff | ||
|
|
4dda2a37aa | ||
|
|
0e79dceae8 | ||
|
|
0ca0a2ee0b | ||
|
|
7095903653 | ||
|
|
30841d57dc | ||
|
|
d0f889850c | ||
|
|
f9fe3506c5 | ||
|
|
8390e5ea6b | ||
|
|
fcd1a8849d | ||
|
|
9bd047917d | ||
|
|
2108666f3a | ||
|
|
0f10b71604 | ||
|
|
09e739a5a9 | ||
|
|
a7a94ba201 | ||
|
|
3466828b65 | ||
|
|
cfed874182 | ||
|
|
c688b8700e | ||
|
|
7a608d2ee3 | ||
|
|
33b998cbda | ||
|
|
d7da0ad24e | ||
|
|
92cff82184 | ||
|
|
7cd2b1c533 | ||
|
|
29a34f826a | ||
|
|
bd97a73c65 | ||
|
|
eebe4c46fa | ||
|
|
6aba694518 | ||
|
|
ae7d37a0e0 | ||
|
|
897e674912 | ||
|
|
a52f00eeb2 | ||
|
|
0ee9b54a9b | ||
|
|
dd8bb9cb18 | ||
|
|
86762d2dc8 | ||
|
|
c124002605 | ||
|
|
8e18d4a0dc | ||
|
|
21e075b479 | ||
|
|
51dfee699f | ||
|
|
a6a10ef6b8 | ||
|
|
fba46e2479 | ||
|
|
c4650f5d31 | ||
|
|
a441f78e61 | ||
|
|
280d991567 | ||
|
|
62e5db86a5 | ||
|
|
4fe4178090 | ||
|
|
dfc0fbbb71 | ||
|
|
295fff4746 | ||
|
|
c671fcd011 | ||
|
|
a6141d9f73 | ||
|
|
91d1dddfed | ||
|
|
ca746df86d | ||
|
|
02330c84b1 | ||
|
|
c89b8b131d | ||
|
|
3690c88c04 | ||
|
|
6573f19ff8 | ||
|
|
a948dd4236 | ||
|
|
56b1c36c9d | ||
|
|
bc7ec834c0 | ||
|
|
5963d14fdd | ||
|
|
80b8083059 | ||
|
|
ecaf23d269 | ||
|
|
14f33c667b | ||
|
|
78c42acb17 | ||
|
|
192bcdc696 | ||
|
|
ac99a6ca75 | ||
|
|
2a48d9be51 | ||
|
|
ab48e6092a | ||
|
|
bf99bda616 | ||
|
|
e1a3f471cb | ||
|
|
07e52bef7a | ||
|
|
d3c5131020 | ||
|
|
58a0ed4ecd | ||
|
|
26cf1d20f3 | ||
|
|
0fedd2479d | ||
|
|
ba585271b0 | ||
|
|
0c4259a05b | ||
|
|
31e0bbc187 | ||
|
|
43b91503d2 | ||
|
|
432e2d202a | ||
|
|
eeb16f4362 | ||
|
|
15fa1729a2 | ||
|
|
119d0b2839 | ||
|
|
0a9798e7a7 | ||
|
|
008faaece6 | ||
|
|
27916585a5 | ||
|
|
346696f673 | ||
|
|
68227b81e8 | ||
|
|
0c806366cd | ||
|
|
8b28d6894f | ||
|
|
3db00f6f70 | ||
|
|
56ab0a68e2 | ||
|
|
4ac32b3aad | ||
|
|
f98b429fcc | ||
|
|
012f204c5c | ||
|
|
7c62466c5b | ||
|
|
111ade2ac8 | ||
|
|
408e3cbb0b | ||
|
|
9cc770f168 | ||
|
|
383a9aad3b | ||
|
|
1be30fd142 | ||
|
|
63cb3f9fef | ||
|
|
ca3ff3fd8f | ||
|
|
313d0f3d0f | ||
|
|
64bf223458 | ||
|
|
97c421e2f1 | ||
|
|
ccad55dd4a | ||
|
|
a21d70a59d | ||
|
|
c2ccb7f879 | ||
|
|
fe9ca215ab | ||
|
|
c14b35356b | ||
|
|
6fd8a24802 | ||
|
|
80531b7fdb | ||
|
|
600a835dad | ||
|
|
3dff8763d4 | ||
|
|
e197d66d9f | ||
|
|
5dfb592ecc | ||
|
|
2630e0235d | ||
|
|
8b4dfe4ded | ||
|
|
9ceee6d02e | ||
|
|
553334f063 | ||
|
|
aef8eb7907 | ||
|
|
cc1f4cc26b | ||
|
|
719302b241 | ||
|
|
3db52e9c63 | ||
|
|
7393d68b7a | ||
|
|
6ec86d3cf7 | ||
|
|
1cba4b5f18 | ||
|
|
3a8e1f5238 | ||
|
|
371e374dc5 | ||
|
|
c2650c76e8 | ||
|
|
fc74346695 | ||
|
|
fca4dedeac | ||
|
|
e5d02043ad | ||
|
|
51fde0cc31 | ||
|
|
afee2e90e0 | ||
|
|
802f7cc442 | ||
|
|
d45005d8c2 | ||
|
|
15e7f34879 | ||
|
|
a54ddf27c7 | ||
|
|
955ae97c19 | ||
|
|
ddbadb67c8 | ||
|
|
b853eb1e75 | ||
|
|
c139e129bf | ||
|
|
3d3827b683 | ||
|
|
cf6d8d6038 | ||
|
|
d12b965bac | ||
|
|
5f0700b5e5 | ||
|
|
48348da663 | ||
|
|
fe8f41f200 | ||
|
|
0ad5a9ed03 | ||
|
|
bd282acae4 | ||
|
|
377fb07c70 | ||
|
|
b32abc0417 | ||
|
|
11d7029568 | ||
|
|
1990ce7562 | ||
|
|
b6f0f6c2d5 | ||
|
|
4c58e49169 | ||
|
|
376a16fd65 | ||
|
|
918cd4aef3 | ||
|
|
ec844637c3 | ||
|
|
5803760c61 | ||
|
|
2e34df5d63 | ||
|
|
35d755e417 | ||
|
|
66641ca56e | ||
|
|
307aaf0aa4 | ||
|
|
eb5a82d413 | ||
|
|
ce9169b24d | ||
|
|
22069f4795 | ||
|
|
567b4da7e9 | ||
|
|
06345a5615 | ||
|
|
6b8178f643 | ||
|
|
449ff724e1 | ||
|
|
95e75f0e8f | ||
|
|
1a63ac69d8 | ||
|
|
da67217d74 | ||
|
|
e0c03141f0 | ||
|
|
4d563e3ddd | ||
|
|
8bad78b0d3 | ||
|
|
56fdf245d3 | ||
|
|
5a8c61396f | ||
|
|
5fcf32dcaa | ||
|
|
acf457c0a0 | ||
|
|
e205c0b9a3 | ||
|
|
85f1c5584b | ||
|
|
9e5fddf294 | ||
|
|
3039e43767 | ||
|
|
7371557482 | ||
|
|
4b5e06f50c | ||
|
|
8daefb6946 | ||
|
|
6bf605f9ea | ||
|
|
48221a7af1 | ||
|
|
7a1c9caa70 | ||
|
|
8c2d138976 | ||
|
|
5b09d8279e | ||
|
|
92d8096f3a | ||
|
|
adc6b336e0 | ||
|
|
6d67d6163d | ||
|
|
4d89f1e0e0 | ||
|
|
7706d2992c | ||
|
|
6dcb98a438 | ||
|
|
834d365a97 | ||
|
|
d26ef01afc | ||
|
|
2bd4c5f724 | ||
|
|
2c71d07512 | ||
|
|
17a4744e58 | ||
|
|
46f6380fe6 | ||
|
|
d94d28f709 | ||
|
|
94e6b64944 | ||
|
|
d8e9be0246 | ||
|
|
7ef72e8955 | ||
|
|
d76cc3d2a2 | ||
|
|
3102329ac0 | ||
|
|
fd09ea12ff | ||
|
|
7bd09e7326 | ||
|
|
cd3105b320 | ||
|
|
91b848f158 | ||
|
|
352e517c2b |
1
.env.example
Normal file
1
.env.example
Normal file
@@ -0,0 +1 @@
|
||||
APP_VERSION=$npm_package_version
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -13,6 +13,7 @@
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
.env
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
|
||||
62
CHANGELOG.md
62
CHANGELOG.md
@@ -2,6 +2,66 @@
|
||||
|
||||
All notable changes to Bigcapital server-side will be in this file.
|
||||
|
||||
## [1.5.8] - 13-01-2022
|
||||
|
||||
### Added
|
||||
- Add payment receive PDF print.
|
||||
- Add credit note PDF print.
|
||||
|
||||
### Fixed
|
||||
- fix: Payment receive initial loading state depends on request loading state instead fetching.
|
||||
- fix: Balance sheet report alert positioning.
|
||||
- fix: Separate customer and vendor inactivate and activate alerts.
|
||||
- fix: Hide convert to invoice button if the invoice is already converted.
|
||||
- fix: Customer and vendor balance summary percentage of column option.
|
||||
- fix: Remove duplicated details in sales and purchases details drawers.
|
||||
|
||||
## [1.5.3] - 03-01-2020
|
||||
|
||||
### Fixed
|
||||
|
||||
- Localize the global errors.
|
||||
- Expand account name column on trial balance sheet.
|
||||
|
||||
## [1.5.0] - 20-12-2021
|
||||
|
||||
### Added
|
||||
|
||||
- Add credit note on sales module.
|
||||
- Add vendor credit on purchases module.
|
||||
- Optimize landed costs on purchase invoices.
|
||||
- Display associated payment transactions on sale invoice drawer.
|
||||
- Display associated pamyment transactions on purchase invoice drawer.
|
||||
- Display item associate invoice, bill, estimate and receipt transactions.
|
||||
- Transactions locking on all transactions or individual modules.
|
||||
- Roles and permissions access control module.
|
||||
- Optimize readonly details style of invoice, receipt, estimate, payment receive,
|
||||
purchase invoice, expense, manual journal, inventory adjustment and cashflow transaction.
|
||||
|
||||
### Changed
|
||||
|
||||
- Dashboard meta boot and authenticated user request query.
|
||||
- Optimize Arabic localization.
|
||||
|
||||
## [1.4.0] - 11-09-2021
|
||||
|
||||
### Added
|
||||
|
||||
- Add SMS notification on sale invoice, receipt, customers payments modules.
|
||||
- Customer quick create in customers list.
|
||||
- Item quick create in items list.
|
||||
|
||||
### Changes
|
||||
|
||||
change: BIG-171 alerts in global scope and lazy loading.
|
||||
|
||||
### Fixed
|
||||
|
||||
fix: BIG-140 - Reordering sell, cost and inventory account on item details.
|
||||
fix: BIG-144 - Typo adjustment dialog success message.
|
||||
fix: BIG-148 - Items entries ordered by index.
|
||||
fix: BIG-132 AR/AP aging summary report filter by none transactions/zero contacts.
|
||||
|
||||
## [1.2.0-RC] - 03-09-2021
|
||||
|
||||
Here we write upgrading notes for brands. It's a team effort to make them as
|
||||
@@ -32,7 +92,7 @@ straightforward as possible.
|
||||
- Inventory adjustment publish action.
|
||||
- Customers and vendors activate and inactivate action.
|
||||
- Add refresh button on dashboard actions bar to all datatables resources.
|
||||
- Add clickable datatable rows to display each row details.
|
||||
- Add clickable datatable rows to display each row details.
|
||||
|
||||
### Changed
|
||||
|
||||
|
||||
@@ -85,6 +85,9 @@ function getClientEnvironment(publicUrl) {
|
||||
WDS_SOCKET_HOST: process.env.WDS_SOCKET_HOST,
|
||||
WDS_SOCKET_PATH: process.env.WDS_SOCKET_PATH,
|
||||
WDS_SOCKET_PORT: process.env.WDS_SOCKET_PORT,
|
||||
|
||||
// Application version.
|
||||
VERSION: paths.appVersion
|
||||
}
|
||||
);
|
||||
// Stringify all values so we can feed into webpack DefinePlugin
|
||||
|
||||
@@ -48,6 +48,8 @@ const resolveModule = (resolveFn, filePath) => {
|
||||
return resolveFn(`${filePath}.js`);
|
||||
};
|
||||
|
||||
const appVersion = require(resolveApp('package.json')).version;
|
||||
|
||||
// config after eject: we're in ./config/
|
||||
module.exports = {
|
||||
dotenv: resolveApp('.env'),
|
||||
@@ -65,6 +67,7 @@ module.exports = {
|
||||
proxySetup: resolveApp('src/setupProxy.js'),
|
||||
appNodeModules: resolveApp('node_modules'),
|
||||
publicUrlOrPath,
|
||||
appVersion
|
||||
};
|
||||
|
||||
|
||||
|
||||
779
package-lock.json
generated
779
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "bigcapital-client",
|
||||
"version": "1.2.0",
|
||||
"version": "1.5.8",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@babel/core": "7.8.4",
|
||||
@@ -10,6 +10,8 @@
|
||||
"@blueprintjs/select": "^3.11.2",
|
||||
"@blueprintjs/table": "^3.8.3",
|
||||
"@blueprintjs/timezone": "^3.6.2",
|
||||
"@casl/ability": "^5.4.3",
|
||||
"@casl/react": "^2.3.0",
|
||||
"@reduxjs/toolkit": "^1.2.5",
|
||||
"@sentry/react": "^6.13.2",
|
||||
"@sentry/tracing": "^6.13.2",
|
||||
@@ -34,6 +36,7 @@
|
||||
"cross-env": "^7.0.2",
|
||||
"css-loader": "3.4.2",
|
||||
"deep-map-keys": "^2.0.1",
|
||||
"dependency-graph": "^0.11.0",
|
||||
"dotenv": "8.2.0",
|
||||
"dotenv-expand": "5.1.0",
|
||||
"eslint": "^6.6.0",
|
||||
@@ -44,6 +47,7 @@
|
||||
"eslint-plugin-jsx-a11y": "6.2.3",
|
||||
"eslint-plugin-react": "7.18.0",
|
||||
"eslint-plugin-react-hooks": "^1.6.1",
|
||||
"fast-deep-equal": "^3.1.3",
|
||||
"file-loader": "4.3.0",
|
||||
"flow-bin": "^0.123.0",
|
||||
"formik": "^2.2.5",
|
||||
@@ -68,6 +72,7 @@
|
||||
"postcss-preset-env": "6.7.0",
|
||||
"postcss-rtl": "^1.7.3",
|
||||
"postcss-safe-parser": "4.0.1",
|
||||
"query-string": "^7.1.1",
|
||||
"ramda": "^0.27.1",
|
||||
"react": "^16.12.0",
|
||||
"react-app-polyfill": "^1.0.6",
|
||||
@@ -89,7 +94,7 @@
|
||||
"react-sortablejs": "^2.0.11",
|
||||
"react-split-pane": "^0.1.91",
|
||||
"react-table": "^7.6.3",
|
||||
"react-table-sticky": "^1.1.2",
|
||||
"react-table-sticky": "^1.1.3",
|
||||
"react-transition-group": "^4.4.1",
|
||||
"react-use": "^13.26.1",
|
||||
"react-use-context-menu": "^0.1.4",
|
||||
@@ -104,6 +109,7 @@
|
||||
"semver": "6.3.0",
|
||||
"style-loader": "0.23.1",
|
||||
"styled-components": "^5.3.1",
|
||||
"stylis-rtlcss": "^2.1.1",
|
||||
"terser-webpack-plugin": "2.3.4",
|
||||
"ts-pnp": "1.1.5",
|
||||
"url-loader": "2.3.0",
|
||||
|
||||
@@ -2,7 +2,11 @@
|
||||
<html dir="ltr" lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="%PUBLIC_URL%/favicons/favicon-32.ico" sizes="32x32">
|
||||
<link
|
||||
rel="icon"
|
||||
href="%PUBLIC_URL%/favicons/favicon-32.ico"
|
||||
sizes="32x32"
|
||||
/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<meta
|
||||
@@ -15,6 +19,25 @@
|
||||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
||||
-->
|
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||
|
||||
<% if (process.env.NODE_ENV === 'production') { %>
|
||||
<!-- Hotjar Tracking Code for https://app.bigcapital.ly/ -->
|
||||
<script>
|
||||
(function (h, o, t, j, a, r) {
|
||||
h.hj =
|
||||
h.hj ||
|
||||
function () {
|
||||
(h.hj.q = h.hj.q || []).push(arguments);
|
||||
};
|
||||
h._hjSettings = { hjid: 2774528, hjsv: 6 };
|
||||
a = o.getElementsByTagName('head')[0];
|
||||
r = o.createElement('script');
|
||||
r.async = 1;
|
||||
r.src = t + h._hjSettings.hjid + j + h._hjSettings.hjsv;
|
||||
a.appendChild(r);
|
||||
})(window, document, 'https://static.hotjar.com/c/hotjar-', '.js?sv=');
|
||||
</script>
|
||||
<% } %>
|
||||
<!--
|
||||
Notice the use of %PUBLIC_URL% in the tags above.
|
||||
It will be replaced with the URL of the `public` folder during the build.
|
||||
@@ -41,7 +64,11 @@
|
||||
To create a production bundle, use `npm run build` or `yarn build`.
|
||||
-->
|
||||
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/flexboxgrid/6.3.1/flexboxgrid.min.css" type="text/css" >
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdnjs.cloudflare.com/ajax/libs/flexboxgrid/6.3.1/flexboxgrid.min.css"
|
||||
type="text/css"
|
||||
/>
|
||||
<!-- <link href="https://cdn.syncfusion.com/ej2/material.css" rel="stylesheet"> -->
|
||||
<!-- <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" /> -->
|
||||
</body>
|
||||
|
||||
6
src/common/TableStyle.js
Normal file
6
src/common/TableStyle.js
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
|
||||
export const TableStyle = {
|
||||
Constrant: 'constrant',
|
||||
Regular: 'regular'
|
||||
}
|
||||
178
src/common/abilityOption.js
Normal file
178
src/common/abilityOption.js
Normal file
@@ -0,0 +1,178 @@
|
||||
export const AbilitySubject = {
|
||||
Item: 'Item',
|
||||
InventoryAdjustment: 'InventoryAdjustment',
|
||||
Estimate: 'SaleEstimate',
|
||||
Invoice: 'SaleInvoice',
|
||||
Receipt: 'SaleReceipt',
|
||||
PaymentReceive: 'PaymentReceive',
|
||||
Bill: 'Bill',
|
||||
PaymentMade: 'PaymentMade',
|
||||
Customer: 'Customer',
|
||||
Vendor: 'Vendor',
|
||||
Account: 'Account',
|
||||
ManualJournal: 'ManualJournal',
|
||||
Expense: 'Expense',
|
||||
Cashflow: 'Cashflow',
|
||||
Report: 'Report',
|
||||
Preferences: 'Preferences',
|
||||
ExchangeRate: 'ExchangeRate',
|
||||
SubscriptionBilling: 'SubscriptionBilling',
|
||||
CreditNote: 'CreditNote',
|
||||
VendorCredit: 'VendorCredit',
|
||||
};
|
||||
|
||||
export const ItemAction = {
|
||||
View: 'View',
|
||||
Create: 'Create',
|
||||
Edit: 'Edit',
|
||||
Delete: 'Delete',
|
||||
};
|
||||
|
||||
export const InventoryAdjustmentAction = {
|
||||
Create: 'Create',
|
||||
Edit: 'Edit',
|
||||
View: 'View',
|
||||
Delete: 'Delete',
|
||||
};
|
||||
|
||||
export const SaleEstimateAction = {
|
||||
View: 'View',
|
||||
Create: 'Create',
|
||||
Edit: 'Edit',
|
||||
Delete: 'Delete',
|
||||
NotifyBySms: 'NotifyBySms',
|
||||
};
|
||||
|
||||
export const SaleInvoiceAction = {
|
||||
View: 'View',
|
||||
Create: 'Create',
|
||||
Edit: 'Edit',
|
||||
Delete: 'Delete',
|
||||
Writeoff: 'bad-debt',
|
||||
NotifyBySms: 'NotifyBySms',
|
||||
};
|
||||
|
||||
export const SaleReceiptAction = {
|
||||
View: 'View',
|
||||
Create: 'Create',
|
||||
Edit: 'Edit',
|
||||
Delete: 'Delete',
|
||||
NotifyBySms: 'NotifyBySms',
|
||||
};
|
||||
|
||||
export const PaymentReceiveAction = {
|
||||
View: 'View',
|
||||
Create: 'Create',
|
||||
Edit: 'Edit',
|
||||
Delete: 'Delete',
|
||||
NotifyBySms: 'NotifyBySms',
|
||||
};
|
||||
|
||||
export const CreditNoteAction = {
|
||||
View: 'View',
|
||||
Create: 'Create',
|
||||
Edit: 'Edit',
|
||||
Delete: 'Delete',
|
||||
Refund: 'Refund'
|
||||
};
|
||||
|
||||
export const VendorCreditAction = {
|
||||
View: 'View',
|
||||
Create: 'Create',
|
||||
Edit: 'Edit',
|
||||
Delete: 'Delete',
|
||||
Refund: 'Refund'
|
||||
};
|
||||
export const BillAction = {
|
||||
View: 'View',
|
||||
Create: 'Create',
|
||||
Edit: 'Edit',
|
||||
Delete: 'Delete',
|
||||
NotifyBySms: 'NotifyBySms',
|
||||
};
|
||||
|
||||
export const PaymentMadeAction = {
|
||||
View: 'View',
|
||||
Create: 'Create',
|
||||
Edit: 'Edit',
|
||||
Delete: 'Delete',
|
||||
};
|
||||
|
||||
export const CustomerAction = {
|
||||
View: 'View',
|
||||
Create: 'Create',
|
||||
Edit: 'Edit',
|
||||
Delete: 'Delete',
|
||||
};
|
||||
|
||||
export const VendorAction = {
|
||||
View: 'View',
|
||||
Create: 'Create',
|
||||
Edit: 'Edit',
|
||||
Delete: 'Delete',
|
||||
};
|
||||
|
||||
export const AccountAction = {
|
||||
View: 'View',
|
||||
Create: 'Create',
|
||||
Edit: 'Edit',
|
||||
Delete: 'Delete',
|
||||
TransactionsLocking: 'TransactionsLocking',
|
||||
};
|
||||
|
||||
export const ManualJournalAction = {
|
||||
View: 'View',
|
||||
Create: 'Create',
|
||||
Edit: 'Edit',
|
||||
Delete: 'Delete',
|
||||
TransactionLocking: 'TransactionLocking',
|
||||
};
|
||||
|
||||
export const ExpenseAction = {
|
||||
View: 'View',
|
||||
Create: 'Create',
|
||||
Edit: 'Edit',
|
||||
Delete: 'Delete',
|
||||
};
|
||||
|
||||
export const CashflowAction = {
|
||||
View: 'View',
|
||||
Create: 'Create',
|
||||
Delete: 'Delete',
|
||||
};
|
||||
|
||||
export const ReportsAction = {
|
||||
ALL: 'all',
|
||||
READ_BALANCE_SHEET: 'read-balance-sheet',
|
||||
READ_TRIAL_BALANCE_SHEET: 'read-trial-balance-sheet',
|
||||
READ_PROFIT_LOSS: 'read-profit-loss',
|
||||
READ_JOURNAL: 'read-journal',
|
||||
READ_GENERAL_LEDGET: 'read-general-ledger',
|
||||
READ_CASHFLOW: 'read-cashflow',
|
||||
READ_AR_AGING_SUMMARY: 'read-ar-aging-summary',
|
||||
READ_AP_AGING_SUMMARY: 'read-ap-aging-summary',
|
||||
READ_PURCHASES_BY_ITEMS: 'read-purchases-by-items',
|
||||
READ_SALES_BY_ITEMS: 'read-sales-by-items',
|
||||
READ_CUSTOMERS_TRANSACTIONS: 'read-customers-transactions',
|
||||
READ_VENDORS_TRANSACTIONS: 'read-vendors-transactions',
|
||||
READ_CUSTOMERS_SUMMARY_BALANCE: 'read-customers-summary-balance',
|
||||
READ_VENDORS_SUMMARY_BALANCE: 'read-vendors-summary-balance',
|
||||
READ_INVENTORY_VALUATION_SUMMARY: 'read-inventory-valuation-summary',
|
||||
READ_INVENTORY_ITEM_DETAILS: 'read-inventory-item-details',
|
||||
READ_CASHFLOW_ACCOUNT_TRANSACTION: 'read-cashflow-account-transactions',
|
||||
};
|
||||
|
||||
export const PreferencesAbility = {
|
||||
Mutate: 'Mutate',
|
||||
};
|
||||
|
||||
export const ExchangeRateAbility = {
|
||||
View: 'view',
|
||||
Create: 'create',
|
||||
Delete: 'delete',
|
||||
};
|
||||
|
||||
export const SubscriptionBillingAbility = {
|
||||
View: 'view',
|
||||
Payment: 'payment',
|
||||
};
|
||||
@@ -39,6 +39,8 @@ const CLASSES = {
|
||||
PAGE_FORM_ITEM: 'page-form--item',
|
||||
PAGE_FORM_MAKE_JOURNAL: 'page-form--make-journal-entries',
|
||||
PAGE_FORM_EXPENSE: 'page-form--expense',
|
||||
PAGE_FORM_CREDIT_NOTE:'page-form--credit-note',
|
||||
PAGE_FORM_VENDOR_CREDIT_NOTE:'page-form--vendor-credit-note',
|
||||
|
||||
FORM_GROUP_LIST_SELECT: 'form-group--select-list',
|
||||
|
||||
@@ -66,6 +68,8 @@ const CLASSES = {
|
||||
PREFERENCES_PAGE_INSIDE_CONTENT_USERS: 'preferences-page__inside-content--users',
|
||||
PREFERENCES_PAGE_INSIDE_CONTENT_CURRENCIES: 'preferences-page__inside-content--currencies',
|
||||
PREFERENCES_PAGE_INSIDE_CONTENT_ACCOUNTANT: 'preferences-page__inside-content--accountant',
|
||||
PREFERENCES_PAGE_INSIDE_CONTENT_SMS_INTEGRATION: 'preferences-page__inside-content--sms-integration',
|
||||
PREFERENCES_PAGE_INSIDE_CONTENT_ROLES_FORM: 'preferences-page__inside-content--roles-form',
|
||||
|
||||
FINANCIAL_REPORT_INSIDER: 'dashboard__insider--financial-report',
|
||||
|
||||
|
||||
@@ -10,4 +10,12 @@ export const DRAWERS = {
|
||||
BILL_DRAWER: 'bill-drawer',
|
||||
INVENTORY_ADJUSTMENT_DRAWER: 'inventory-adjustment-drawer',
|
||||
CASHFLOW_TRNASACTION_DRAWER: 'cashflow-transaction-drawer',
|
||||
|
||||
QUICK_WRITE_VENDOR: 'quick-write-vendor',
|
||||
QUICK_CREATE_CUSTOMER: 'quick-create-customer',
|
||||
QUICK_CREATE_ITEM: 'quick-create-item',
|
||||
CREDIT_NOTE_DETAIL_DRAWER: 'credit-note-detail-drawer',
|
||||
VENDOR_CREDIT_DETAIL_DRAWER: 'vendor-credit-detail-drawer',
|
||||
REFUND_CREDIT_NOTE_DETAIL_DRAWER:'refund-credit-detail-drawer',
|
||||
REFUND_VENDOR_CREDIT_DETAIL_DRAWER:'refund-vendor-detail-drawer'
|
||||
};
|
||||
|
||||
@@ -1,5 +1,21 @@
|
||||
import React from 'react';
|
||||
import { FormattedMessage as T } from 'components';
|
||||
import {
|
||||
SaleInvoiceAction,
|
||||
SaleEstimateAction,
|
||||
AbilitySubject,
|
||||
SaleReceiptAction,
|
||||
CustomerAction,
|
||||
PaymentReceiveAction,
|
||||
BillAction,
|
||||
VendorAction,
|
||||
PaymentMadeAction,
|
||||
AccountAction,
|
||||
ManualJournalAction,
|
||||
ExpenseAction,
|
||||
ItemAction,
|
||||
ReportsAction,
|
||||
} from '../common/abilityOption';
|
||||
|
||||
export const accountsReceivable = [
|
||||
{
|
||||
@@ -9,21 +25,29 @@ export const accountsReceivable = [
|
||||
title: <T id={'sales_invoices'} />,
|
||||
description: <T id={'tracking_sales_invoices_with_your_customers'} />,
|
||||
link: '/invoices',
|
||||
subject: AbilitySubject.Invoice,
|
||||
ability: SaleInvoiceAction.View,
|
||||
},
|
||||
{
|
||||
title: <T id={'sales_estimates'} />,
|
||||
description: <T id={'manage_your_sales_estimates_to_create_quotes'} />,
|
||||
link: '/estimates',
|
||||
subject: AbilitySubject.Estimate,
|
||||
ability: SaleEstimateAction.View,
|
||||
},
|
||||
{
|
||||
title: <T id={'sales_receipts'} />,
|
||||
description: <T id={'manage_sales_receipts_for_sales_that_get_paid'} />,
|
||||
link: '/receipts',
|
||||
subject: AbilitySubject.Receipt,
|
||||
ability: SaleReceiptAction.View,
|
||||
},
|
||||
{
|
||||
title: <T id={'customers'} />,
|
||||
description: <T id={'manage_the_customers_relations_with_customer'} />,
|
||||
link: '/customers',
|
||||
subject: AbilitySubject.Customer,
|
||||
ability: CustomerAction.View,
|
||||
},
|
||||
{
|
||||
title: <T id={'customers_payments'} />,
|
||||
@@ -31,6 +55,8 @@ export const accountsReceivable = [
|
||||
<T id={'manage_payment_transactions_from_your_customers'} />
|
||||
),
|
||||
link: '/payment-receives',
|
||||
subject: AbilitySubject.PaymentReceive,
|
||||
ability: PaymentReceiveAction.View,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -46,6 +72,8 @@ export const accountsPayable = [
|
||||
<T id={'manage_the_purchase_invoices_with_your_vendors'} />
|
||||
),
|
||||
link: '/bills',
|
||||
subject: AbilitySubject.Bill,
|
||||
ability: BillAction.View,
|
||||
},
|
||||
{
|
||||
title: <T id={'vendors'} />,
|
||||
@@ -53,11 +81,15 @@ export const accountsPayable = [
|
||||
<T id={'manage_the_vendors_relations_with_vendor_relations'} />
|
||||
),
|
||||
link: '/vendors',
|
||||
subject: AbilitySubject.Vendor,
|
||||
ability: VendorAction.View,
|
||||
},
|
||||
{
|
||||
title: <T id={'vendors_payments'} />,
|
||||
description: <T id={'manage_payments_transactions_to_your_vendors'} />,
|
||||
link: '/payment-mades',
|
||||
subject: AbilitySubject.PaymentMade,
|
||||
ability: PaymentMadeAction.View,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -77,21 +109,35 @@ export const financialAccounting = [
|
||||
/>
|
||||
),
|
||||
link: '/accounts',
|
||||
subject: AbilitySubject.Account,
|
||||
ability: AccountAction.View,
|
||||
},
|
||||
{
|
||||
title: <T id={'manual_journal'}/>,
|
||||
description:<T id={'manage_manual_journal_transactions_on_accounts'}/>,
|
||||
title: <T id={'manual_journal'} />,
|
||||
description: (
|
||||
<T id={'manage_manual_journal_transactions_on_accounts'} />
|
||||
),
|
||||
link: '/manual-journals',
|
||||
subject: AbilitySubject.ManualJournal,
|
||||
ability: ManualJournalAction.View,
|
||||
},
|
||||
{
|
||||
title: <T id={'expenses'}/>,
|
||||
description:<T id={'track_your_indirect_expenses_under_specific_categories'}/>,
|
||||
title: <T id={'expenses'} />,
|
||||
description: (
|
||||
<T id={'track_your_indirect_expenses_under_specific_categories'} />
|
||||
),
|
||||
link: '/expenses',
|
||||
subject: AbilitySubject.Expense,
|
||||
ability: ExpenseAction.View,
|
||||
},
|
||||
{
|
||||
title: <T id={'financial_statements'}/>,
|
||||
description:<T id={'show_financial_reports_about_your_organization'}/>,
|
||||
title: <T id={'financial_statements'} />,
|
||||
description: (
|
||||
<T id={'show_financial_reports_about_your_organization'} />
|
||||
),
|
||||
link: '/financial-reports',
|
||||
subject: AbilitySubject.Report,
|
||||
ability: ReportsAction.ALL,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -102,19 +148,27 @@ export const productsServices = [
|
||||
sectionTitle: <T id={'products_services_inventory'} />,
|
||||
shortcuts: [
|
||||
{
|
||||
title: <T id={'products_services'}/>,
|
||||
description:<T id={'manage_your_products_inventory_or_non_inventory'}/>,
|
||||
title: <T id={'products_services'} />,
|
||||
description: (
|
||||
<T id={'manage_your_products_inventory_or_non_inventory'} />
|
||||
),
|
||||
link: '/items',
|
||||
subject: AbilitySubject.Item,
|
||||
ability: ItemAction.View,
|
||||
},
|
||||
{
|
||||
title: <T id={'products_services_categories'}/>,
|
||||
description:<T id={'group_your_products_and_service'}/>,
|
||||
title: <T id={'products_services_categories'} />,
|
||||
description: <T id={'group_your_products_and_service'} />,
|
||||
link: 'items/categories',
|
||||
},
|
||||
{
|
||||
title: <T id={'inventory_adjustments'}/>,
|
||||
description: <T id={'manage_your_inventory_adjustment_of_inventory_items'}/>,
|
||||
title: <T id={'inventory_adjustments'} />,
|
||||
description: (
|
||||
<T id={'manage_your_inventory_adjustment_of_inventory_items'} />
|
||||
),
|
||||
link: '/inventory-adjustments',
|
||||
subject: AbilitySubject.InventoryAdjustment,
|
||||
ability: SaleInvoiceAction.View,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
3
src/common/index.js
Normal file
3
src/common/index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
export * from './TableStyle';
|
||||
|
||||
export const Align = { Left: 'left', Right: 'right', Center: 'center' };
|
||||
51
src/common/itemPaymentTranactionsOption.js
Normal file
51
src/common/itemPaymentTranactionsOption.js
Normal file
@@ -0,0 +1,51 @@
|
||||
import intl from 'react-intl-universal';
|
||||
import {
|
||||
AbilitySubject,
|
||||
SaleEstimateAction,
|
||||
SaleReceiptAction,
|
||||
SaleInvoiceAction,
|
||||
BillAction,
|
||||
} from '../common/abilityOption';
|
||||
import { useAbilitiesFilter } from '../hooks';
|
||||
|
||||
export const getItemPaymentTransactions = () => [
|
||||
{
|
||||
name: 'invoices',
|
||||
label: intl.get('invoices'),
|
||||
permission: {
|
||||
subject: AbilitySubject.Invoice,
|
||||
ability: SaleInvoiceAction.View,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'estimates',
|
||||
label: intl.get('estimates'),
|
||||
permission: {
|
||||
subject: AbilitySubject.Estimate,
|
||||
ability: SaleEstimateAction.View,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'receipts',
|
||||
label: intl.get('receipts'),
|
||||
permission: {
|
||||
subject: AbilitySubject.Receipt,
|
||||
ability: SaleReceiptAction.View,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'bills',
|
||||
label: intl.get('bills'),
|
||||
permission: {
|
||||
subject: AbilitySubject.Bill,
|
||||
ability: BillAction.View,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
export const useGetItemPaymentTransactionsMenu = () => {
|
||||
const itemTransactionMenu = getItemPaymentTransactions();
|
||||
const abilitiesFilter = useAbilitiesFilter();
|
||||
|
||||
return abilitiesFilter(itemTransactionMenu);
|
||||
};
|
||||
@@ -1,110 +1,228 @@
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import {
|
||||
AbilitySubject,
|
||||
AccountAction,
|
||||
BillAction,
|
||||
CashflowAction,
|
||||
CustomerAction,
|
||||
ExpenseAction,
|
||||
ItemAction,
|
||||
ManualJournalAction,
|
||||
ReportsAction,
|
||||
SaleEstimateAction,
|
||||
SaleInvoiceAction,
|
||||
SaleReceiptAction,
|
||||
VendorAction,
|
||||
} from './abilityOption';
|
||||
|
||||
export default [
|
||||
{
|
||||
shortcut_key: 'Shift + I',
|
||||
description: intl.get('jump_to_the_invoices'),
|
||||
permission: {
|
||||
ability: SaleInvoiceAction.View,
|
||||
subject: AbilitySubject.Invoice,
|
||||
},
|
||||
},
|
||||
{
|
||||
shortcut_key: 'Shift + E',
|
||||
description: intl.get('jump_to_the_estimates'),
|
||||
permission: {
|
||||
ability: SaleEstimateAction.View,
|
||||
subject: AbilitySubject.Estimate,
|
||||
},
|
||||
},
|
||||
{
|
||||
shortcut_key: 'Shift + R',
|
||||
description: intl.get('jump_to_the_receipts'),
|
||||
permission: {
|
||||
ability: SaleReceiptAction.View,
|
||||
subject: AbilitySubject.Receipt,
|
||||
},
|
||||
},
|
||||
{
|
||||
shortcut_key: 'Shift + X',
|
||||
description: intl.get('jump_to_the_expenses'),
|
||||
permission: {
|
||||
ability: ExpenseAction.View,
|
||||
subject: AbilitySubject.Expense,
|
||||
},
|
||||
},
|
||||
{
|
||||
shortcut_key: 'Shift + C',
|
||||
description: intl.get('jump_to_the_customers'),
|
||||
permission: {
|
||||
ability: CustomerAction.View,
|
||||
subject: AbilitySubject.Customer,
|
||||
},
|
||||
},
|
||||
{
|
||||
shortcut_key: 'Shift + V',
|
||||
description: intl.get('jump_to_the_vendors'),
|
||||
permission: {
|
||||
ability: VendorAction.View,
|
||||
subject: AbilitySubject.Vendor,
|
||||
},
|
||||
},
|
||||
{
|
||||
shortcut_key: 'Shift + A',
|
||||
description: intl.get('jump_to_the_chart_of_accounts'),
|
||||
permission: {
|
||||
ability: AccountAction.View,
|
||||
subject: AbilitySubject.Account,
|
||||
},
|
||||
},
|
||||
{
|
||||
shortcut_key: 'Shift + B',
|
||||
description: intl.get('jump_to_the_bills'),
|
||||
permission: {
|
||||
ability: BillAction.View,
|
||||
subject: AbilitySubject.Bill,
|
||||
},
|
||||
},
|
||||
{
|
||||
shortcut_key: 'Shift + M',
|
||||
description: intl.get('jump_to_the_manual_journals'),
|
||||
permission: {
|
||||
ability: ManualJournalAction.View,
|
||||
subject: AbilitySubject.ManualJournal,
|
||||
},
|
||||
},
|
||||
{
|
||||
shortcut_key: 'Shift + W',
|
||||
description: intl.get('jump_to_the_items'),
|
||||
permission: {
|
||||
ability: ItemAction.View,
|
||||
subject: AbilitySubject.Item,
|
||||
},
|
||||
},
|
||||
{
|
||||
shortcut_key: 'Shift + D',
|
||||
description: intl.get('jump_to_the_add_money_in'),
|
||||
permission: {
|
||||
ability: CashflowAction.Create,
|
||||
subject: AbilitySubject.Cashflow,
|
||||
},
|
||||
},
|
||||
{
|
||||
shortcut_key: 'Shift + Q',
|
||||
description: intl.get('jump_to_the_add_money_out'),
|
||||
permission: {
|
||||
ability: CashflowAction.Create,
|
||||
subject: AbilitySubject.Cashflow,
|
||||
},
|
||||
},
|
||||
{
|
||||
shortcut_key: 'Shift + 1',
|
||||
description: intl.get('jump_to_the_balance_sheet'),
|
||||
permission: {
|
||||
ability: ReportsAction.READ_BALANCE_SHEET,
|
||||
subject: AbilitySubject.Report,
|
||||
},
|
||||
},
|
||||
{
|
||||
shortcut_key: 'Shift + 2',
|
||||
description: intl.get('jump_to_the_profit_loss_sheet'),
|
||||
permission: {
|
||||
ability: ReportsAction.READ_PROFIT_LOSS,
|
||||
subject: AbilitySubject.Report,
|
||||
},
|
||||
},
|
||||
{
|
||||
shortcut_key: 'Shift + 3',
|
||||
description: intl.get('jump_to_the_journal_sheet'),
|
||||
permission: {
|
||||
ability: ReportsAction.READ_JOURNAL,
|
||||
subject: AbilitySubject.Report,
|
||||
},
|
||||
},
|
||||
{
|
||||
shortcut_key: 'Shift + 4',
|
||||
description: intl.get('jump_to_the_general_ledger_sheet'),
|
||||
permission: {
|
||||
ability: ReportsAction.READ_GENERAL_LEDGET,
|
||||
subject: AbilitySubject.Report,
|
||||
},
|
||||
},
|
||||
{
|
||||
shortcut_key: 'Shift + 5',
|
||||
description: intl.get('jump_to_the_trial_balance_sheet'),
|
||||
permission: {
|
||||
ability: ReportsAction.READ_TRIAL_BALANCE_SHEET,
|
||||
subject: AbilitySubject.Report,
|
||||
},
|
||||
},
|
||||
{
|
||||
shortcut_key: 'Ctrl + Shift + I ',
|
||||
description: intl.get('create_a_new_invoice'),
|
||||
permission: {
|
||||
ability: SaleInvoiceAction.Create,
|
||||
subject: AbilitySubject.Invoice,
|
||||
},
|
||||
},
|
||||
{
|
||||
shortcut_key: 'Ctrl + Shift + E ',
|
||||
description: intl.get('create_a_new_estimate'),
|
||||
permission: {
|
||||
ability: SaleEstimateAction.Create,
|
||||
subject: AbilitySubject.Estimate,
|
||||
},
|
||||
},
|
||||
{
|
||||
shortcut_key: 'Ctrl + Shift + R ',
|
||||
description: intl.get('create_a_new_receipt'),
|
||||
permission: {
|
||||
ability: SaleReceiptAction.Create,
|
||||
subject: AbilitySubject.Receipt,
|
||||
},
|
||||
},
|
||||
{
|
||||
shortcut_key: 'Ctrl + Shift + X ',
|
||||
description: intl.get('create_a_new_expense'),
|
||||
permission: {
|
||||
ability: ExpenseAction.Create,
|
||||
subject: AbilitySubject.Expense,
|
||||
},
|
||||
},
|
||||
{
|
||||
shortcut_key: 'Ctrl + Shift + C ',
|
||||
description: intl.get('create_a_new_customer'),
|
||||
permission: {
|
||||
ability: CustomerAction.Create,
|
||||
subject: AbilitySubject.Customer,
|
||||
},
|
||||
},
|
||||
{
|
||||
shortcut_key: 'Ctrl + Shift + V ',
|
||||
description: intl.get('create_a_new_vendor'),
|
||||
permission: {
|
||||
ability: VendorAction.Create,
|
||||
subject: AbilitySubject.Vendor,
|
||||
},
|
||||
},
|
||||
{
|
||||
shortcut_key: 'Ctrl + Shift + B ',
|
||||
description: intl.get('create_a_new_bill'),
|
||||
permission: {
|
||||
ability: BillAction.Create,
|
||||
subject: AbilitySubject.Bill,
|
||||
},
|
||||
},
|
||||
{
|
||||
shortcut_key: 'Ctrl + Shift + M ',
|
||||
description: intl.get('create_a_new_journal'),
|
||||
permission: {
|
||||
ability: ManualJournalAction.Create,
|
||||
subject: AbilitySubject.ManualJournal,
|
||||
},
|
||||
},
|
||||
{
|
||||
shortcut_key: 'Ctrl + Shift + W ',
|
||||
description: intl.get('create_a_new_item'),
|
||||
permission: {
|
||||
ability: ItemAction.Create,
|
||||
subject: AbilitySubject.Item,
|
||||
},
|
||||
},
|
||||
{
|
||||
shortcut_key: 'Ctrl + / ',
|
||||
|
||||
12
src/common/moreVertOptions.js
Normal file
12
src/common/moreVertOptions.js
Normal file
@@ -0,0 +1,12 @@
|
||||
import intl from 'react-intl-universal';
|
||||
|
||||
export const moreVertOptions = [
|
||||
{
|
||||
name: intl.get('bad_debt.dialog.bad_debt'),
|
||||
value: 'bad debt',
|
||||
},
|
||||
{
|
||||
name: intl.get('bad_debt.dialog.cancel_bad_debt'),
|
||||
value: 'cancel bad debt',
|
||||
},
|
||||
];
|
||||
659
src/common/permissionsSchema.js
Normal file
659
src/common/permissionsSchema.js
Normal file
@@ -0,0 +1,659 @@
|
||||
import { chain } from 'lodash';
|
||||
import intl from 'react-intl-universal';
|
||||
import {
|
||||
AbilitySubject,
|
||||
AccountAction,
|
||||
BillAction,
|
||||
CreditNoteAction,
|
||||
CustomerAction,
|
||||
ExpenseAction,
|
||||
ItemAction,
|
||||
ManualJournalAction,
|
||||
PaymentMadeAction,
|
||||
PaymentReceiveAction,
|
||||
ReportsAction,
|
||||
SaleEstimateAction,
|
||||
SaleInvoiceAction,
|
||||
SaleReceiptAction,
|
||||
VendorAction,
|
||||
VendorCreditAction,
|
||||
} from './abilityOption';
|
||||
|
||||
export const ModulePermissionsStyle = {
|
||||
Columns: 'columns',
|
||||
Vertical: 'vertical',
|
||||
};
|
||||
|
||||
const PermissionColumn = {
|
||||
View: 'view',
|
||||
Create: 'create',
|
||||
Delete: 'delete',
|
||||
Edit: 'edit',
|
||||
};
|
||||
|
||||
export const getPermissionsSchema = () => [
|
||||
{
|
||||
label: intl.get('permissions.items_inventory'),
|
||||
type: ModulePermissionsStyle.Columns,
|
||||
serviceFullAccess: true,
|
||||
columns: [
|
||||
{ label: intl.get('permissions.column.view'), key: 'view' },
|
||||
{ label: intl.get('permissions.column.create'), key: 'create' },
|
||||
{ label: intl.get('permissions.column.edit'), key: 'edit' },
|
||||
{ label: intl.get('permissions.column.delete'), key: 'delete' },
|
||||
],
|
||||
services: [
|
||||
{
|
||||
label: intl.get('permissions.items'),
|
||||
subject: AbilitySubject.Item,
|
||||
permissions: [
|
||||
{
|
||||
label: intl.get('permissions.column.view'),
|
||||
key: ItemAction.View,
|
||||
relatedColumn: PermissionColumn.View,
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.create'),
|
||||
key: ItemAction.Create,
|
||||
relatedColumn: PermissionColumn.Create,
|
||||
depend: [{ key: ItemAction.View }],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.edit'),
|
||||
key: ItemAction.Edit,
|
||||
relatedColumn: PermissionColumn.Edit,
|
||||
depend: [{ key: ItemAction.Create }],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.delete'),
|
||||
key: ItemAction.Delete,
|
||||
relatedColumn: PermissionColumn.Delete,
|
||||
depend: [{ key: ItemAction.Edit }],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.inventory_adjustment'),
|
||||
subject: AbilitySubject.InventoryAdjustment,
|
||||
permissions: [
|
||||
{
|
||||
label: 'View',
|
||||
key: ItemAction.View,
|
||||
relatedColumn: PermissionColumn.View,
|
||||
},
|
||||
{
|
||||
label: 'Create',
|
||||
key: ItemAction.Create,
|
||||
relatedColumn: PermissionColumn.Create,
|
||||
depend: [{ key: ItemAction.View }],
|
||||
},
|
||||
{
|
||||
label: 'Edit',
|
||||
key: ItemAction.Edit,
|
||||
relatedColumn: PermissionColumn.Edit,
|
||||
depend: [{ key: ItemAction.Create }],
|
||||
},
|
||||
{
|
||||
label: 'Delete',
|
||||
key: ItemAction.Delete,
|
||||
relatedColumn: PermissionColumn.Delete,
|
||||
depend: [{ key: ItemAction.Edit }],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.contacts'),
|
||||
type: ModulePermissionsStyle.Columns,
|
||||
serviceFullAccess: true,
|
||||
moduleFullAccess: true,
|
||||
columns: [
|
||||
{ label: intl.get('permissions.column.view'), key: 'view' },
|
||||
{ label: intl.get('permissions.column.create'), key: 'create' },
|
||||
{ label: intl.get('permissions.column.edit'), key: 'edit' },
|
||||
{ label: intl.get('permissions.column.delete'), key: 'delete' },
|
||||
],
|
||||
services: [
|
||||
{
|
||||
label: intl.get('permissions.customers'),
|
||||
subject: AbilitySubject.Customer,
|
||||
permissions: [
|
||||
{
|
||||
label: intl.get('permissions.column.view'),
|
||||
key: CustomerAction.View,
|
||||
relatedColumn: PermissionColumn.View,
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.create'),
|
||||
key: CustomerAction.Create,
|
||||
relatedColumn: PermissionColumn.Create,
|
||||
depend: [{ key: CustomerAction.View }],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.edit'),
|
||||
key: CustomerAction.Edit,
|
||||
relatedColumn: PermissionColumn.Edit,
|
||||
depend: [{ key: CustomerAction.Create }],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.delete'),
|
||||
key: CustomerAction.Delete,
|
||||
relatedColumn: PermissionColumn.Delete,
|
||||
depend: [{ key: CustomerAction.Edit }],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.vendors'),
|
||||
subject: AbilitySubject.Vendor,
|
||||
permissions: [
|
||||
{
|
||||
label: intl.get('permissions.column.view'),
|
||||
key: VendorAction.View,
|
||||
relatedColumn: PermissionColumn.View,
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.create'),
|
||||
key: VendorAction.Create,
|
||||
relatedColumn: PermissionColumn.Create,
|
||||
depend: [{ key: VendorAction.View }],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.edit'),
|
||||
key: VendorAction.Edit,
|
||||
relatedColumn: PermissionColumn.Edit,
|
||||
depend: [{ key: VendorAction.Create }],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.delete'),
|
||||
key: VendorAction.Delete,
|
||||
relatedColumn: PermissionColumn.Delete,
|
||||
depend: [{ key: VendorAction.Edit }],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.sales'),
|
||||
type: ModulePermissionsStyle.Columns,
|
||||
serviceFullAccess: true,
|
||||
moduleFullAccess: true,
|
||||
columns: [
|
||||
{ label: intl.get('permissions.column.view'), key: 'view' },
|
||||
{ label: intl.get('permissions.column.create'), key: 'create' },
|
||||
{ label: intl.get('permissions.column.edit'), key: 'edit' },
|
||||
{ label: intl.get('permissions.column.delete'), key: 'delete' },
|
||||
],
|
||||
services: [
|
||||
{
|
||||
label: intl.get('permissions.sale_invoice'),
|
||||
subject: AbilitySubject.Invoice,
|
||||
permissions: [
|
||||
{
|
||||
label: intl.get('permissions.column.view'),
|
||||
key: SaleInvoiceAction.View,
|
||||
relatedColumn: PermissionColumn.View,
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.create'),
|
||||
key: SaleInvoiceAction.Create,
|
||||
relatedColumn: PermissionColumn.Create,
|
||||
depend: [{ key: SaleInvoiceAction.View }],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.edit'),
|
||||
key: SaleInvoiceAction.Edit,
|
||||
relatedColumn: PermissionColumn.Edit,
|
||||
depend: [{ key: SaleInvoiceAction.Create }],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.delete'),
|
||||
key: SaleInvoiceAction.Delete,
|
||||
relatedColumn: PermissionColumn.Delete,
|
||||
depend: [{ key: SaleInvoiceAction.Edit }],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.written_off_invoice'),
|
||||
key: SaleInvoiceAction.Writeoff,
|
||||
depend: [{ key: SaleInvoiceAction.Edit }],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.sale_estimate'),
|
||||
subject: AbilitySubject.Estimate,
|
||||
permissions: [
|
||||
{
|
||||
label: intl.get('permissions.column.view'),
|
||||
key: SaleEstimateAction.View,
|
||||
relatedColumn: PermissionColumn.View,
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.create'),
|
||||
key: SaleEstimateAction.Create,
|
||||
relatedColumn: PermissionColumn.Create,
|
||||
depend: [{ key: SaleEstimateAction.View }],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.edit'),
|
||||
key: SaleEstimateAction.Edit,
|
||||
relatedColumn: PermissionColumn.Edit,
|
||||
depend: [{ key: SaleEstimateAction.Create }],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.delete'),
|
||||
key: SaleEstimateAction.Delete,
|
||||
relatedColumn: PermissionColumn.Delete,
|
||||
depend: [{ key: SaleEstimateAction.Edit }],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.sale_receipt'),
|
||||
subject: AbilitySubject.Receipt,
|
||||
permissions: [
|
||||
{
|
||||
label: intl.get('permissions.column.view'),
|
||||
key: SaleReceiptAction.View,
|
||||
relatedColumn: PermissionColumn.View,
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.create'),
|
||||
key: SaleReceiptAction.Create,
|
||||
relatedColumn: PermissionColumn.Create,
|
||||
depend: [{ key: SaleReceiptAction.View }],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.edit'),
|
||||
key: SaleReceiptAction.Edit,
|
||||
relatedColumn: PermissionColumn.Edit,
|
||||
depend: [{ key: SaleReceiptAction.Create }],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.delete'),
|
||||
key: SaleReceiptAction.Delete,
|
||||
relatedColumn: PermissionColumn.Delete,
|
||||
depend: [{ key: SaleReceiptAction.Edit }],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.credit_note'),
|
||||
subject: AbilitySubject.CreditNote,
|
||||
permissions: [
|
||||
{
|
||||
label: intl.get('permissions.column.view'),
|
||||
key: CreditNoteAction.View,
|
||||
relatedColumn: PermissionColumn.View,
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.create'),
|
||||
key: CreditNoteAction.Create,
|
||||
relatedColumn: PermissionColumn.Create,
|
||||
depend: [{ key: CreditNoteAction.View }],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.edit'),
|
||||
key: CreditNoteAction.Edit,
|
||||
relatedColumn: PermissionColumn.Edit,
|
||||
depend: [{ key: CreditNoteAction.Create }],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.delete'),
|
||||
key: CreditNoteAction.Delete,
|
||||
relatedColumn: PermissionColumn.Delete,
|
||||
depend: [{ key: CreditNoteAction.Edit }],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.refund_credit_note'),
|
||||
key: CreditNoteAction.Refund,
|
||||
depend: [{ key: CreditNoteAction.View }],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.payment_receive'),
|
||||
subject: AbilitySubject.PaymentReceive,
|
||||
permissions: [
|
||||
{
|
||||
label: intl.get('permissions.column.view'),
|
||||
key: PaymentReceiveAction.View,
|
||||
relatedColumn: PermissionColumn.View,
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.create'),
|
||||
key: PaymentReceiveAction.Create,
|
||||
relatedColumn: PermissionColumn.Create,
|
||||
depend: [{ key: PaymentReceiveAction.View }],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.edit'),
|
||||
key: PaymentReceiveAction.Edit,
|
||||
relatedColumn: PermissionColumn.Edit,
|
||||
depend: [{ key: PaymentReceiveAction.Create }],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.delete'),
|
||||
key: PaymentReceiveAction.Delete,
|
||||
relatedColumn: PermissionColumn.Delete,
|
||||
depend: [{ key: PaymentReceiveAction.Edit }],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.purchases'),
|
||||
type: ModulePermissionsStyle.Columns,
|
||||
serviceFullAccess: true,
|
||||
moduleFullAccess: true,
|
||||
columns: [
|
||||
{ label: intl.get('permissions.column.view'), key: 'view' },
|
||||
{ label: intl.get('permissions.column.create'), key: 'create' },
|
||||
{ label: intl.get('permissions.column.edit'), key: 'edit' },
|
||||
{ label: intl.get('permissions.column.delete'), key: 'delete' },
|
||||
],
|
||||
services: [
|
||||
{
|
||||
label: intl.get('permissions.bills'),
|
||||
subject: AbilitySubject.Bill,
|
||||
permissions: [
|
||||
{
|
||||
label: intl.get('permissions.column.view'),
|
||||
key: BillAction.View,
|
||||
relatedColumn: PermissionColumn.View,
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.create'),
|
||||
key: BillAction.Create,
|
||||
relatedColumn: PermissionColumn.Create,
|
||||
depend: [{ key: BillAction.View }],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.edit'),
|
||||
key: BillAction.Edit,
|
||||
relatedColumn: PermissionColumn.Edit,
|
||||
depend: [{ key: BillAction.Create }],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.delete'),
|
||||
key: BillAction.Delete,
|
||||
relatedColumn: PermissionColumn.Delete,
|
||||
depend: [{ key: BillAction.Edit }],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.vendor_credits'),
|
||||
subject: AbilitySubject.VendorCredit,
|
||||
permissions: [
|
||||
{
|
||||
label: intl.get('permissions.column.view'),
|
||||
key: VendorCreditAction.View,
|
||||
relatedColumn: PermissionColumn.View,
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.create'),
|
||||
key: VendorCreditAction.Create,
|
||||
relatedColumn: PermissionColumn.Create,
|
||||
depend: [{ key: VendorCreditAction.View }],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.edit'),
|
||||
key: VendorCreditAction.Edit,
|
||||
relatedColumn: PermissionColumn.Edit,
|
||||
depend: [{ key: VendorCreditAction.Create }],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.delete'),
|
||||
key: VendorCreditAction.Delete,
|
||||
relatedColumn: PermissionColumn.Delete,
|
||||
depend: [{ key: VendorCreditAction.Edit }],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.refund_vendor_credit'),
|
||||
key: VendorCreditAction.Refund,
|
||||
depend: [{ key: VendorCreditAction.View }],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.payment_made'),
|
||||
subject: AbilitySubject.PaymentMade,
|
||||
permissions: [
|
||||
{
|
||||
label: intl.get('permissions.column.view'),
|
||||
key: PaymentMadeAction.View,
|
||||
relatedColumn: PermissionColumn.View,
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.create'),
|
||||
key: PaymentMadeAction.Create,
|
||||
relatedColumn: PermissionColumn.Create,
|
||||
depend: [{ key: PaymentMadeAction.View }],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.edit'),
|
||||
key: PaymentMadeAction.Edit,
|
||||
relatedColumn: PermissionColumn.Edit,
|
||||
depend: [{ key: PaymentMadeAction.Create }],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.delete'),
|
||||
key: PaymentMadeAction.Delete,
|
||||
relatedColumn: PermissionColumn.Delete,
|
||||
depend: [{ key: PaymentMadeAction.Edit }],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.financial_accounting'),
|
||||
type: ModulePermissionsStyle.Columns,
|
||||
serviceFullAccess: true,
|
||||
moduleFullAccess: true,
|
||||
columns: [
|
||||
{ label: intl.get('permissions.column.view'), key: 'view' },
|
||||
{ label: intl.get('permissions.column.create'), key: 'create' },
|
||||
{ label: intl.get('permissions.column.edit'), key: 'edit' },
|
||||
{ label: intl.get('permissions.column.delete'), key: 'delete' },
|
||||
],
|
||||
services: [
|
||||
{
|
||||
label: intl.get('permissions.manual_journals'),
|
||||
subject: AbilitySubject.ManualJournal,
|
||||
permissions: [
|
||||
{
|
||||
label: intl.get('permissions.column.view'),
|
||||
key: ManualJournalAction.View,
|
||||
relatedColumn: PermissionColumn.View,
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.create'),
|
||||
key: ManualJournalAction.Create,
|
||||
relatedColumn: PermissionColumn.Create,
|
||||
depend: [{ key: ManualJournalAction.View }],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.edit'),
|
||||
key: ManualJournalAction.Edit,
|
||||
relatedColumn: PermissionColumn.Edit,
|
||||
depend: [{ key: ManualJournalAction.Create }],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.delete'),
|
||||
key: ManualJournalAction.Delete,
|
||||
relatedColumn: PermissionColumn.Delete,
|
||||
depend: [{ key: ManualJournalAction.Edit }],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.chart_of_accounts'),
|
||||
subject: AbilitySubject.Account,
|
||||
permissions: [
|
||||
{
|
||||
label: intl.get('permissions.column.view'),
|
||||
key: AccountAction.View,
|
||||
relatedColumn: PermissionColumn.View,
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.create'),
|
||||
key: AccountAction.Create,
|
||||
relatedColumn: PermissionColumn.Create,
|
||||
depend: [{ key: AccountAction.View }],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.edit'),
|
||||
key: AccountAction.Edit,
|
||||
relatedColumn: PermissionColumn.Edit,
|
||||
depend: [{ key: AccountAction.Create }],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.delete'),
|
||||
key: AccountAction.Delete,
|
||||
relatedColumn: PermissionColumn.Delete,
|
||||
depend: [{ key: AccountAction.Edit }],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.transactions_locking'),
|
||||
key: AccountAction.TransactionsLocking,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.expenses'),
|
||||
subject: AbilitySubject.Expense,
|
||||
permissions: [
|
||||
{
|
||||
label: intl.get('permissions.column.view'),
|
||||
key: ExpenseAction.View,
|
||||
relatedColumn: PermissionColumn.View,
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.create'),
|
||||
key: ExpenseAction.Create,
|
||||
relatedColumn: PermissionColumn.Create,
|
||||
depend: [{ key: ExpenseAction.View }],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.edit'),
|
||||
key: ExpenseAction.Edit,
|
||||
relatedColumn: PermissionColumn.Edit,
|
||||
depend: [{ key: ExpenseAction.Create }],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.column.delete'),
|
||||
key: ExpenseAction.Delete,
|
||||
relatedColumn: PermissionColumn.Delete,
|
||||
depend: [{ key: ExpenseAction.Edit }],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.reports'),
|
||||
type: ModulePermissionsStyle.Vertical,
|
||||
serviceFullAccess: true,
|
||||
moduleFullAccess: true,
|
||||
services: [
|
||||
{
|
||||
label: intl.get('permissions.financial_reports'),
|
||||
subject: AbilitySubject.Report,
|
||||
permissions: [
|
||||
{
|
||||
label: intl.get('permissions.balance_sheet'),
|
||||
key: ReportsAction.READ_BALANCE_SHEET,
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.trial_balance_sheet'),
|
||||
key: ReportsAction.READ_TRIAL_BALANCE_SHEET,
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.profit_loss_sheet'),
|
||||
key: ReportsAction.READ_PROFIT_LOSS,
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.cash_flow_sheet'),
|
||||
key: ReportsAction.READ_CASHFLOW,
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.journal_sheet'),
|
||||
key: ReportsAction.READ_JOURNAL,
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.general_ledger'),
|
||||
key: ReportsAction.READ_GENERAL_LEDGET,
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.a_r_aging_summary_report'),
|
||||
key: ReportsAction.READ_AR_AGING_SUMMARY,
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.a_r_aging_summary_report'),
|
||||
key: ReportsAction.READ_AP_AGING_SUMMARY,
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.purchases_by_items'),
|
||||
key: ReportsAction.READ_PURCHASES_BY_ITEMS,
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.sales_by_items'),
|
||||
key: ReportsAction.READ_SALES_BY_ITEMS,
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.customers_transactions'),
|
||||
key: ReportsAction.READ_CUSTOMERS_TRANSACTIONS,
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.vendors_transactions'),
|
||||
key: ReportsAction.READ_VENDORS_TRANSACTIONS,
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.customers_summary_balance'),
|
||||
key: ReportsAction.READ_CUSTOMERS_SUMMARY_BALANCE,
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.vendors_summary_balance'),
|
||||
key: ReportsAction.READ_VENDORS_SUMMARY_BALANCE,
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.inventory_valuation_summary'),
|
||||
key: ReportsAction.READ_INVENTORY_VALUATION_SUMMARY,
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.inventory_items_details'),
|
||||
key: ReportsAction.READ_INVENTORY_ITEM_DETAILS,
|
||||
},
|
||||
{
|
||||
label: intl.get('permissions.cashflow_account_transactions'),
|
||||
key: ReportsAction.READ_CASHFLOW_ACCOUNT_TRANSACTION,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
export function getPermissionsSchemaService(subject) {
|
||||
const permissions = getPermissionsSchema();
|
||||
|
||||
return chain(permissions)
|
||||
.map((perm) => perm.services)
|
||||
.flatten()
|
||||
.find((service) => service.subject === subject)
|
||||
.value();
|
||||
}
|
||||
|
||||
export function getPermissionsSchemaServices() {
|
||||
const permissions = getPermissionsSchema();
|
||||
|
||||
return chain(permissions)
|
||||
.map((module) => module.services)
|
||||
.flatten()
|
||||
.value();
|
||||
}
|
||||
@@ -1,10 +1,71 @@
|
||||
import intl from 'react-intl-universal';
|
||||
import {
|
||||
AbilitySubject,
|
||||
SaleInvoiceAction,
|
||||
CustomerAction,
|
||||
VendorAction,
|
||||
ManualJournalAction,
|
||||
ExpenseAction,
|
||||
} from '../common/abilityOption';
|
||||
import { useAbilitiesFilter } from '../hooks';
|
||||
|
||||
export const getQuickNewActions = () => [
|
||||
{ path: 'invoices/new', name: intl.get('sale_invoice') },
|
||||
{ path: 'bills/new', name: intl.get('purchase_invoice') },
|
||||
{ path: 'make-journal-entry', name: intl.get('manual_journal') },
|
||||
{ path: 'expenses/new', name: intl.get('expense') },
|
||||
{ path: 'customers/new', name: intl.get('customer') },
|
||||
{ path: 'vendors/new', name: intl.get('vendor') },
|
||||
{
|
||||
path: 'invoices/new',
|
||||
name: intl.get('sale_invoice'),
|
||||
permission: {
|
||||
subject: AbilitySubject.Invoice,
|
||||
ability: SaleInvoiceAction.Create,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'bills/new',
|
||||
name: intl.get('purchase_invoice'),
|
||||
permission: {
|
||||
subject: AbilitySubject.Invoice,
|
||||
ability: SaleInvoiceAction.Create,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'make-journal-entry',
|
||||
name: intl.get('manual_journal'),
|
||||
permission: {
|
||||
subject: AbilitySubject.ManualJournal,
|
||||
ability: ManualJournalAction.Create,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'expenses/new',
|
||||
name: intl.get('expense'),
|
||||
permission: {
|
||||
subject: AbilitySubject.Expense,
|
||||
ability: ExpenseAction.Create,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'customers/new',
|
||||
name: intl.get('customer'),
|
||||
permission: {
|
||||
subject: AbilitySubject.Customer,
|
||||
ability: CustomerAction.Create,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'vendors/new',
|
||||
name: intl.get('vendor'),
|
||||
permission: {
|
||||
subject: AbilitySubject.Vendor,
|
||||
ability: VendorAction.Vendor,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* Retrieve the dashboard quick new menu items.
|
||||
*/
|
||||
export const useGetQuickNewMenu = () => {
|
||||
const quickNewMenu = getQuickNewActions();
|
||||
const abilitiesFilter = useAbilitiesFilter();
|
||||
|
||||
return abilitiesFilter(quickNewMenu);
|
||||
};
|
||||
|
||||
@@ -11,4 +11,6 @@ export const RESOURCES_TYPES = {
|
||||
EXPENSE: 'expense',
|
||||
MANUAL_JOURNAL: 'manual_journal',
|
||||
ACCOUNT: 'account',
|
||||
CREDIT_NOTE: 'credit_note',
|
||||
VENDOR_CREDIT:'vendor_credit'
|
||||
};
|
||||
|
||||
@@ -14,6 +14,8 @@ export const TABLES = {
|
||||
EXPENSES: 'expenses',
|
||||
CASHFLOW_ACCOUNTS: 'cashflow_accounts',
|
||||
CASHFLOW_Transactions: 'cashflow_transactions',
|
||||
CREDIT_NOTES: 'credit_notes',
|
||||
VENDOR_CREDITS: 'vendor_credits',
|
||||
};
|
||||
|
||||
export const TABLE_SIZE = {
|
||||
|
||||
@@ -1,13 +1,56 @@
|
||||
import React, { useCallback, useState, useEffect, useMemo } from 'react';
|
||||
import { MenuItem, Button } from '@blueprintjs/core';
|
||||
import { Select } from '@blueprintjs/select';
|
||||
import { MenuItemNestedText, FormattedMessage as T } from 'components';
|
||||
import * as R from 'ramda';
|
||||
import classNames from 'classnames';
|
||||
import intl from 'react-intl-universal'
|
||||
|
||||
import { MenuItemNestedText, FormattedMessage as T } from 'components';
|
||||
import { filterAccountsByQuery } from './utils';
|
||||
import { nestedArrayToflatten } from 'utils';
|
||||
import { CLASSES } from 'common/classes';
|
||||
|
||||
export default function AccountsSelectList({
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
|
||||
// Create new account renderer.
|
||||
const createNewItemRenderer = (query, active, handleClick) => {
|
||||
return (
|
||||
<MenuItem
|
||||
icon="add"
|
||||
text={intl.get('list.create', { value: `"${query}"` })}
|
||||
active={active}
|
||||
onClick={handleClick}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
// Create new item from the given query string.
|
||||
const createNewItemFromQuery = (name) => {
|
||||
return {
|
||||
name,
|
||||
};
|
||||
};
|
||||
|
||||
// Filters accounts items.
|
||||
const filterAccountsPredicater = (query, account, _index, exactMatch) => {
|
||||
const normalizedTitle = account.name.toLowerCase();
|
||||
const normalizedQuery = query.toLowerCase();
|
||||
|
||||
if (exactMatch) {
|
||||
return normalizedTitle === normalizedQuery;
|
||||
} else {
|
||||
return `${account.code} ${normalizedTitle}`.indexOf(normalizedQuery) >= 0;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Accounts select list.
|
||||
*/
|
||||
function AccountsSelectList({
|
||||
// #withDialogActions
|
||||
openDialog,
|
||||
|
||||
// #ownProps
|
||||
accounts,
|
||||
initialAccountId,
|
||||
selectedAccountId,
|
||||
@@ -21,6 +64,8 @@ export default function AccountsSelectList({
|
||||
filterByNormal,
|
||||
filterByRootTypes,
|
||||
|
||||
allowCreate,
|
||||
|
||||
buttonProps = {},
|
||||
}) {
|
||||
const flattenAccounts = useMemo(
|
||||
@@ -51,6 +96,7 @@ export default function AccountsSelectList({
|
||||
[initialAccountId, filteredAccounts],
|
||||
);
|
||||
|
||||
// Select account item.
|
||||
const [selectedAccount, setSelectedAccount] = useState(
|
||||
initialAccount || null,
|
||||
);
|
||||
@@ -76,31 +122,25 @@ export default function AccountsSelectList({
|
||||
);
|
||||
}, []);
|
||||
|
||||
const onAccountSelect = useCallback(
|
||||
// Handle the account item select.
|
||||
const handleAccountSelect = useCallback(
|
||||
(account) => {
|
||||
setSelectedAccount({ ...account });
|
||||
onAccountSelected && onAccountSelected(account);
|
||||
},
|
||||
[setSelectedAccount, onAccountSelected],
|
||||
);
|
||||
|
||||
// Filters accounts items.
|
||||
const filterAccountsPredicater = useCallback(
|
||||
(query, account, _index, exactMatch) => {
|
||||
const normalizedTitle = account.name.toLowerCase();
|
||||
const normalizedQuery = query.toLowerCase();
|
||||
|
||||
if (exactMatch) {
|
||||
return normalizedTitle === normalizedQuery;
|
||||
if (account.id) {
|
||||
setSelectedAccount({ ...account });
|
||||
onAccountSelected && onAccountSelected(account);
|
||||
} else {
|
||||
return (
|
||||
`${account.code} ${normalizedTitle}`.indexOf(normalizedQuery) >= 0
|
||||
);
|
||||
openDialog('account-form');
|
||||
}
|
||||
},
|
||||
[],
|
||||
[setSelectedAccount, onAccountSelected, openDialog],
|
||||
);
|
||||
|
||||
// Maybe inject new item props to select component.
|
||||
const maybeCreateNewItemRenderer = allowCreate ? createNewItemRenderer : null;
|
||||
const maybeCreateNewItemFromQuery = allowCreate
|
||||
? createNewItemFromQuery
|
||||
: null;
|
||||
|
||||
return (
|
||||
<Select
|
||||
items={filteredAccounts}
|
||||
@@ -113,11 +153,13 @@ export default function AccountsSelectList({
|
||||
inline: popoverFill,
|
||||
}}
|
||||
filterable={true}
|
||||
onItemSelect={onAccountSelect}
|
||||
onItemSelect={handleAccountSelect}
|
||||
disabled={disabled}
|
||||
className={classNames('form-group--select-list', {
|
||||
[CLASSES.SELECT_LIST_FILL_POPOVER]: popoverFill,
|
||||
})}
|
||||
createNewItemRenderer={maybeCreateNewItemRenderer}
|
||||
createNewItemFromQuery={maybeCreateNewItemFromQuery}
|
||||
>
|
||||
<Button
|
||||
disabled={disabled}
|
||||
@@ -127,3 +169,5 @@ export default function AccountsSelectList({
|
||||
</Select>
|
||||
);
|
||||
}
|
||||
|
||||
export default R.compose(withDialogActions)(AccountsSelectList);
|
||||
|
||||
@@ -2,6 +2,7 @@ import React, { useState, useCallback, useEffect, useMemo } from 'react';
|
||||
import { MenuItem } from '@blueprintjs/core';
|
||||
import { Suggest } from '@blueprintjs/select';
|
||||
import intl from 'react-intl-universal';
|
||||
import * as R from 'ramda';
|
||||
|
||||
import classNames from 'classnames';
|
||||
import { CLASSES } from 'common/classes';
|
||||
@@ -10,10 +11,55 @@ import { MenuItemNestedText, FormattedMessage as T } from 'components';
|
||||
import { filterAccountsByQuery } from './utils';
|
||||
import { nestedArrayToflatten } from 'utils';
|
||||
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
|
||||
// Create new account renderer.
|
||||
const createNewItemRenderer = (query, active, handleClick) => {
|
||||
return (
|
||||
<MenuItem
|
||||
icon="add"
|
||||
text={intl.get('list.create', { value: `"${query}"` })}
|
||||
active={active}
|
||||
onClick={handleClick}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
// Create new item from the given query string.
|
||||
const createNewItemFromQuery = (name) => {
|
||||
return {
|
||||
name,
|
||||
};
|
||||
};
|
||||
|
||||
// Handle input value renderer.
|
||||
const handleInputValueRenderer = (inputValue) => {
|
||||
if (inputValue) {
|
||||
return inputValue.name.toString();
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
// Filters accounts items.
|
||||
const filterAccountsPredicater = (query, account, _index, exactMatch) => {
|
||||
const normalizedTitle = account.name.toLowerCase();
|
||||
const normalizedQuery = query.toLowerCase();
|
||||
|
||||
if (exactMatch) {
|
||||
return normalizedTitle === normalizedQuery;
|
||||
} else {
|
||||
return `${account.code} ${normalizedTitle}`.indexOf(normalizedQuery) >= 0;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Accounts suggest field.
|
||||
*/
|
||||
export default function AccountsSuggestField({
|
||||
function AccountsSuggestField({
|
||||
// #withDialogActions
|
||||
openDialog,
|
||||
|
||||
// #ownProps
|
||||
accounts,
|
||||
initialAccountId,
|
||||
selectedAccountId,
|
||||
@@ -26,6 +72,8 @@ export default function AccountsSuggestField({
|
||||
filterByNormal,
|
||||
filterByRootTypes = [],
|
||||
|
||||
allowCreate,
|
||||
|
||||
...suggestProps
|
||||
}) {
|
||||
const flattenAccounts = useMemo(
|
||||
@@ -69,23 +117,6 @@ export default function AccountsSuggestField({
|
||||
}
|
||||
}, [selectedAccountId, filteredAccounts, setSelectedAccount]);
|
||||
|
||||
// Filters accounts items.
|
||||
const filterAccountsPredicater = useCallback(
|
||||
(query, account, _index, exactMatch) => {
|
||||
const normalizedTitle = account.name.toLowerCase();
|
||||
const normalizedQuery = query.toLowerCase();
|
||||
|
||||
if (exactMatch) {
|
||||
return normalizedTitle === normalizedQuery;
|
||||
} else {
|
||||
return (
|
||||
`${account.code} ${normalizedTitle}`.indexOf(normalizedQuery) >= 0
|
||||
);
|
||||
}
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
||||
// Account item of select accounts field.
|
||||
const accountItem = useCallback((item, { handleClick, modifiers, query }) => {
|
||||
return (
|
||||
@@ -98,28 +129,31 @@ export default function AccountsSuggestField({
|
||||
);
|
||||
}, []);
|
||||
|
||||
const handleInputValueRenderer = (inputValue) => {
|
||||
if (inputValue) {
|
||||
return inputValue.name.toString();
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
const onAccountSelect = useCallback(
|
||||
const handleAccountSelect = useCallback(
|
||||
(account) => {
|
||||
setSelectedAccount({ ...account });
|
||||
onAccountSelected && onAccountSelected(account);
|
||||
if (account.id) {
|
||||
setSelectedAccount({ ...account });
|
||||
onAccountSelected && onAccountSelected(account);
|
||||
} else {
|
||||
openDialog('account-form');
|
||||
}
|
||||
},
|
||||
[setSelectedAccount, onAccountSelected],
|
||||
[setSelectedAccount, onAccountSelected, openDialog],
|
||||
);
|
||||
|
||||
// Maybe inject new item props to select component.
|
||||
const maybeCreateNewItemRenderer = allowCreate ? createNewItemRenderer : null;
|
||||
const maybeCreateNewItemFromQuery = allowCreate
|
||||
? createNewItemFromQuery
|
||||
: null;
|
||||
|
||||
return (
|
||||
<Suggest
|
||||
items={filteredAccounts}
|
||||
noResults={<MenuItem disabled={true} text={<T id={'no_accounts'} />} />}
|
||||
itemRenderer={accountItem}
|
||||
itemPredicate={filterAccountsPredicater}
|
||||
onItemSelect={onAccountSelect}
|
||||
onItemSelect={handleAccountSelect}
|
||||
selectedItem={selectedAccount}
|
||||
inputProps={{ placeholder: defaultSelectText }}
|
||||
resetOnClose={true}
|
||||
@@ -129,7 +163,11 @@ export default function AccountsSuggestField({
|
||||
className={classNames(CLASSES.FORM_GROUP_LIST_SELECT, {
|
||||
[CLASSES.SELECT_LIST_FILL_POPOVER]: popoverFill,
|
||||
})}
|
||||
createNewItemRenderer={maybeCreateNewItemRenderer}
|
||||
createNewItemFromQuery={maybeCreateNewItemFromQuery}
|
||||
{...suggestProps}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export default R.compose(withDialogActions)(AccountsSuggestField);
|
||||
|
||||
@@ -1,17 +1,60 @@
|
||||
import React from 'react';
|
||||
import clsx from 'classnames';
|
||||
import styled from 'styled-components';
|
||||
|
||||
import Style from './style.module.scss';
|
||||
|
||||
export function Alert({ title, description, intent }) {
|
||||
export function Alert({ title, description, children, intent, className }) {
|
||||
return (
|
||||
<div
|
||||
className={clsx(Style.root, {
|
||||
[`${Style['root_' + intent]}`]: intent,
|
||||
})}
|
||||
>
|
||||
{title && <h3 className={clsx(Style.title)}>{title}</h3>}
|
||||
{description && <p class={clsx(Style.description)}>{description}</p>}
|
||||
</div>
|
||||
<AlertRoot className={clsx(className)} intent={intent}>
|
||||
{title && <AlertTitle>{title}</AlertTitle>}
|
||||
{description && <AlertDesc>{description}</AlertDesc>}
|
||||
{children && <AlertDesc>{children}</AlertDesc>}
|
||||
</AlertRoot>
|
||||
);
|
||||
}
|
||||
|
||||
const AlertRoot = styled.div`
|
||||
border: 1px solid rgb(223, 227, 230);
|
||||
padding: 12px;
|
||||
border-radius: 6px;
|
||||
margin-bottom: 20px;
|
||||
|
||||
${(props) =>
|
||||
props.intent === 'danger' &&
|
||||
`
|
||||
border-color: rgb(249, 198, 198);
|
||||
background: rgb(255, 248, 248);
|
||||
|
||||
${AlertDesc} {
|
||||
color: #d95759;
|
||||
}
|
||||
${AlertTitle} {
|
||||
color: rgb(205, 43, 49);
|
||||
}
|
||||
`}
|
||||
|
||||
${(props) =>
|
||||
props.intent === 'primary' &&
|
||||
`
|
||||
background: #fff;
|
||||
border-color: #98a8ee;
|
||||
|
||||
${AlertTitle} {
|
||||
color: #1a3bd4;
|
||||
}
|
||||
${AlertDesc} {
|
||||
color: #455883;
|
||||
}
|
||||
`}
|
||||
`;
|
||||
|
||||
export const AlertTitle = styled.h3`
|
||||
color: rgb(17, 24, 28);
|
||||
margin-bottom: 4px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
`;
|
||||
|
||||
export const AlertDesc = styled.p`
|
||||
color: rgb(104, 112, 118);
|
||||
margin: 0;
|
||||
`;
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
.root {
|
||||
border: 1px solid rgb(223, 227, 230);
|
||||
padding: 12px;
|
||||
border-radius: 6px;
|
||||
margin-bottom: 20px;
|
||||
|
||||
&_danger {
|
||||
border-color: rgb(249, 198, 198);
|
||||
background: rgb(255, 248, 248);
|
||||
|
||||
.description {
|
||||
color: #d95759;
|
||||
}
|
||||
|
||||
.title {
|
||||
color: rgb(205, 43, 49);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.title {
|
||||
color: rgb(17, 24, 28);
|
||||
margin-bottom: 4px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.description {
|
||||
color: rgb(104, 112, 118);
|
||||
margin: 0;
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import styled from 'styled-components';
|
||||
import { Classes } from '@blueprintjs/core';
|
||||
import clsx from 'classnames';
|
||||
import Icon from '../Icon';
|
||||
import { whenRtl, whenLtr } from 'utils/styled-components';
|
||||
|
||||
const ACCOUNT_TYPE = {
|
||||
CASH: 'cash',
|
||||
@@ -185,9 +184,7 @@ const MetaLineValue = styled.div`
|
||||
text-align: center;
|
||||
color: rgb(23, 43, 77);
|
||||
font-size: 11px;
|
||||
|
||||
${whenLtr(`margin-left: auto;`)}
|
||||
${whenRtl(`margin-right: auto;`)}
|
||||
margin-left: auto;
|
||||
`;
|
||||
|
||||
const BankAccountMeta = styled.div`
|
||||
@@ -204,7 +201,5 @@ const AccountIconWrap = styled.div`
|
||||
position: absolute;
|
||||
top: 14px;
|
||||
color: #abb3bb;
|
||||
|
||||
${whenLtr(`right: 12px;`)}
|
||||
${whenRtl(`left: 12px;`)}
|
||||
right: 12px;
|
||||
`;
|
||||
|
||||
@@ -1,23 +1,14 @@
|
||||
import styled from 'styled-components';
|
||||
import { Button } from '@blueprintjs/core';
|
||||
|
||||
export const ButtonLink = styled(Button)`
|
||||
line-height: inherit;
|
||||
export const ButtonLink = styled.button`
|
||||
color: #0052cc;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
text-align: inherit;
|
||||
|
||||
&.bp3-small {
|
||||
min-height: auto;
|
||||
min-width: auto;
|
||||
padding: 0;
|
||||
}
|
||||
&:not([class*='bp3-intent-']) {
|
||||
&,
|
||||
&:hover {
|
||||
color: #0052cc;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
&:hover,
|
||||
&:active {
|
||||
text-decoration: underline;
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -1,3 +1 @@
|
||||
|
||||
|
||||
export * from './ButtonLink';
|
||||
@@ -1,6 +0,0 @@
|
||||
import React from 'react';
|
||||
import classNames from 'classnames';
|
||||
|
||||
export default function Card({ className, children }) {
|
||||
return <div className={classNames('card', className)}>{children}</div>;
|
||||
}
|
||||
27
src/components/Card/index.js
Normal file
27
src/components/Card/index.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
|
||||
export function Card({ className, children }) {
|
||||
return <CardRoot className={className}>{children}</CardRoot>;
|
||||
}
|
||||
|
||||
const CardRoot = styled.div`
|
||||
padding: 15px;
|
||||
margin: 15px;
|
||||
background: #fff;
|
||||
border: 1px solid #d2dce2;
|
||||
`;
|
||||
|
||||
export const CardFooterActions = styled.div`
|
||||
padding-top: 16px;
|
||||
border-top: 1px solid #e0e7ea;
|
||||
margin-top: 30px;
|
||||
|
||||
.bp3-button {
|
||||
min-width: 70px;
|
||||
|
||||
+ .bp3-button {
|
||||
margin-left: 10px;
|
||||
}
|
||||
}
|
||||
`;
|
||||
25
src/components/CommercialDoc/index.js
Normal file
25
src/components/CommercialDoc/index.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import styled from 'styled-components';
|
||||
import { Card } from '../Card';
|
||||
import DataTable from '../DataTable';
|
||||
|
||||
export const CommercialDocBox = styled(Card)`
|
||||
padding: 22px 20px;
|
||||
`;
|
||||
|
||||
export const CommercialDocHeader = styled.div`
|
||||
margin-bottom: 25px;
|
||||
`;
|
||||
|
||||
export const CommercialDocTopHeader = styled.div`
|
||||
margin-bottom: 25px;
|
||||
`;
|
||||
|
||||
export const CommercialDocEntriesTable = styled(DataTable)`
|
||||
.tbody .tr:last-child .td {
|
||||
border-bottom: 1px solid #d2dce2;
|
||||
}
|
||||
`;
|
||||
|
||||
export const CommercialDocFooter = styled.div`
|
||||
margin-top: 28px;
|
||||
`;
|
||||
@@ -11,12 +11,14 @@ export default function ContactSelecetList({
|
||||
contactsList,
|
||||
initialContactId,
|
||||
selectedContactId,
|
||||
selectedContactType,
|
||||
createNewItemFrom,
|
||||
defaultSelectText = <T id={'select_contact'} />,
|
||||
onContactSelected,
|
||||
popoverFill = false,
|
||||
disabled = false,
|
||||
buttonProps,
|
||||
|
||||
...restProps
|
||||
}) {
|
||||
const contacts = useMemo(
|
||||
() =>
|
||||
@@ -65,7 +67,7 @@ export default function ContactSelecetList({
|
||||
);
|
||||
|
||||
// Filter Contact List
|
||||
const filterContacts = (query, contact, index, exactMatch) => {
|
||||
const itemPredicate = (query, contact, index, exactMatch) => {
|
||||
const normalizedTitle = contact.display_name.toLowerCase();
|
||||
const normalizedQuery = query.toLowerCase();
|
||||
if (exactMatch) {
|
||||
@@ -83,7 +85,7 @@ export default function ContactSelecetList({
|
||||
items={contacts}
|
||||
noResults={<MenuItem disabled={true} text={<T id={'no_results'} />} />}
|
||||
itemRenderer={handleContactRenderer}
|
||||
itemPredicate={filterContacts}
|
||||
itemPredicate={itemPredicate}
|
||||
filterable={true}
|
||||
disabled={disabled}
|
||||
onItemSelect={onContactSelect}
|
||||
@@ -92,8 +94,9 @@ export default function ContactSelecetList({
|
||||
[CLASSES.SELECT_LIST_FILL_POPOVER]: popoverFill,
|
||||
})}
|
||||
inputProps={{
|
||||
placeholder: intl.get('filter_')
|
||||
placeholder: intl.get('filter_'),
|
||||
}}
|
||||
{...restProps}
|
||||
>
|
||||
<Button
|
||||
disabled={disabled}
|
||||
|
||||
86
src/components/Contacts/ContactSelectField.js
Normal file
86
src/components/Contacts/ContactSelectField.js
Normal file
@@ -0,0 +1,86 @@
|
||||
import React, { useCallback, useState, useEffect, useMemo } from 'react';
|
||||
import { FormattedMessage as T } from 'components';
|
||||
import intl from 'react-intl-universal';
|
||||
|
||||
import { MenuItem, Button } from '@blueprintjs/core';
|
||||
import { Select } from '@blueprintjs/select';
|
||||
import classNames from 'classnames';
|
||||
import { CLASSES } from 'common/classes';
|
||||
|
||||
import { itemPredicate, handleContactRenderer } from './utils';
|
||||
|
||||
export default function ContactSelectField({
|
||||
contacts,
|
||||
initialContactId,
|
||||
selectedContactId,
|
||||
defaultSelectText = <T id={'select_contact'} />,
|
||||
onContactSelected,
|
||||
popoverFill = false,
|
||||
disabled = false,
|
||||
buttonProps,
|
||||
|
||||
...restProps
|
||||
}) {
|
||||
const localContacts = useMemo(
|
||||
() =>
|
||||
contacts.map((contact) => ({
|
||||
...contact,
|
||||
_id: `${contact.id}_${contact.contact_type}`,
|
||||
})),
|
||||
[contacts],
|
||||
);
|
||||
|
||||
const initialContact = useMemo(
|
||||
() => contacts.find((a) => a.id === initialContactId),
|
||||
[initialContactId, contacts],
|
||||
);
|
||||
|
||||
const [selecetedContact, setSelectedContact] = useState(
|
||||
initialContact || null,
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof selectedContactId !== 'undefined') {
|
||||
const account = selectedContactId
|
||||
? contacts.find((a) => a.id === selectedContactId)
|
||||
: null;
|
||||
setSelectedContact(account);
|
||||
}
|
||||
}, [selectedContactId, contacts, setSelectedContact]);
|
||||
|
||||
const handleContactSelect = useCallback(
|
||||
(contact) => {
|
||||
setSelectedContact({ ...contact });
|
||||
onContactSelected && onContactSelected(contact);
|
||||
},
|
||||
[setSelectedContact, onContactSelected],
|
||||
);
|
||||
|
||||
return (
|
||||
<Select
|
||||
items={localContacts}
|
||||
noResults={<MenuItem disabled={true} text={<T id={'no_results'} />} />}
|
||||
itemRenderer={handleContactRenderer}
|
||||
itemPredicate={itemPredicate}
|
||||
filterable={true}
|
||||
disabled={disabled}
|
||||
onItemSelect={handleContactSelect}
|
||||
popoverProps={{ minimal: true, usePortal: !popoverFill }}
|
||||
className={classNames(CLASSES.FORM_GROUP_LIST_SELECT, {
|
||||
[CLASSES.SELECT_LIST_FILL_POPOVER]: popoverFill,
|
||||
})}
|
||||
inputProps={{
|
||||
placeholder: intl.get('filter_'),
|
||||
}}
|
||||
{...restProps}
|
||||
>
|
||||
<Button
|
||||
disabled={disabled}
|
||||
text={
|
||||
selecetedContact ? selecetedContact.display_name : defaultSelectText
|
||||
}
|
||||
{...buttonProps}
|
||||
/>
|
||||
</Select>
|
||||
);
|
||||
}
|
||||
116
src/components/Contacts/CustomerSelectField.js
Normal file
116
src/components/Contacts/CustomerSelectField.js
Normal file
@@ -0,0 +1,116 @@
|
||||
import React, { useCallback, useState, useEffect, useMemo } from 'react';
|
||||
import { FormattedMessage as T } from 'components';
|
||||
import intl from 'react-intl-universal';
|
||||
import * as R from 'ramda';
|
||||
|
||||
import { MenuItem, Button } from '@blueprintjs/core';
|
||||
import { Select } from '@blueprintjs/select';
|
||||
import classNames from 'classnames';
|
||||
import { CLASSES } from 'common/classes';
|
||||
|
||||
import {
|
||||
itemPredicate,
|
||||
handleContactRenderer,
|
||||
createNewItemRenderer,
|
||||
createNewItemFromQuery,
|
||||
} from './utils';
|
||||
|
||||
import withDrawerActions from 'containers/Drawer/withDrawerActions';
|
||||
|
||||
import { DRAWERS } from 'common/drawers';
|
||||
|
||||
function CustomerSelectField({
|
||||
// #withDrawerActions
|
||||
openDrawer,
|
||||
|
||||
// #ownProps
|
||||
contacts,
|
||||
initialContactId,
|
||||
selectedContactId,
|
||||
defaultSelectText = <T id={'select_contact'} />,
|
||||
onContactSelected,
|
||||
popoverFill = false,
|
||||
disabled = false,
|
||||
allowCreate,
|
||||
buttonProps,
|
||||
|
||||
...restProps
|
||||
}) {
|
||||
const localContacts = useMemo(
|
||||
() =>
|
||||
contacts.map((contact) => ({
|
||||
...contact,
|
||||
_id: `${contact.id}_${contact.contact_type}`,
|
||||
})),
|
||||
[contacts],
|
||||
);
|
||||
|
||||
const initialContact = useMemo(
|
||||
() => contacts.find((a) => a.id === initialContactId),
|
||||
[initialContactId, contacts],
|
||||
);
|
||||
|
||||
const [selecetedContact, setSelectedContact] = useState(
|
||||
initialContact || null,
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof selectedContactId !== 'undefined') {
|
||||
const account = selectedContactId
|
||||
? contacts.find((a) => a.id === selectedContactId)
|
||||
: null;
|
||||
setSelectedContact(account);
|
||||
}
|
||||
}, [selectedContactId, contacts, setSelectedContact]);
|
||||
|
||||
const handleContactSelect = useCallback(
|
||||
(contact) => {
|
||||
if (contact.id) {
|
||||
setSelectedContact({ ...contact });
|
||||
onContactSelected && onContactSelected(contact);
|
||||
} else {
|
||||
openDrawer(DRAWERS.QUICK_CREATE_CUSTOMER);
|
||||
}
|
||||
},
|
||||
[setSelectedContact, onContactSelected, openDrawer],
|
||||
);
|
||||
|
||||
// Maybe inject create new item props to suggest component.
|
||||
const maybeCreateNewItemRenderer = allowCreate ? createNewItemRenderer : null;
|
||||
const maybeCreateNewItemFromQuery = allowCreate
|
||||
? createNewItemFromQuery
|
||||
: null;
|
||||
|
||||
return (
|
||||
<Select
|
||||
items={localContacts}
|
||||
noResults={<MenuItem disabled={true} text={<T id={'no_results'} />} />}
|
||||
itemRenderer={handleContactRenderer}
|
||||
itemPredicate={itemPredicate}
|
||||
filterable={true}
|
||||
disabled={disabled}
|
||||
onItemSelect={handleContactSelect}
|
||||
popoverProps={{ minimal: true, usePortal: !popoverFill }}
|
||||
className={classNames(CLASSES.FORM_GROUP_LIST_SELECT, {
|
||||
[CLASSES.SELECT_LIST_FILL_POPOVER]: popoverFill,
|
||||
})}
|
||||
inputProps={{
|
||||
placeholder: intl.get('filter_'),
|
||||
}}
|
||||
createNewItemRenderer={maybeCreateNewItemRenderer}
|
||||
createNewItemFromQuery={maybeCreateNewItemFromQuery}
|
||||
createNewItemPosition={'top'}
|
||||
{...restProps}
|
||||
>
|
||||
<Button
|
||||
disabled={disabled}
|
||||
text={
|
||||
selecetedContact ? selecetedContact.display_name : defaultSelectText
|
||||
}
|
||||
{...buttonProps}
|
||||
/>
|
||||
</Select>
|
||||
);
|
||||
}
|
||||
|
||||
export default R.compose(withDrawerActions)(CustomerSelectField);
|
||||
115
src/components/Contacts/VendorSelectField.js
Normal file
115
src/components/Contacts/VendorSelectField.js
Normal file
@@ -0,0 +1,115 @@
|
||||
import React, { useCallback, useState, useEffect, useMemo } from 'react';
|
||||
import { FormattedMessage as T } from 'components';
|
||||
import intl from 'react-intl-universal';
|
||||
import * as R from 'ramda';
|
||||
|
||||
import { MenuItem, Button } from '@blueprintjs/core';
|
||||
import { Select } from '@blueprintjs/select';
|
||||
import classNames from 'classnames';
|
||||
import { CLASSES } from 'common/classes';
|
||||
|
||||
import {
|
||||
itemPredicate,
|
||||
handleContactRenderer,
|
||||
createNewItemFromQuery,
|
||||
createNewItemRenderer,
|
||||
} from './utils';
|
||||
import withDrawerActions from 'containers/Drawer/withDrawerActions';
|
||||
|
||||
import { DRAWERS } from 'common/drawers';
|
||||
|
||||
function VendorSelectField({
|
||||
// #withDrawerActions
|
||||
openDrawer,
|
||||
|
||||
// #ownProps
|
||||
contacts,
|
||||
initialContactId,
|
||||
selectedContactId,
|
||||
defaultSelectText = <T id={'select_contact'} />,
|
||||
onContactSelected,
|
||||
popoverFill = false,
|
||||
disabled = false,
|
||||
allowCreate,
|
||||
buttonProps,
|
||||
|
||||
...restProps
|
||||
}) {
|
||||
const localContacts = useMemo(
|
||||
() =>
|
||||
contacts.map((contact) => ({
|
||||
...contact,
|
||||
_id: `${contact.id}_${contact.contact_type}`,
|
||||
})),
|
||||
[contacts],
|
||||
);
|
||||
|
||||
const initialContact = useMemo(
|
||||
() => contacts.find((a) => a.id === initialContactId),
|
||||
[initialContactId, contacts],
|
||||
);
|
||||
|
||||
const [selecetedContact, setSelectedContact] = useState(
|
||||
initialContact || null,
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof selectedContactId !== 'undefined') {
|
||||
const account = selectedContactId
|
||||
? contacts.find((a) => a.id === selectedContactId)
|
||||
: null;
|
||||
setSelectedContact(account);
|
||||
}
|
||||
}, [selectedContactId, contacts, setSelectedContact]);
|
||||
|
||||
const handleContactSelect = useCallback(
|
||||
(contact) => {
|
||||
if (contact.id) {
|
||||
setSelectedContact({ ...contact });
|
||||
onContactSelected && onContactSelected(contact);
|
||||
} else {
|
||||
openDrawer(DRAWERS.QUICK_WRITE_VENDOR);
|
||||
}
|
||||
},
|
||||
[setSelectedContact, onContactSelected, openDrawer],
|
||||
);
|
||||
|
||||
// Maybe inject create new item props to suggest component.
|
||||
const maybeCreateNewItemRenderer = allowCreate ? createNewItemRenderer : null;
|
||||
const maybeCreateNewItemFromQuery = allowCreate
|
||||
? createNewItemFromQuery
|
||||
: null;
|
||||
|
||||
return (
|
||||
<Select
|
||||
items={localContacts}
|
||||
noResults={<MenuItem disabled={true} text={<T id={'no_results'} />} />}
|
||||
itemRenderer={handleContactRenderer}
|
||||
itemPredicate={itemPredicate}
|
||||
filterable={true}
|
||||
disabled={disabled}
|
||||
onItemSelect={handleContactSelect}
|
||||
popoverProps={{ minimal: true, usePortal: !popoverFill }}
|
||||
className={classNames(CLASSES.FORM_GROUP_LIST_SELECT, {
|
||||
[CLASSES.SELECT_LIST_FILL_POPOVER]: popoverFill,
|
||||
})}
|
||||
inputProps={{
|
||||
placeholder: intl.get('filter_'),
|
||||
}}
|
||||
createNewItemRenderer={maybeCreateNewItemRenderer}
|
||||
createNewItemFromQuery={maybeCreateNewItemFromQuery}
|
||||
createNewItemPosition={'top'}
|
||||
{...restProps}
|
||||
>
|
||||
<Button
|
||||
disabled={disabled}
|
||||
text={
|
||||
selecetedContact ? selecetedContact.display_name : defaultSelectText
|
||||
}
|
||||
{...buttonProps}
|
||||
/>
|
||||
</Select>
|
||||
);
|
||||
}
|
||||
|
||||
export default R.compose(withDrawerActions)(VendorSelectField);
|
||||
5
src/components/Contacts/index.js
Normal file
5
src/components/Contacts/index.js
Normal file
@@ -0,0 +1,5 @@
|
||||
import ContactSelectField from './ContactSelectField';
|
||||
import CustomerSelectField from './CustomerSelectField';
|
||||
import VendorSelectField from './VendorSelectField';
|
||||
|
||||
export { ContactSelectField, CustomerSelectField, VendorSelectField };
|
||||
44
src/components/Contacts/utils.js
Normal file
44
src/components/Contacts/utils.js
Normal file
@@ -0,0 +1,44 @@
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import { MenuItem } from '@blueprintjs/core';
|
||||
|
||||
// Filter Contact List
|
||||
export const itemPredicate = (query, contact, index, exactMatch) => {
|
||||
const normalizedTitle = contact.display_name.toLowerCase();
|
||||
const normalizedQuery = query.toLowerCase();
|
||||
if (exactMatch) {
|
||||
return normalizedTitle === normalizedQuery;
|
||||
} else {
|
||||
return (
|
||||
`${contact.display_name} ${normalizedTitle}`.indexOf(normalizedQuery) >= 0
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export const handleContactRenderer = (contact, { handleClick }) => (
|
||||
<MenuItem
|
||||
key={contact.id}
|
||||
text={contact.display_name}
|
||||
onClick={handleClick}
|
||||
/>
|
||||
);
|
||||
|
||||
// Creates a new item from query.
|
||||
export const createNewItemFromQuery = (name) => {
|
||||
return {
|
||||
name,
|
||||
};
|
||||
};
|
||||
|
||||
// Handle quick create new customer.
|
||||
export const createNewItemRenderer = (query, active, handleClick) => {
|
||||
return (
|
||||
<MenuItem
|
||||
icon="add"
|
||||
text={intl.get('list.create', { value: `"${query}"` })}
|
||||
active={active}
|
||||
shouldDismissPopover={false}
|
||||
onClick={handleClick}
|
||||
/>
|
||||
);
|
||||
};
|
||||
25
src/components/Customers/CustomerDrawerLink.js
Normal file
25
src/components/Customers/CustomerDrawerLink.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import React from 'react';
|
||||
import * as R from 'ramda';
|
||||
|
||||
import { ButtonLink } from '../Button';
|
||||
import withDrawerActions from 'containers/Drawer/withDrawerActions';
|
||||
|
||||
function CustomerDrawerLinkComponent({
|
||||
// #ownProps
|
||||
children,
|
||||
customerId,
|
||||
|
||||
// #withDrawerActions
|
||||
openDrawer,
|
||||
}) {
|
||||
// Handle view customer drawer.
|
||||
const handleCustomerDrawer = () => {
|
||||
openDrawer('customer-details-drawer', { customerId });
|
||||
};
|
||||
|
||||
return <ButtonLink onClick={handleCustomerDrawer}>{children}</ButtonLink>;
|
||||
}
|
||||
|
||||
export const CustomerDrawerLink = R.compose(withDrawerActions)(
|
||||
CustomerDrawerLinkComponent,
|
||||
);
|
||||
1
src/components/Customers/index.js
Normal file
1
src/components/Customers/index.js
Normal file
@@ -0,0 +1 @@
|
||||
export * from './CustomerDrawerLink';
|
||||
@@ -1,28 +0,0 @@
|
||||
import React from 'react';
|
||||
import { useUser } from 'hooks/query';
|
||||
import withAuthentication from '../../containers/Authentication/withAuthentication';
|
||||
|
||||
const AuthenticatedUserContext = React.createContext();
|
||||
|
||||
function AuthenticatedUserComponent({ authenticatedUserId, children }) {
|
||||
const { data: user, ...restProps } = useUser(authenticatedUserId);
|
||||
|
||||
return (
|
||||
<AuthenticatedUserContext.Provider
|
||||
value={{
|
||||
user,
|
||||
...restProps,
|
||||
}}
|
||||
children={children}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export const AuthenticatedUser = withAuthentication(
|
||||
({ authenticatedUserId }) => ({
|
||||
authenticatedUserId,
|
||||
}),
|
||||
)(AuthenticatedUserComponent);
|
||||
|
||||
export const useAuthenticatedUser = () =>
|
||||
React.useContext(AuthenticatedUserContext);
|
||||
25
src/components/Dashboard/DashboardAbilityProvider.js
Normal file
25
src/components/Dashboard/DashboardAbilityProvider.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import React from 'react';
|
||||
import { Ability } from '@casl/ability';
|
||||
import { createContextualCan } from '@casl/react';
|
||||
import { useDashboardMeta } from '../../hooks/query';
|
||||
|
||||
export const AbilityContext = React.createContext();
|
||||
export const Can = createContextualCan(AbilityContext.Consumer);
|
||||
|
||||
/**
|
||||
* Dashboard ability provider.
|
||||
*/
|
||||
export function DashboardAbilityProvider({ children }) {
|
||||
const {
|
||||
data: { abilities },
|
||||
} = useDashboardMeta();
|
||||
|
||||
// Ability instance.
|
||||
const ability = new Ability(abilities);
|
||||
|
||||
return (
|
||||
<AbilityContext.Provider value={ability}>
|
||||
{children}
|
||||
</AbilityContext.Provider>
|
||||
);
|
||||
}
|
||||
@@ -1,16 +1,19 @@
|
||||
import React from 'react';
|
||||
import classnames from 'classnames';
|
||||
import clsx from 'classnames';
|
||||
import { Navbar } from '@blueprintjs/core';
|
||||
|
||||
export default function DashboardActionsBar({ children, name }) {
|
||||
export default function DashboardActionsBar({ className, children, name }) {
|
||||
return (
|
||||
<div
|
||||
className={classnames({
|
||||
'dashboard__actions-bar': true,
|
||||
[`dashboard__actions-bar--${name}`]: !!name
|
||||
})}
|
||||
className={clsx(
|
||||
{
|
||||
'dashboard__actions-bar': true,
|
||||
[`dashboard__actions-bar--${name}`]: !!name,
|
||||
},
|
||||
className,
|
||||
)}
|
||||
>
|
||||
<Navbar className='navbar--dashboard-actions-bar'>{children}</Navbar>
|
||||
<Navbar className="navbar--dashboard-actions-bar">{children}</Navbar>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,53 @@
|
||||
import React from 'react';
|
||||
import * as R from 'ramda';
|
||||
|
||||
import { useUser, useCurrentOrganization } from '../../hooks/query';
|
||||
import {
|
||||
useAuthenticatedAccount,
|
||||
useCurrentOrganization,
|
||||
useDashboardMeta,
|
||||
} from '../../hooks/query';
|
||||
import { useSplashLoading } from '../../hooks/state';
|
||||
import { useWatch, useWatchImmediate, useWhen } from '../../hooks';
|
||||
|
||||
import withAuthentication from '../../containers/Authentication/withAuthentication';
|
||||
|
||||
import { setCookie, getCookie } from '../../utils';
|
||||
|
||||
/**
|
||||
* Dashboard async booting.
|
||||
* Dashboard meta async booting.
|
||||
*/
|
||||
function DashboardBootJSX({ authenticatedUserId }) {
|
||||
export function useDashboardMetaBoot() {
|
||||
const {
|
||||
data: dashboardMeta,
|
||||
isLoading: isDashboardMetaLoading,
|
||||
isSuccess: isDashboardMetaSuccess,
|
||||
} = useDashboardMeta({
|
||||
keepPreviousData: true,
|
||||
});
|
||||
const [startLoading, stopLoading] = useSplashLoading();
|
||||
|
||||
useWatchImmediate((value) => {
|
||||
value && startLoading();
|
||||
}, isDashboardMetaLoading);
|
||||
|
||||
useWatchImmediate(() => {
|
||||
isDashboardMetaSuccess && stopLoading();
|
||||
}, isDashboardMetaSuccess);
|
||||
|
||||
return {
|
||||
isLoading: isDashboardMetaLoading,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Dashboard async booting.
|
||||
* @returns {{ isLoading: boolean }}
|
||||
*/
|
||||
export function useDashboardBoot() {
|
||||
const { isLoading } = useDashboardMetaBoot();
|
||||
|
||||
return { isLoading };
|
||||
}
|
||||
|
||||
/**
|
||||
* Application async booting.
|
||||
*/
|
||||
export function useApplicationBoot() {
|
||||
// Fetches the current user's organization.
|
||||
const {
|
||||
isSuccess: isCurrentOrganizationSuccess,
|
||||
@@ -22,7 +57,7 @@ function DashboardBootJSX({ authenticatedUserId }) {
|
||||
|
||||
// Authenticated user.
|
||||
const { isSuccess: isAuthUserSuccess, isLoading: isAuthUserLoading } =
|
||||
useUser(authenticatedUserId);
|
||||
useAuthenticatedAccount();
|
||||
|
||||
// Initial locale cookie value.
|
||||
const localeCookie = getCookie('locale');
|
||||
@@ -86,11 +121,8 @@ function DashboardBootJSX({ authenticatedUserId }) {
|
||||
isBooted.current = true;
|
||||
},
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
export const DashboardBoot = R.compose(
|
||||
withAuthentication(({ authenticatedUserId }) => ({
|
||||
authenticatedUserId,
|
||||
})),
|
||||
)(DashboardBootJSX);
|
||||
return {
|
||||
isLoading: isOrgLoading || isAuthUserLoading,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ import React from 'react';
|
||||
import { ErrorBoundary } from 'react-error-boundary';
|
||||
import DashboardTopbar from 'components/Dashboard/DashboardTopbar';
|
||||
import DashboardContentRoutes from 'components/Dashboard/DashboardContentRoute';
|
||||
import DashboardFooter from 'components/Dashboard/DashboardFooter';
|
||||
import DashboardErrorBoundary from './DashboardErrorBoundary';
|
||||
|
||||
export default React.forwardRef(({}, ref) => {
|
||||
@@ -11,7 +10,6 @@ export default React.forwardRef(({}, ref) => {
|
||||
<div className="dashboard-content" id="dashboard" ref={ref}>
|
||||
<DashboardTopbar />
|
||||
<DashboardContentRoutes />
|
||||
<DashboardFooter />
|
||||
</div>
|
||||
</ErrorBoundary>
|
||||
);
|
||||
|
||||
@@ -1,8 +1,16 @@
|
||||
import React from 'react';
|
||||
import { DashboardAbilityProvider } from '../../components';
|
||||
import { useDashboardBoot } from './DashboardBoot';
|
||||
|
||||
/**
|
||||
* Dashboard provider.
|
||||
*/
|
||||
export default function DashboardProvider({ children }) {
|
||||
return children;
|
||||
const { isLoading } = useDashboardBoot();
|
||||
|
||||
// Avoid display any dashboard component before complete booting.
|
||||
if (isLoading) {
|
||||
return null;
|
||||
}
|
||||
return <DashboardAbilityProvider>{children}</DashboardAbilityProvider>;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
import React from 'react';
|
||||
import { ThemeProvider } from 'styled-components';
|
||||
import { ThemeProvider, StyleSheetManager } from 'styled-components';
|
||||
import rtlcss from 'stylis-rtlcss';
|
||||
import { useAppIntlContext } from '../AppIntlProvider';
|
||||
|
||||
export function DashboardThemeProvider({ children }) {
|
||||
const { direction } = useAppIntlContext();
|
||||
|
||||
return <ThemeProvider theme={{ dir: direction }}>{children}</ThemeProvider>;
|
||||
return (
|
||||
<StyleSheetManager
|
||||
{...(direction === 'rtl' ? { stylisPlugins: [rtlcss] } : {})}
|
||||
>
|
||||
<ThemeProvider theme={{ dir: direction }}>{children}</ThemeProvider>
|
||||
</StyleSheetManager>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import withDashboard from 'containers/Dashboard/withDashboard';
|
||||
import QuickNewDropdown from 'containers/QuickNewDropdown/QuickNewDropdown';
|
||||
import { compose } from 'utils';
|
||||
import withSubscriptions from '../../containers/Subscriptions/withSubscriptions';
|
||||
import { useGetUniversalSearchTypeOptions } from '../../containers/UniversalSearch/utils';
|
||||
|
||||
function DashboardTopbarSubscriptionMessage() {
|
||||
return (
|
||||
@@ -142,11 +143,8 @@ function DashboardTopbar({
|
||||
<Navbar class="dashboard__topbar-navbar">
|
||||
<NavbarGroup>
|
||||
<If condition={isSubscriptionActive}>
|
||||
<Button
|
||||
<DashboardQuickSearchButton
|
||||
onClick={() => openGlobalSearch(true)}
|
||||
className={Classes.MINIMAL}
|
||||
icon={<Icon icon={'search-24'} iconSize={20} />}
|
||||
text={<T id={'quick_find'} />}
|
||||
/>
|
||||
<QuickNewDropdown />
|
||||
|
||||
@@ -195,3 +193,23 @@ export default compose(
|
||||
'main',
|
||||
),
|
||||
)(DashboardTopbar);
|
||||
|
||||
/**
|
||||
* Dashboard quick search button.
|
||||
*/
|
||||
function DashboardQuickSearchButton({ ...rest }) {
|
||||
const searchTypeOptions = useGetUniversalSearchTypeOptions();
|
||||
|
||||
// Can't continue if there is no any search type option.
|
||||
if (searchTypeOptions.length <= 0) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<Button
|
||||
className={Classes.MINIMAL}
|
||||
icon={<Icon icon={'search-24'} iconSize={20} />}
|
||||
text={<T id={'quick_find'} />}
|
||||
{...rest}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,31 +1,15 @@
|
||||
import React from 'react';
|
||||
import * as R from 'ramda';
|
||||
|
||||
import { AuthenticatedUser } from './AuthenticatedUser';
|
||||
import { DashboardBoot } from '../../components';
|
||||
|
||||
import withDashboard from '../../containers/Dashboard/withDashboard';
|
||||
import { useApplicationBoot } from '../../components';
|
||||
|
||||
/**
|
||||
* Private pages provider.
|
||||
*/
|
||||
function PrivatePagesProviderComponent({
|
||||
splashScreenCompleted,
|
||||
|
||||
export function PrivatePagesProvider({
|
||||
// #ownProps
|
||||
children,
|
||||
}) {
|
||||
return (
|
||||
<AuthenticatedUser>
|
||||
<DashboardBoot />
|
||||
const { isLoading } = useApplicationBoot();
|
||||
|
||||
{splashScreenCompleted ? children : null}
|
||||
</AuthenticatedUser>
|
||||
);
|
||||
return <React.Fragment>{!isLoading ? children : null}</React.Fragment>;
|
||||
}
|
||||
|
||||
export const PrivatePagesProvider = R.compose(
|
||||
withDashboard(({ splashScreenCompleted }) => ({
|
||||
splashScreenCompleted,
|
||||
})),
|
||||
)(PrivatePagesProviderComponent);
|
||||
|
||||
@@ -14,10 +14,14 @@ import { firstLettersArgs } from 'utils';
|
||||
import { useAuthActions } from 'hooks/state';
|
||||
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
import { compose } from 'utils';
|
||||
import withSubscriptions from '../../containers/Subscriptions/withSubscriptions';
|
||||
import { useAuthenticatedUser } from './AuthenticatedUser';
|
||||
|
||||
import { useAuthenticatedAccount } from 'hooks/query'
|
||||
import { compose } from 'utils';
|
||||
|
||||
/**
|
||||
* Dashboard topbar user.
|
||||
*/
|
||||
function DashboardTopbarUser({
|
||||
openDialog,
|
||||
|
||||
@@ -28,7 +32,7 @@ function DashboardTopbarUser({
|
||||
const { setLogout } = useAuthActions();
|
||||
|
||||
// Retrieve authenticated user information.
|
||||
const { user } = useAuthenticatedUser();
|
||||
const { data: user } = useAuthenticatedAccount();
|
||||
|
||||
const onClickLogout = () => {
|
||||
setLogout();
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from './SplashScreen';
|
||||
export * from './DashboardBoot';
|
||||
export * from './DashboardThemeProvider';
|
||||
export * from './DashboardAbilityProvider';
|
||||
@@ -17,6 +17,8 @@ export default function AccountCellRenderer({
|
||||
accountsDataProp,
|
||||
filterAccountsByRootTypes,
|
||||
filterAccountsByTypes,
|
||||
fieldProps,
|
||||
formGroupProps,
|
||||
},
|
||||
row: { index, original },
|
||||
cell: { value: initialValue },
|
||||
@@ -53,6 +55,7 @@ export default function AccountCellRenderer({
|
||||
'form-group--account',
|
||||
Classes.FILL,
|
||||
)}
|
||||
{...formGroupProps}
|
||||
>
|
||||
<AccountsSuggestField
|
||||
accounts={accounts}
|
||||
@@ -66,6 +69,7 @@ export default function AccountCellRenderer({
|
||||
}}
|
||||
openOnKeyDown={true}
|
||||
blurOnSelectClose={false}
|
||||
{...fieldProps}
|
||||
/>
|
||||
</FormGroup>
|
||||
);
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
import React, { useCallback, useRef } from 'react';
|
||||
// import ItemsListField from 'components/ItemsListField';
|
||||
import ItemsSuggestField from 'components/ItemsSuggestField';
|
||||
import classNames from 'classnames';
|
||||
|
||||
import { FormGroup, Classes, Intent } from '@blueprintjs/core';
|
||||
import intl from 'react-intl-universal';
|
||||
|
||||
import ItemsSuggestField from 'components/ItemsSuggestField';
|
||||
|
||||
import { useCellAutoFocus } from 'hooks';
|
||||
|
||||
/**
|
||||
* Items list cell.
|
||||
*/
|
||||
export default function ItemsListCell({
|
||||
column: { id, filterSellable, filterPurchasable },
|
||||
column: { id, filterSellable, filterPurchasable, fieldProps, formGroupProps },
|
||||
row: { index },
|
||||
cell: { value: initialValue },
|
||||
payload: { items, updateData, errors, autoFocus },
|
||||
@@ -19,6 +21,7 @@ export default function ItemsListCell({
|
||||
// Auto-focus the items list input field.
|
||||
useCellAutoFocus(fieldRef, autoFocus, id, index);
|
||||
|
||||
// Handle the item selected.
|
||||
const handleItemSelected = useCallback(
|
||||
(item) => {
|
||||
updateData(index, id, item.id);
|
||||
@@ -32,6 +35,7 @@ export default function ItemsListCell({
|
||||
<FormGroup
|
||||
intent={error ? Intent.DANGER : null}
|
||||
className={classNames('form-group--select-list', Classes.FILL)}
|
||||
{...formGroupProps}
|
||||
>
|
||||
<ItemsSuggestField
|
||||
items={items}
|
||||
@@ -45,6 +49,7 @@ export default function ItemsListCell({
|
||||
}}
|
||||
openOnKeyDown={true}
|
||||
blurOnSelectClose={false}
|
||||
{...fieldProps}
|
||||
/>
|
||||
</FormGroup>
|
||||
);
|
||||
|
||||
51
src/components/DataTableCells/SwitchFieldCell.js
Normal file
51
src/components/DataTableCells/SwitchFieldCell.js
Normal file
@@ -0,0 +1,51 @@
|
||||
import React from 'react';
|
||||
import classNames from 'classnames';
|
||||
import { Classes, Switch, FormGroup, Intent } from '@blueprintjs/core';
|
||||
|
||||
import { safeInvoke } from 'utils';
|
||||
|
||||
/**
|
||||
* Switch editable cell.
|
||||
*/
|
||||
const SwitchEditableCell = ({
|
||||
row: { index, original },
|
||||
column: { id, switchProps, onSwitchChange },
|
||||
cell: { value: initialValue },
|
||||
payload,
|
||||
}) => {
|
||||
const [value, setValue] = React.useState(initialValue);
|
||||
|
||||
// Handle the switch change.
|
||||
const onChange = (e) => {
|
||||
const newValue = e.target.checked;
|
||||
|
||||
setValue(newValue);
|
||||
|
||||
safeInvoke(payload.updateData, index, id, newValue);
|
||||
safeInvoke(onSwitchChange, e, newValue, original);
|
||||
};
|
||||
|
||||
React.useEffect(() => {
|
||||
setValue(initialValue);
|
||||
}, [initialValue]);
|
||||
|
||||
const error = payload.errors?.[index]?.[id];
|
||||
|
||||
return (
|
||||
<FormGroup
|
||||
intent={error ? Intent.DANGER : null}
|
||||
className={classNames(Classes.FILL)}
|
||||
>
|
||||
<Switch
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
checked={initialValue}
|
||||
minimal={true}
|
||||
className="ml2"
|
||||
{...switchProps}
|
||||
/>
|
||||
</FormGroup>
|
||||
);
|
||||
};
|
||||
|
||||
export default SwitchEditableCell;
|
||||
42
src/components/DataTableCells/TextAreaCell.js
Normal file
42
src/components/DataTableCells/TextAreaCell.js
Normal file
@@ -0,0 +1,42 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import classNames from 'classnames';
|
||||
import { Classes, TextArea, FormGroup, Intent } from '@blueprintjs/core';
|
||||
|
||||
const TextAreaEditableCell = ({
|
||||
row: { index },
|
||||
column: { id },
|
||||
cell: { value: initialValue },
|
||||
payload,
|
||||
}) => {
|
||||
const [value, setValue] = useState(initialValue);
|
||||
|
||||
const onChange = (e) => {
|
||||
setValue(e.target.value);
|
||||
};
|
||||
const onBlur = () => {
|
||||
payload.updateData(index, id, value);
|
||||
};
|
||||
useEffect(() => {
|
||||
setValue(initialValue);
|
||||
}, [initialValue]);
|
||||
|
||||
const error = payload.errors?.[index]?.[id];
|
||||
|
||||
return (
|
||||
<FormGroup
|
||||
intent={error ? Intent.DANGER : null}
|
||||
className={classNames(Classes.FILL)}
|
||||
>
|
||||
<TextArea
|
||||
growVertically={true}
|
||||
large={true}
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
onBlur={onBlur}
|
||||
fill={true}
|
||||
/>
|
||||
</FormGroup>
|
||||
);
|
||||
};
|
||||
|
||||
export default TextAreaEditableCell;
|
||||
@@ -6,7 +6,9 @@ import ItemsListCell from './ItemsListCell';
|
||||
import PercentFieldCell from './PercentFieldCell';
|
||||
import { DivFieldCell, EmptyDiv } from './DivFieldCell';
|
||||
import NumericInputCell from './NumericInputCell';
|
||||
import CheckBoxFieldCell from './CheckBoxFieldCell'
|
||||
import CheckBoxFieldCell from './CheckBoxFieldCell';
|
||||
import SwitchFieldCell from './SwitchFieldCell';
|
||||
import TextAreaCell from './TextAreaCell';
|
||||
|
||||
export {
|
||||
AccountsListFieldCell,
|
||||
@@ -18,5 +20,7 @@ export {
|
||||
DivFieldCell,
|
||||
EmptyDiv,
|
||||
NumericInputCell,
|
||||
CheckBoxFieldCell
|
||||
CheckBoxFieldCell,
|
||||
SwitchFieldCell,
|
||||
TextAreaCell,
|
||||
};
|
||||
|
||||
@@ -15,7 +15,7 @@ function TableHeaderCell({ column, index }) {
|
||||
<div
|
||||
{...column.getHeaderProps({
|
||||
className: classNames(column.className || '', 'th', {
|
||||
'align-right': column.align === 'right',
|
||||
[`align-${column.align}`]: column.align,
|
||||
}),
|
||||
})}
|
||||
>
|
||||
@@ -89,12 +89,14 @@ export default function TableHeader() {
|
||||
return (
|
||||
<ScrollSyncPane>
|
||||
<div className="thead">
|
||||
{headerGroups.map((headerGroup, index) => (
|
||||
<TableHeaderGroup key={index} headerGroup={headerGroup} />
|
||||
))}
|
||||
<If condition={progressBarLoading}>
|
||||
<MaterialProgressBar />
|
||||
</If>
|
||||
<div className={'thead-inner'}>
|
||||
{headerGroups.map((headerGroup, index) => (
|
||||
<TableHeaderGroup key={index} headerGroup={headerGroup} />
|
||||
))}
|
||||
<If condition={progressBarLoading}>
|
||||
<MaterialProgressBar />
|
||||
</If>
|
||||
</div>
|
||||
</div>
|
||||
</ScrollSyncPane>
|
||||
);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { useContext } from 'react';
|
||||
import clsx from 'classnames';
|
||||
import TableContext from './TableContext';
|
||||
import { Skeleton } from 'components';
|
||||
|
||||
@@ -8,7 +9,13 @@ function TableHeaderCell({ column }) {
|
||||
return (
|
||||
<div
|
||||
{...column.getHeaderProps({
|
||||
className: 'th',
|
||||
className: clsx(
|
||||
'th',
|
||||
{
|
||||
[`align-${column.align}`]: column.align,
|
||||
},
|
||||
column.className,
|
||||
),
|
||||
})}
|
||||
>
|
||||
<Skeleton minWidth={skeletonWidthMin} maxWidth={skeletonWidthMax} />
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React, { useContext } from 'react';
|
||||
import clsx from 'classnames';
|
||||
import TableContext from './TableContext';
|
||||
import { Skeleton } from 'components';
|
||||
|
||||
@@ -11,7 +12,13 @@ function TableHeaderCell({ column }) {
|
||||
return (
|
||||
<div
|
||||
{...column.getHeaderProps({
|
||||
className: 'td',
|
||||
className: clsx(
|
||||
'td',
|
||||
{
|
||||
[`align-${column.align}`]: column.align,
|
||||
},
|
||||
column.className,
|
||||
),
|
||||
})}
|
||||
>
|
||||
<Skeleton minWidth={skeletonWidthMin} maxWidth={skeletonWidthMax} />
|
||||
|
||||
@@ -16,6 +16,7 @@ export default function TableWrapper({ children }) {
|
||||
expandable,
|
||||
virtualizedRows,
|
||||
className,
|
||||
styleName,
|
||||
size,
|
||||
},
|
||||
} = useContext(TableContext);
|
||||
@@ -28,6 +29,7 @@ export default function TableWrapper({ children }) {
|
||||
'is-expandable': expandable,
|
||||
'is-loading': loading,
|
||||
'has-virtualized-rows': virtualizedRows,
|
||||
[`table--${styleName}`]: styleName,
|
||||
})}
|
||||
>
|
||||
<ScrollSync>
|
||||
|
||||
@@ -17,6 +17,7 @@ const useDetailsMenuContext = () => React.useContext(DetailsMenuContext);
|
||||
export function DetailsMenu({
|
||||
children,
|
||||
direction = DIRECTION.VERTICAL,
|
||||
textAlign,
|
||||
minLabelSize,
|
||||
className,
|
||||
}) {
|
||||
@@ -27,6 +28,7 @@ export function DetailsMenu({
|
||||
{
|
||||
'details-menu--vertical': direction === DIRECTION.VERTICAL,
|
||||
'details-menu--horizantal': direction === DIRECTION.HORIZANTAL,
|
||||
[`align-${textAlign}`]: textAlign,
|
||||
},
|
||||
className,
|
||||
)}
|
||||
|
||||
@@ -9,16 +9,16 @@ function DialogComponent(props) {
|
||||
const { name, children, closeDialog, onClose } = props;
|
||||
|
||||
const handleClose = (event) => {
|
||||
closeDialog(name)
|
||||
closeDialog(name);
|
||||
onClose && onClose(event);
|
||||
};
|
||||
return (
|
||||
<Dialog {...props} onClose={handleClose}>
|
||||
{ children }
|
||||
{children}
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(
|
||||
withDialogActions,
|
||||
)(DialogComponent);
|
||||
const DialogRoot = compose(withDialogActions)(DialogComponent);
|
||||
|
||||
export { DialogRoot as Dialog };
|
||||
|
||||
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import { Spinner, Classes } from '@blueprintjs/core';
|
||||
import classNames from 'classnames';
|
||||
|
||||
export default function DialogContent(props) {
|
||||
export function DialogContent(props) {
|
||||
const { isLoading, children } = props;
|
||||
|
||||
const loadingContent = (
|
||||
|
||||
15
src/components/Dialog/DialogFooter.js
Normal file
15
src/components/Dialog/DialogFooter.js
Normal file
@@ -0,0 +1,15 @@
|
||||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { Classes } from '@blueprintjs/core';
|
||||
|
||||
export function DialogFooter({ children }) {
|
||||
return (
|
||||
<DialogFooterRoot className={Classes.DIALOG_FOOTER}>
|
||||
{children}
|
||||
</DialogFooterRoot>
|
||||
);
|
||||
}
|
||||
|
||||
const DialogFooterRoot = styled.div`
|
||||
display: flex;
|
||||
`;
|
||||
41
src/components/Dialog/DialogFooterActions.js
Normal file
41
src/components/Dialog/DialogFooterActions.js
Normal file
@@ -0,0 +1,41 @@
|
||||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { Classes } from '@blueprintjs/core';
|
||||
|
||||
/**
|
||||
* Dialog footer actions.
|
||||
* @returns {React.JSX}
|
||||
*/
|
||||
export function DialogFooterActions({ alignment = 'right', children }) {
|
||||
return (
|
||||
<DialogFooterActionsRoot
|
||||
className={Classes.DIALOG_FOOTER_ACTIONS}
|
||||
alignment={alignment}
|
||||
>
|
||||
{children}
|
||||
</DialogFooterActionsRoot>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dialog footer.
|
||||
* @returns {React.JSX}
|
||||
*/
|
||||
export function DialogFooter({ ...props }) {
|
||||
return <DialogFooterRoot {...props} />;
|
||||
}
|
||||
|
||||
const DialogFooterRoot = styled.div`
|
||||
flex: 0 0 auto;
|
||||
margin: 0 20px;
|
||||
`;
|
||||
|
||||
const DialogFooterActionsRoot = styled.div`
|
||||
${(props) =>
|
||||
props.alignment === 'right' ? 'margin-left: auto;' : 'margin-right: auto;'};
|
||||
|
||||
.bp3-button {
|
||||
margin-left: 5px;
|
||||
margin-left: 5px;
|
||||
}
|
||||
`;
|
||||
@@ -5,7 +5,7 @@ function LoadingContent() {
|
||||
return (<div className={Classes.DIALOG_BODY}><Spinner size={30} /></div>);
|
||||
}
|
||||
|
||||
export default function DialogSuspense({
|
||||
export function DialogSuspense({
|
||||
children
|
||||
}) {
|
||||
return (
|
||||
|
||||
7
src/components/Dialog/index.js
Normal file
7
src/components/Dialog/index.js
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
|
||||
export * from './Dialog';
|
||||
export * from './DialogFooterActions';
|
||||
export * from './DialogSuspense';
|
||||
export * from './DialogContent';
|
||||
export * from './DialogFooter';
|
||||
@@ -19,6 +19,21 @@ import EstimatePdfPreviewDialog from 'containers/Dialogs/EstimatePdfPreviewDialo
|
||||
import ReceiptPdfPreviewDialog from '../containers/Dialogs/ReceiptPdfPreviewDialog';
|
||||
import MoneyInDialog from '../containers/Dialogs/MoneyInDialog';
|
||||
import MoneyOutDialog from '../containers/Dialogs/MoneyOutDialog';
|
||||
import BadDebtDialog from '../containers/Dialogs/BadDebtDialog';
|
||||
import NotifyInvoiceViaSMSDialog from '../containers/Dialogs/NotifyInvoiceViaSMSDialog';
|
||||
import NotifyReceiptViaSMSDialog from '../containers/Dialogs/NotifyReceiptViaSMSDialog';
|
||||
import NotifyEstimateViaSMSDialog from '../containers/Dialogs/NotifyEstimateViaSMSDialog';
|
||||
import NotifyPaymentReceiveViaSMSDialog from '../containers/Dialogs/NotifyPaymentReceiveViaSMSDialog';
|
||||
import SMSMessageDialog from '../containers/Dialogs/SMSMessageDialog';
|
||||
import RefundCreditNoteDialog from '../containers/Dialogs/RefundCreditNoteDialog';
|
||||
import RefundVendorCreditDialog from '../containers/Dialogs/RefundVendorCreditDialog';
|
||||
import ReconcileCreditNoteDialog from '../containers/Dialogs/ReconcileCreditNoteDialog';
|
||||
import ReconcileVendorCreditDialog from '../containers/Dialogs/ReconcileVendorCreditDialog';
|
||||
import LockingTransactionsDialog from '../containers/Dialogs/LockingTransactionsDialog';
|
||||
import UnlockingTransactionsDialog from '../containers/Dialogs/UnlockingTransactionsDialog';
|
||||
import UnlockingPartialTransactionsDialog from '../containers/Dialogs/UnlockingPartialTransactionsDialog';
|
||||
import CreditNotePdfPreviewDialog from '../containers/Dialogs/CreditNotePdfPreviewDialog';
|
||||
import PaymentReceivePdfPreviewDialog from '../containers/Dialogs/PaymentReceivePdfPreviewDialog';
|
||||
|
||||
/**
|
||||
* Dialogs container.
|
||||
@@ -44,6 +59,25 @@ export default function DialogsContainer() {
|
||||
<ReceiptPdfPreviewDialog dialogName={'receipt-pdf-preview'} />
|
||||
<MoneyInDialog dialogName={'money-in'} />
|
||||
<MoneyOutDialog dialogName={'money-out'} />
|
||||
|
||||
<NotifyInvoiceViaSMSDialog dialogName={'notify-invoice-via-sms'} />
|
||||
<NotifyReceiptViaSMSDialog dialogName={'notify-receipt-via-sms'} />
|
||||
<NotifyEstimateViaSMSDialog dialogName={'notify-estimate-via-sms'} />
|
||||
<NotifyPaymentReceiveViaSMSDialog dialogName={'notify-payment-via-sms'} />
|
||||
|
||||
<BadDebtDialog dialogName={'write-off-bad-debt'} />
|
||||
<SMSMessageDialog dialogName={'sms-message-form'} />
|
||||
<RefundCreditNoteDialog dialogName={'refund-credit-note'} />
|
||||
<RefundVendorCreditDialog dialogName={'refund-vendor-credit'} />
|
||||
<ReconcileCreditNoteDialog dialogName={'reconcile-credit-note'} />
|
||||
<ReconcileVendorCreditDialog dialogName={'reconcile-vendor-credit'} />
|
||||
<LockingTransactionsDialog dialogName={'locking-transactions'} />
|
||||
<UnlockingTransactionsDialog dialogName={'unlocking-transactions'} />
|
||||
<UnlockingPartialTransactionsDialog
|
||||
dialogName={'unlocking-partial-transactions'}
|
||||
/>
|
||||
<CreditNotePdfPreviewDialog dialogName={'credit-note-pdf-preview'} />
|
||||
<PaymentReceivePdfPreviewDialog dialogName={'payment-pdf-preview'} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import React from 'react';
|
||||
import ListSelect from "./ListSelect";
|
||||
import intl from 'react-intl-universal';
|
||||
import ListSelect from './ListSelect';
|
||||
|
||||
export default function DisplayNameList({
|
||||
salutation,
|
||||
@@ -9,25 +10,32 @@ export default function DisplayNameList({
|
||||
...restProps
|
||||
}) {
|
||||
const formats = [
|
||||
{ format: '{1} {2} {3}', values: [salutation, firstName, lastName], required: [1] },
|
||||
{
|
||||
format: '{1} {2} {3}',
|
||||
values: [salutation, firstName, lastName],
|
||||
required: [1],
|
||||
},
|
||||
{ format: '{1} {2}', values: [firstName, lastName], required: [] },
|
||||
{ format: '{1}, {2}', values: [firstName, lastName], required: [1, 2] },
|
||||
{ format: '{1}', values: [company], required: [1] }
|
||||
{ format: '{1}', values: [company], required: [1] },
|
||||
];
|
||||
|
||||
const formatOptions = formats
|
||||
.filter((format) => !format.values.some((value, index) => {
|
||||
return !value && format.required.indexOf(index + 1) !== -1;
|
||||
}))
|
||||
.filter(
|
||||
(format) =>
|
||||
!format.values.some((value, index) => {
|
||||
return !value && format.required.indexOf(index + 1) !== -1;
|
||||
}),
|
||||
)
|
||||
.map((formatOption) => {
|
||||
const { format, values } = formatOption;
|
||||
let label = format;
|
||||
|
||||
values.forEach((value, index) => {
|
||||
const replaceWith = (value || '');
|
||||
const replaceWith = value || '';
|
||||
label = label.replace(`{${index + 1}}`, replaceWith).trim();
|
||||
});
|
||||
return { label: label.replace(/\s+/g, " ") };
|
||||
return { label: label.replace(/\s+/g, ' ') };
|
||||
});
|
||||
|
||||
return (
|
||||
@@ -35,9 +43,9 @@ export default function DisplayNameList({
|
||||
items={formatOptions}
|
||||
selectedItemProp={'label'}
|
||||
textProp={'label'}
|
||||
defaultText={'Select display name as'}
|
||||
defaultText={intl.get('select_display_name_as')}
|
||||
filterable={false}
|
||||
{ ...restProps }
|
||||
{...restProps}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Position, Drawer } from '@blueprintjs/core';
|
||||
|
||||
import 'style/components/Drawer.scss';
|
||||
|
||||
import { DrawerProvider } from './DrawerProvider';
|
||||
import withDrawerActions from 'containers/Drawer/withDrawerActions';
|
||||
import { compose } from 'utils';
|
||||
|
||||
@@ -27,7 +28,7 @@ function DrawerComponent(props) {
|
||||
portalClassName={'drawer-portal'}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<DrawerProvider {...props}>{children}</DrawerProvider>
|
||||
</Drawer>
|
||||
);
|
||||
}
|
||||
|
||||
12
src/components/Drawer/DrawerActionsBar.js
Normal file
12
src/components/Drawer/DrawerActionsBar.js
Normal file
@@ -0,0 +1,12 @@
|
||||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
|
||||
import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar';
|
||||
|
||||
export function DrawerActionsBar({ ...props }) {
|
||||
return <DrawerActionsBarRoot {...props} />;
|
||||
}
|
||||
|
||||
const DrawerActionsBarRoot = styled(DashboardActionsBar)`
|
||||
border-bottom: 1px solid #d9d9da;
|
||||
`;
|
||||
@@ -1,15 +1,54 @@
|
||||
import React from 'react';
|
||||
import { Tabs } from '@blueprintjs/core';
|
||||
import styled from 'styled-components';
|
||||
|
||||
/**
|
||||
* Drawer main tabs.
|
||||
*/
|
||||
export function DrawerMainTabs({ children, ...restProps }) {
|
||||
return (
|
||||
<div class="drawer__main-tabs">
|
||||
<DrawerMainTabsRoot>
|
||||
<Tabs animate={true} large={true} {...restProps}>
|
||||
{children}
|
||||
</Tabs>
|
||||
</div>
|
||||
</DrawerMainTabsRoot>
|
||||
);
|
||||
}
|
||||
|
||||
const DrawerMainTabsRoot = styled.div`
|
||||
.bp3-tabs {
|
||||
.bp3-tab-list {
|
||||
position: relative;
|
||||
background-color: #fff;
|
||||
padding: 0 15px;
|
||||
border-bottom: 2px solid #e1e2e8;
|
||||
|
||||
> *:not(:last-child) {
|
||||
margin-right: 25px;
|
||||
}
|
||||
|
||||
&.bp3-large > .bp3-tab {
|
||||
font-size: 15px;
|
||||
color: #7f8596;
|
||||
margin: 0 1rem;
|
||||
|
||||
&[aria-selected='true'],
|
||||
&:not([aria-disabled='true']):hover {
|
||||
color: #0052cc;
|
||||
}
|
||||
}
|
||||
.bp3-tab-indicator-wrapper .bp3-tab-indicator {
|
||||
height: 2px;
|
||||
bottom: -2px;
|
||||
}
|
||||
}
|
||||
|
||||
.bp3-tab-panel {
|
||||
margin-top: 0;
|
||||
|
||||
.card {
|
||||
margin: 15px;
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
16
src/components/Drawer/DrawerProvider.js
Normal file
16
src/components/Drawer/DrawerProvider.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import React, { createContext, useContext } from 'react';
|
||||
|
||||
const DrawerContext = createContext();
|
||||
|
||||
/**
|
||||
* Account form provider.
|
||||
*/
|
||||
function DrawerProvider({ ...props }) {
|
||||
const provider = { ...props };
|
||||
|
||||
return <DrawerContext.Provider value={provider} {...props} />;
|
||||
}
|
||||
|
||||
const useDrawerContext = () => useContext(DrawerContext);
|
||||
|
||||
export { DrawerProvider, useDrawerContext };
|
||||
@@ -13,3 +13,5 @@ export function DrawerLoading({ loading, mount = false, children }) {
|
||||
export function DrawerBody({ children }) {
|
||||
return <div className={Classes.DRAWER_BODY}>{children}</div>;
|
||||
}
|
||||
|
||||
export * from './DrawerActionsBar';
|
||||
@@ -14,6 +14,13 @@ import CustomerDetailsDrawer from '../containers/Drawers/CustomerDetailsDrawer';
|
||||
import VendorDetailsDrawer from '../containers/Drawers/VendorDetailsDrawer';
|
||||
import InventoryAdjustmentDetailDrawer from '../containers/Drawers/InventoryAdjustmentDetailDrawer';
|
||||
import CashflowTransactionDetailDrawer from '../containers/Drawers/CashflowTransactionDetailDrawer';
|
||||
import QuickCreateCustomerDrawer from '../containers/Drawers/QuickCreateCustomerDrawer';
|
||||
import QuickCreateItemDrawer from '../containers/Drawers/QuickCreateItemDrawer';
|
||||
import QuickWriteVendorDrawer from '../containers/Drawers/QuickWriteVendorDrawer';
|
||||
import CreditNoteDetailDrawer from '../containers/Drawers/CreditNoteDetailDrawer';
|
||||
import VendorCreditDetailDrawer from '../containers/Drawers/VendorCreditDetailDrawer';
|
||||
import RefundCreditNoteDetailDrawer from '../containers/Drawers/RefundCreditNoteDetailDrawer';
|
||||
import RefundVendorCreditDetailDrawer from '../containers/Drawers/RefundVendorCreditDetailDrawer';
|
||||
|
||||
import { DRAWERS } from 'common/drawers';
|
||||
|
||||
@@ -38,7 +45,20 @@ export default function DrawersContainer() {
|
||||
<InventoryAdjustmentDetailDrawer
|
||||
name={DRAWERS.INVENTORY_ADJUSTMENT_DRAWER}
|
||||
/>
|
||||
<CashflowTransactionDetailDrawer name={DRAWERS.CASHFLOW_TRNASACTION_DRAWER} />
|
||||
<CashflowTransactionDetailDrawer
|
||||
name={DRAWERS.CASHFLOW_TRNASACTION_DRAWER}
|
||||
/>
|
||||
<QuickCreateCustomerDrawer name={DRAWERS.QUICK_CREATE_CUSTOMER} />
|
||||
<QuickCreateItemDrawer name={DRAWERS.QUICK_CREATE_ITEM} />
|
||||
<QuickWriteVendorDrawer name={DRAWERS.QUICK_WRITE_VENDOR} />
|
||||
<CreditNoteDetailDrawer name={DRAWERS.CREDIT_NOTE_DETAIL_DRAWER} />
|
||||
<VendorCreditDetailDrawer name={DRAWERS.VENDOR_CREDIT_DETAIL_DRAWER} />
|
||||
<RefundCreditNoteDetailDrawer
|
||||
name={DRAWERS.REFUND_CREDIT_NOTE_DETAIL_DRAWER}
|
||||
/>
|
||||
<RefundVendorCreditDetailDrawer
|
||||
name={DRAWERS.REFUND_VENDOR_CREDIT_DETAIL_DRAWER}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
23
src/components/FinancialReport/index.js
Normal file
23
src/components/FinancialReport/index.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
|
||||
const FinancialStatementRoot = styled.div``;
|
||||
const FinancialStatementBodyRoot = styled.div``;
|
||||
|
||||
/**
|
||||
*
|
||||
* @returns {React.JSX}
|
||||
*/
|
||||
export function FinancialReport({ children, className }) {
|
||||
return <FinancialStatementRoot children={children} className={className} />;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {React.JSX}
|
||||
*/
|
||||
export function FinancialReportBody({ children, className }) {
|
||||
return (
|
||||
<FinancialStatementBodyRoot children={children} className={className} />
|
||||
);
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
import React, { useMemo, useCallback } from 'react';
|
||||
import moment from 'moment';
|
||||
import classnames from 'classnames';
|
||||
import { FormattedMessage as T } from 'components';
|
||||
import intl from 'react-intl-universal';
|
||||
|
||||
import 'style/pages/FinancialStatements/FinancialSheet.scss';
|
||||
|
||||
import { If, LoadingIndicator, MODIFIER } from 'components';
|
||||
|
||||
export default function FinancialSheet({
|
||||
companyName,
|
||||
sheetType,
|
||||
fromDate,
|
||||
toDate,
|
||||
asDate,
|
||||
children,
|
||||
accountingBasis,
|
||||
name,
|
||||
loading,
|
||||
className,
|
||||
basis,
|
||||
minimal = false,
|
||||
fullWidth = false,
|
||||
currentDate = true,
|
||||
}) {
|
||||
|
||||
const format = 'DD MMMM YYYY';
|
||||
const formattedFromDate = useMemo(() => moment(fromDate).format(format), [
|
||||
fromDate,
|
||||
]);
|
||||
const formattedToDate = useMemo(() => moment(toDate).format(format), [
|
||||
toDate,
|
||||
]);
|
||||
const formattedAsDate = useMemo(() => moment(asDate).format(format), [
|
||||
asDate,
|
||||
]);
|
||||
|
||||
const nameModifer = name ? `financial-sheet--${name}` : '';
|
||||
const methodsLabels = useMemo(
|
||||
() => ({
|
||||
cash: intl.get('cash'),
|
||||
accrual: intl.get('accrual'),
|
||||
}),
|
||||
[],
|
||||
);
|
||||
const getBasisLabel = useCallback((b) => methodsLabels[b], [methodsLabels]);
|
||||
const basisLabel = useMemo(() => getBasisLabel(basis), [
|
||||
getBasisLabel,
|
||||
basis,
|
||||
]);
|
||||
|
||||
return (
|
||||
<div
|
||||
className={classnames('financial-sheet', nameModifer, className, {
|
||||
[MODIFIER.FINANCIAL_SHEET_MINIMAL]: minimal,
|
||||
'is-full-width': fullWidth,
|
||||
})}
|
||||
>
|
||||
{loading ? (
|
||||
<LoadingIndicator loading={loading} spinnerSize={34} />
|
||||
) : (
|
||||
<div className={classnames('financial-sheet__inner')}>
|
||||
<If condition={!!companyName}>
|
||||
<h1 class="financial-sheet__title">{companyName}</h1>
|
||||
</If>
|
||||
|
||||
<If condition={!!sheetType}>
|
||||
<h6 class="financial-sheet__sheet-type">{sheetType}</h6>
|
||||
</If>
|
||||
|
||||
<div class="financial-sheet__date">
|
||||
<If condition={asDate}>
|
||||
<T id={'as'} /> {formattedAsDate}
|
||||
</If>
|
||||
|
||||
<If condition={fromDate && toDate}>
|
||||
<T id={'from'} /> {formattedFromDate} | <T id={'to'} />{' '}
|
||||
{formattedToDate}
|
||||
</If>
|
||||
</div>
|
||||
|
||||
<div class="financial-sheet__table">{children}</div>
|
||||
<div class="financial-sheet__accounting-basis">{accountingBasis}</div>
|
||||
|
||||
<div class="financial-sheet__footer">
|
||||
<If condition={basisLabel}>
|
||||
<span class="financial-sheet__basis">
|
||||
<T id={'accounting_basis'} /> {basisLabel}
|
||||
</span>
|
||||
</If>
|
||||
|
||||
<If condition={currentDate}>
|
||||
<span class="financial-sheet__current-date">
|
||||
{moment().format('YYYY MMM DD HH:MM')}
|
||||
</span>
|
||||
</If>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
101
src/components/FinancialSheet/FinancialSheet.js
Normal file
101
src/components/FinancialSheet/FinancialSheet.js
Normal file
@@ -0,0 +1,101 @@
|
||||
import React, { useMemo, useCallback } from 'react';
|
||||
import moment from 'moment';
|
||||
import intl from 'react-intl-universal';
|
||||
|
||||
import If from '../Utils/If';
|
||||
import { FormattedMessage as T } from '../FormattedMessage';
|
||||
import {
|
||||
FinancialSheetRoot,
|
||||
FinancialSheetFooterCurrentTime,
|
||||
FinancialSheetFooterBasis,
|
||||
FinancialSheetFooter,
|
||||
FinancialSheetAccountingBasis,
|
||||
FinancialSheetTable,
|
||||
FinancialSheetDate,
|
||||
FinancialSheetType,
|
||||
FinancialSheetTitle,
|
||||
} from './StyledFinancialSheet';
|
||||
|
||||
/**
|
||||
* Financial sheet.
|
||||
* @returns {React.JSX}
|
||||
*/
|
||||
export function FinancialSheet({
|
||||
companyName,
|
||||
sheetType,
|
||||
fromDate,
|
||||
toDate,
|
||||
asDate,
|
||||
children,
|
||||
accountingBasis,
|
||||
basis,
|
||||
minimal = false,
|
||||
fullWidth = false,
|
||||
currentDate = true,
|
||||
className,
|
||||
}) {
|
||||
const format = 'DD MMMM YYYY';
|
||||
const formattedFromDate = useMemo(
|
||||
() => moment(fromDate).format(format),
|
||||
[fromDate],
|
||||
);
|
||||
const formattedToDate = useMemo(
|
||||
() => moment(toDate).format(format),
|
||||
[toDate],
|
||||
);
|
||||
const formattedAsDate = useMemo(
|
||||
() => moment(asDate).format(format),
|
||||
[asDate],
|
||||
);
|
||||
const methodsLabels = useMemo(
|
||||
() => ({
|
||||
cash: intl.get('cash'),
|
||||
accrual: intl.get('accrual'),
|
||||
}),
|
||||
[],
|
||||
);
|
||||
const getBasisLabel = useCallback((b) => methodsLabels[b], [methodsLabels]);
|
||||
const basisLabel = useMemo(
|
||||
() => getBasisLabel(basis),
|
||||
[getBasisLabel, basis],
|
||||
);
|
||||
|
||||
return (
|
||||
<FinancialSheetRoot
|
||||
minimal={minimal}
|
||||
fullWidth={fullWidth}
|
||||
className={className}
|
||||
>
|
||||
{companyName && <FinancialSheetTitle>{companyName}</FinancialSheetTitle>}
|
||||
{sheetType && <FinancialSheetType>{sheetType}</FinancialSheetType>}
|
||||
|
||||
<FinancialSheetDate>
|
||||
<If condition={asDate}>
|
||||
<T id={'as'} /> {formattedAsDate}
|
||||
</If>
|
||||
<If condition={fromDate && toDate}>
|
||||
<T id={'from'} /> {formattedFromDate} | <T id={'to'} />{' '}
|
||||
{formattedToDate}
|
||||
</If>
|
||||
</FinancialSheetDate>
|
||||
|
||||
<FinancialSheetTable>{children}</FinancialSheetTable>
|
||||
<FinancialSheetAccountingBasis>
|
||||
{accountingBasis}
|
||||
</FinancialSheetAccountingBasis>
|
||||
|
||||
<FinancialSheetFooter>
|
||||
{basisLabel && (
|
||||
<FinancialSheetFooterBasis>
|
||||
<T id={'accounting_basis'} /> {basisLabel}
|
||||
</FinancialSheetFooterBasis>
|
||||
)}
|
||||
{currentDate && (
|
||||
<FinancialSheetFooterCurrentTime>
|
||||
{moment().format('YYYY MMM DD HH:MM')}
|
||||
</FinancialSheetFooterCurrentTime>
|
||||
)}
|
||||
</FinancialSheetFooter>
|
||||
</FinancialSheetRoot>
|
||||
);
|
||||
}
|
||||
85
src/components/FinancialSheet/FinancialSheetSkeleton.js
Normal file
85
src/components/FinancialSheet/FinancialSheetSkeleton.js
Normal file
@@ -0,0 +1,85 @@
|
||||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
|
||||
import { Align } from 'common';
|
||||
import { SkeletonText } from 'components';
|
||||
import DataTable from '../../components/DataTable'
|
||||
|
||||
import TableSkeletonRows from 'components/Datatable/TableSkeletonRows';
|
||||
import TableSkeletonHeader from 'components/Datatable/TableHeaderSkeleton';
|
||||
import { TableStyle } from 'common';
|
||||
import {
|
||||
FinancialSheetRoot,
|
||||
FinancialSheetTitle,
|
||||
FinancialSheetType,
|
||||
FinancialSheetDate,
|
||||
FinancialSheetTable,
|
||||
} from './StyledFinancialSheet';
|
||||
|
||||
/**
|
||||
* Financial sheet paper skeleton.
|
||||
* @returns {React.JSX}
|
||||
*/
|
||||
export function FinancialSheetSkeleton({
|
||||
minimal,
|
||||
fullWidth,
|
||||
titleCharsLength,
|
||||
typeCharsLength,
|
||||
dateCharsLength,
|
||||
skeletonTableColumns,
|
||||
}) {
|
||||
return (
|
||||
<FinancialSheetRoot minimal={minimal} fullWidth={fullWidth}>
|
||||
<FinancialSheetTitle>
|
||||
<SkeletonText charsLength={titleCharsLength} />
|
||||
</FinancialSheetTitle>
|
||||
|
||||
<FinancialSheetType>
|
||||
<SkeletonText charsLength={typeCharsLength} />
|
||||
</FinancialSheetType>
|
||||
|
||||
<FinancialSheetDate>
|
||||
<SkeletonText charsLength={dateCharsLength} />
|
||||
</FinancialSheetDate>
|
||||
|
||||
<FinancialSheetTable>
|
||||
<FinancialSkeletonTable
|
||||
columns={skeletonTableColumns}
|
||||
data={[]}
|
||||
noInitialFetch={true}
|
||||
expandable={true}
|
||||
styleName={TableStyle.Constrant}
|
||||
TableLoadingRenderer={TableSkeletonRows}
|
||||
TableHeaderSkeletonRenderer={TableSkeletonHeader}
|
||||
headerLoading={true}
|
||||
loading={true}
|
||||
/>
|
||||
</FinancialSheetTable>
|
||||
</FinancialSheetRoot>
|
||||
);
|
||||
}
|
||||
|
||||
FinancialSheetSkeleton.defaultProps = {
|
||||
titleCharsLength: 20,
|
||||
typeCharsLength: 40,
|
||||
dateCharsLength: 20,
|
||||
skeletonTableColumns: [
|
||||
{
|
||||
id: 'skeleton-1',
|
||||
className: 'skeleton-1',
|
||||
},
|
||||
{
|
||||
id: 'skeleton-2',
|
||||
className: 'skeleton-2',
|
||||
align: Align.Right,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const FinancialSkeletonTable = styled(DataTable)`
|
||||
.table .th .skeleton,
|
||||
.table .td .skeleton {
|
||||
margin-top: 4px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
`;
|
||||
9
src/components/FinancialSheet/ReportDataTable.js
Normal file
9
src/components/FinancialSheet/ReportDataTable.js
Normal file
@@ -0,0 +1,9 @@
|
||||
import styled from 'styled-components';
|
||||
|
||||
import DataTable from '../DataTable';
|
||||
|
||||
export const ReportDataTable = styled(DataTable)`
|
||||
.table .tbody .tr.no-results:last-of-type .td {
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
`;
|
||||
82
src/components/FinancialSheet/StyledFinancialSheet.js
Normal file
82
src/components/FinancialSheet/StyledFinancialSheet.js
Normal file
@@ -0,0 +1,82 @@
|
||||
import styled from 'styled-components';
|
||||
|
||||
export const FinancialSheetRoot = styled.div`
|
||||
border: 2px solid #f0f0f0;
|
||||
border-radius: 10px;
|
||||
min-width: 640px;
|
||||
width: auto;
|
||||
padding: 30px 18px;
|
||||
max-width: 100%;
|
||||
margin: 35px auto;
|
||||
min-height: 400px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: #fff;
|
||||
|
||||
${(props) =>
|
||||
props.fullWidth &&
|
||||
`
|
||||
width: 100%;
|
||||
margin-top: 25px;`}
|
||||
|
||||
${(props) =>
|
||||
props.minimal &&
|
||||
`
|
||||
border: 0;
|
||||
padding: 0;
|
||||
margin-top: 20px;
|
||||
|
||||
${FinancialSheetTitle} {
|
||||
font-size: 18px;
|
||||
color: #333;
|
||||
}
|
||||
${FinancialSheetTitle} + ${FinancialSheetDate} {
|
||||
margin-top: 8px;
|
||||
}
|
||||
${FinancialSheetDate} {
|
||||
margin-top: 20px;
|
||||
}
|
||||
`}
|
||||
`;
|
||||
|
||||
export const FinancialSheetTitle = styled.h1`
|
||||
margin: 0;
|
||||
font-weight: 400;
|
||||
font-size: 20px;
|
||||
color: #464646;
|
||||
text-align: center;
|
||||
`;
|
||||
|
||||
export const FinancialSheetType = styled.h6`
|
||||
text-align: center;
|
||||
margin: 0;
|
||||
font-size: 16px;
|
||||
font-weight: 400;
|
||||
color: #666;
|
||||
margin-top: 6px;
|
||||
`;
|
||||
|
||||
export const FinancialSheetDate = styled.div`
|
||||
text-align: center;
|
||||
color: #666;
|
||||
margin-top: 6px;
|
||||
`;
|
||||
|
||||
export const FinancialSheetFooter = styled.div`
|
||||
color: #888;
|
||||
text-align: center;
|
||||
margin-top: auto;
|
||||
padding-top: 18px;
|
||||
font-size: 13px;
|
||||
|
||||
> span + span {
|
||||
padding-left: 10px;
|
||||
}
|
||||
`;
|
||||
export const FinancialSheetTable = styled.div`
|
||||
margin-top: 24px;
|
||||
`;
|
||||
export const FinancialSheetFooterBasis = styled.span``;
|
||||
export const FinancialSheetFooterCurrentTime = styled.span``;
|
||||
|
||||
export const FinancialSheetAccountingBasis = styled.div``;
|
||||
3
src/components/FinancialSheet/index.js
Normal file
3
src/components/FinancialSheet/index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
export * from './FinancialSheet';
|
||||
export * from './FinancialSheetSkeleton';
|
||||
export * from './ReportDataTable';
|
||||
@@ -1,15 +1,24 @@
|
||||
import React from 'react';
|
||||
import className from 'classnames';
|
||||
import 'style/containers/FinancialStatements/FinancialSheet.scss';
|
||||
import styled from 'styled-components';
|
||||
|
||||
export default function FinancialStatements({ name, children }) {
|
||||
const FinancialStatementRoot = styled.div``;
|
||||
const FinancialStatementBodyRoot = styled.div``;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} param0
|
||||
* @returns
|
||||
*/
|
||||
export function FinancialStatement({ children, className }) {
|
||||
return <FinancialStatementRoot children={children} className={className} />;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {React.JSX}
|
||||
*/
|
||||
export function FinancialStatementBody({ children, className }) {
|
||||
return (
|
||||
<div
|
||||
className={className('financial-statement', {
|
||||
[`financial-statement--${name}`]: name,
|
||||
})}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
<FinancialStatementBodyRoot children={children} className={className} />
|
||||
);
|
||||
}
|
||||
|
||||
14
src/components/Forms/FormikObserver.js
Normal file
14
src/components/Forms/FormikObserver.js
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
import { useDeepCompareEffect } from 'hooks/utils';
|
||||
|
||||
export function FormikObserver({ onChange, values }) {
|
||||
useDeepCompareEffect(() => {
|
||||
onChange(values);
|
||||
}, [values]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
FormikObserver.defaultProps = {
|
||||
onChange: () => null,
|
||||
};
|
||||
@@ -1 +1,2 @@
|
||||
export * from './FormObserver';
|
||||
export * from './FormObserver';
|
||||
export * from './FormikObserver';
|
||||
@@ -1,13 +1,68 @@
|
||||
import React, { useState, useCallback, useEffect, useMemo } from 'react';
|
||||
import { MenuItem } from '@blueprintjs/core';
|
||||
import classNames from 'classnames';
|
||||
import { CLASSES } from 'common/classes';
|
||||
|
||||
import { Suggest } from '@blueprintjs/select';
|
||||
import classNames from 'classnames';
|
||||
import * as R from 'ramda';
|
||||
import intl from 'react-intl-universal';
|
||||
import { CLASSES } from 'common/classes';
|
||||
|
||||
import { FormattedMessage as T } from 'components';
|
||||
|
||||
export default function ItemsSuggestField({
|
||||
import withDrawerActions from 'containers/Drawer/withDrawerActions';
|
||||
|
||||
import { DRAWERS } from 'common/drawers';
|
||||
|
||||
// Creates a new item from query.
|
||||
const createNewItemFromQuery = (name) => {
|
||||
return {
|
||||
name,
|
||||
};
|
||||
};
|
||||
|
||||
// Handle quick create new customer.
|
||||
const createNewItemRenderer = (query, active, handleClick) => {
|
||||
return (
|
||||
<MenuItem
|
||||
icon="add"
|
||||
text={intl.get('list.create', { value: `"${query}"` })}
|
||||
active={active}
|
||||
shouldDismissPopover={false}
|
||||
onClick={handleClick}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
// Item renderer.
|
||||
const itemRenderer = (item, { modifiers, handleClick }) => (
|
||||
<MenuItem
|
||||
key={item.id}
|
||||
text={item.name}
|
||||
label={item.code}
|
||||
onClick={handleClick}
|
||||
/>
|
||||
);
|
||||
|
||||
// Filters items.
|
||||
const filterItemsPredicater = (query, item, _index, exactMatch) => {
|
||||
const normalizedTitle = item.name.toLowerCase();
|
||||
const normalizedQuery = query.toLowerCase();
|
||||
|
||||
if (exactMatch) {
|
||||
return normalizedTitle === normalizedQuery;
|
||||
} else {
|
||||
return `${normalizedTitle} ${item.code}`.indexOf(normalizedQuery) >= 0;
|
||||
}
|
||||
};
|
||||
|
||||
// Handle input value renderer.
|
||||
const handleInputValueRenderer = (inputValue) => {
|
||||
if (inputValue) {
|
||||
return inputValue.name.toString();
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
function ItemsSuggestField({
|
||||
items,
|
||||
initialItemId,
|
||||
selectedItemId,
|
||||
@@ -18,6 +73,10 @@ export default function ItemsSuggestField({
|
||||
sellable = false,
|
||||
purchasable = false,
|
||||
popoverFill = false,
|
||||
|
||||
allowCreate = true,
|
||||
|
||||
openDrawer,
|
||||
...suggestProps
|
||||
}) {
|
||||
// Filters items based on filter props.
|
||||
@@ -36,28 +95,23 @@ export default function ItemsSuggestField({
|
||||
// Find initial item object.
|
||||
const initialItem = useMemo(
|
||||
() => filteredItems.some((a) => a.id === initialItemId),
|
||||
[initialItemId],
|
||||
[initialItemId, filteredItems],
|
||||
);
|
||||
|
||||
const [selectedItem, setSelectedItem] = useState(initialItem || null);
|
||||
|
||||
const onItemSelect = useCallback(
|
||||
(item) => {
|
||||
setSelectedItem({ ...item });
|
||||
onItemSelected && onItemSelected(item);
|
||||
if (item.id) {
|
||||
setSelectedItem({ ...item });
|
||||
onItemSelected && onItemSelected(item);
|
||||
} else {
|
||||
openDrawer(DRAWERS.QUICK_CREATE_ITEM);
|
||||
}
|
||||
},
|
||||
[setSelectedItem, onItemSelected],
|
||||
[setSelectedItem, onItemSelected, openDrawer],
|
||||
);
|
||||
|
||||
const itemRenderer = useCallback((item, { modifiers, handleClick }) => (
|
||||
<MenuItem
|
||||
key={item.id}
|
||||
text={item.name}
|
||||
label={item.code}
|
||||
onClick={handleClick}
|
||||
/>
|
||||
));
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof selectedItemId !== 'undefined') {
|
||||
const item = selectedItemId
|
||||
@@ -67,27 +121,12 @@ export default function ItemsSuggestField({
|
||||
}
|
||||
}, [selectedItemId, filteredItems, setSelectedItem]);
|
||||
|
||||
const handleInputValueRenderer = (inputValue) => {
|
||||
if (inputValue) {
|
||||
return inputValue.name.toString();
|
||||
}
|
||||
return '';
|
||||
};
|
||||
// Maybe inject create new item props to suggest component.
|
||||
const maybeCreateNewItemRenderer = allowCreate ? createNewItemRenderer : null;
|
||||
const maybeCreateNewItemFromQuery = allowCreate
|
||||
? createNewItemFromQuery
|
||||
: null;
|
||||
|
||||
// Filters items.
|
||||
const filterItemsPredicater = useCallback(
|
||||
(query, item, _index, exactMatch) => {
|
||||
const normalizedTitle = item.name.toLowerCase();
|
||||
const normalizedQuery = query.toLowerCase();
|
||||
|
||||
if (exactMatch) {
|
||||
return normalizedTitle === normalizedQuery;
|
||||
} else {
|
||||
return `${normalizedTitle} ${item.code}`.indexOf(normalizedQuery) >= 0;
|
||||
}
|
||||
},
|
||||
[],
|
||||
);
|
||||
return (
|
||||
<Suggest
|
||||
items={filteredItems}
|
||||
@@ -104,7 +143,12 @@ export default function ItemsSuggestField({
|
||||
className={classNames(CLASSES.FORM_GROUP_LIST_SELECT, {
|
||||
[CLASSES.SELECT_LIST_FILL_POPOVER]: popoverFill,
|
||||
})}
|
||||
createNewItemRenderer={maybeCreateNewItemRenderer}
|
||||
createNewItemFromQuery={maybeCreateNewItemFromQuery}
|
||||
createNewItemPosition={'top'}
|
||||
{...suggestProps}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export default R.compose(withDrawerActions)(ItemsSuggestField);
|
||||
|
||||
36
src/components/MoreMenutItems.js
Normal file
36
src/components/MoreMenutItems.js
Normal file
@@ -0,0 +1,36 @@
|
||||
import React from 'react';
|
||||
import {
|
||||
Button,
|
||||
Popover,
|
||||
PopoverInteractionKind,
|
||||
Position,
|
||||
MenuItem,
|
||||
Menu,
|
||||
} from '@blueprintjs/core';
|
||||
|
||||
import { Icon, FormattedMessage as T } from 'components';
|
||||
|
||||
function MoreMenuItems({ payload: { onNotifyViaSMS } }) {
|
||||
return (
|
||||
<Popover
|
||||
minimal={true}
|
||||
content={
|
||||
<Menu>
|
||||
<MenuItem
|
||||
onClick={onNotifyViaSMS}
|
||||
text={<T id={'notify_via_sms.dialog.notify_via_sms'} />}
|
||||
/>
|
||||
</Menu>
|
||||
}
|
||||
interactionKind={PopoverInteractionKind.CLICK}
|
||||
position={Position.BOTTOM_LEFT}
|
||||
modifiers={{
|
||||
offset: { offset: '0, 4' },
|
||||
}}
|
||||
>
|
||||
<Button icon={<Icon icon="more-vert" iconSize={16} />} minimal={true} />
|
||||
</Popover>
|
||||
);
|
||||
}
|
||||
|
||||
export default MoreMenuItems;
|
||||
@@ -1,6 +1,8 @@
|
||||
import React from 'react';
|
||||
import { ErrorBoundary } from 'react-error-boundary';
|
||||
import classNames from 'classnames';
|
||||
import * as R from 'ramda';
|
||||
|
||||
import { CLASSES } from 'common/classes';
|
||||
|
||||
import PreferencesTopbar from 'components/Preferences/PreferencesTopbar';
|
||||
@@ -8,18 +10,28 @@ import PreferencesContentRoute from 'components/Preferences/PreferencesContentRo
|
||||
import DashboardErrorBoundary from 'components/Dashboard/DashboardErrorBoundary';
|
||||
import PreferencesSidebar from 'components/Preferences/PreferencesSidebar';
|
||||
|
||||
import withDashboardActions from 'containers/Dashboard/withDashboardActions';
|
||||
|
||||
import 'style/pages/Preferences/Page.scss';
|
||||
|
||||
/**
|
||||
* Preferences page.
|
||||
*/
|
||||
export default function PreferencesPage() {
|
||||
function PreferencesPage({ toggleSidebarExpand }) {
|
||||
// Shrink the dashboard sidebar once open application preferences page.
|
||||
React.useEffect(() => {
|
||||
toggleSidebarExpand(false);
|
||||
}, [toggleSidebarExpand]);
|
||||
|
||||
return (
|
||||
<ErrorBoundary FallbackComponent={DashboardErrorBoundary}>
|
||||
<div id={'dashboard'} className={classNames(
|
||||
CLASSES.DASHBOARD_CONTENT,
|
||||
CLASSES.DASHBOARD_CONTENT_PREFERENCES,
|
||||
)}>
|
||||
<div
|
||||
id={'dashboard'}
|
||||
className={classNames(
|
||||
CLASSES.DASHBOARD_CONTENT,
|
||||
CLASSES.DASHBOARD_CONTENT_PREFERENCES,
|
||||
)}
|
||||
>
|
||||
<div className={classNames(CLASSES.PREFERENCES_PAGE)}>
|
||||
<PreferencesSidebar />
|
||||
|
||||
@@ -32,3 +44,5 @@ export default function PreferencesPage() {
|
||||
</ErrorBoundary>
|
||||
);
|
||||
}
|
||||
|
||||
export default R.compose(withDashboardActions)(PreferencesPage);
|
||||
|
||||
46
src/components/SMSPreview/index.js
Normal file
46
src/components/SMSPreview/index.js
Normal file
@@ -0,0 +1,46 @@
|
||||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
|
||||
import { Icon } from 'components';
|
||||
|
||||
/**
|
||||
* SMS Message preview.
|
||||
*/
|
||||
export function SMSMessagePreview({
|
||||
message,
|
||||
iconWidth = '265px',
|
||||
iconHeight = '287px',
|
||||
iconColor = '#adadad',
|
||||
}) {
|
||||
return (
|
||||
<SMSMessagePreviewBase>
|
||||
<Icon
|
||||
icon={'sms-message-preview'}
|
||||
width={iconWidth}
|
||||
height={iconHeight}
|
||||
color={iconColor}
|
||||
/>
|
||||
<SMSMessageText>{message}</SMSMessageText>
|
||||
</SMSMessagePreviewBase>
|
||||
);
|
||||
}
|
||||
|
||||
const SMSMessageText = styled.div`
|
||||
position: absolute;
|
||||
top: 60px;
|
||||
padding: 12px;
|
||||
color: #fff;
|
||||
border-radius: 12px;
|
||||
margin-left: 12px;
|
||||
margin-right: 12px;
|
||||
word-break: break-word;
|
||||
background: #2fa2e4;
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
`;
|
||||
|
||||
const SMSMessagePreviewBase = styled.div`
|
||||
position: relative;
|
||||
width: 265px;
|
||||
margin: 0 auto;
|
||||
`;
|
||||
@@ -1,20 +1,37 @@
|
||||
import React from 'react';
|
||||
|
||||
import SidebarContainer from 'components/Sidebar/SidebarContainer';
|
||||
import SidebarHead from 'components/Sidebar/SidebarHead';
|
||||
import SidebarMenu from 'components/Sidebar/SidebarMenu';
|
||||
import { useGetSidebarMenu } from './utils';
|
||||
|
||||
import 'style/containers/Dashboard/Sidebar.scss';
|
||||
|
||||
export default function Sidebar({ dashboardContentRef }) {
|
||||
const menu = useGetSidebarMenu();
|
||||
|
||||
return (
|
||||
<SidebarContainer>
|
||||
<SidebarHead />
|
||||
|
||||
<div className="sidebar__menu">
|
||||
<SidebarMenu />
|
||||
<SidebarMenu menu={menu} />
|
||||
</div>
|
||||
|
||||
<div class="sidebar__version">0.0.1-beta version.</div>
|
||||
<SidebarFooterVersion />
|
||||
</SidebarContainer>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sidebar footer version.
|
||||
* @returns {React.JSX}
|
||||
*/
|
||||
function SidebarFooterVersion() {
|
||||
const { VERSION } = process.env;
|
||||
|
||||
if (!VERSION) {
|
||||
return null;
|
||||
}
|
||||
return <div class="sidebar__version">v{VERSION}</div>;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Button, Popover, Menu, Position } from '@blueprintjs/core';
|
||||
import Icon from 'components/Icon';
|
||||
import { compose, firstLettersArgs } from 'utils';
|
||||
import withCurrentOrganization from '../../containers/Organization/withCurrentOrganization';
|
||||
import { useAuthenticatedUser } from '../Dashboard/AuthenticatedUser';
|
||||
import { useAuthenticatedAccount } from '../../hooks/query';
|
||||
|
||||
// Popover modifiers.
|
||||
const POPOVER_MODIFIERS = {
|
||||
@@ -18,7 +18,7 @@ function SidebarHead({
|
||||
organization,
|
||||
}) {
|
||||
// Retrieve authenticated user information.
|
||||
const { user } = useAuthenticatedUser();
|
||||
const { data: user } = useAuthenticatedAccount();
|
||||
|
||||
return (
|
||||
<div className="sidebar__head">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import { Menu, MenuDivider } from '@blueprintjs/core';
|
||||
import { useHistory, useLocation } from 'react-router-dom';
|
||||
import sidebarMenuList from 'config/sidebarMenu';
|
||||
|
||||
import { Choose } from 'components';
|
||||
import Icon from 'components/Icon';
|
||||
import MenuItem from 'components/MenuItem';
|
||||
@@ -24,7 +24,7 @@ function SidebarMenuItemSpace({ space }) {
|
||||
return <div class="bp3-menu-spacer" style={{ height: `${space}px` }} />;
|
||||
}
|
||||
|
||||
function SidebarMenu({ isSubscriptionActive }) {
|
||||
function SidebarMenu({ menu, isSubscriptionActive }) {
|
||||
const history = useHistory();
|
||||
const location = useLocation();
|
||||
|
||||
@@ -93,7 +93,7 @@ function SidebarMenu({ isSubscriptionActive }) {
|
||||
});
|
||||
};
|
||||
|
||||
const filterItems = sidebarMenuList.filter(
|
||||
const filterItems = menu.filter(
|
||||
(item) => isSubscriptionActive || item.enableBilling,
|
||||
);
|
||||
const items = menuItemsMapper(filterItems);
|
||||
|
||||
48
src/components/Sidebar/utils.js
Normal file
48
src/components/Sidebar/utils.js
Normal file
@@ -0,0 +1,48 @@
|
||||
import sidebarMenuList from 'config/sidebarMenu';
|
||||
import { isArray, isEmpty } from 'lodash';
|
||||
import { useAbilityContext } from 'hooks/utils';
|
||||
|
||||
export function useGetSidebarMenu() {
|
||||
const ability = useAbilityContext();
|
||||
|
||||
return sidebarMenuList
|
||||
.map((item) => {
|
||||
const children = isArray(item.children)
|
||||
? item.children.filter((childItem) => {
|
||||
return isArray(childItem.permission)
|
||||
? childItem.permission.some((perm) =>
|
||||
ability.can(perm.ability, perm.subject),
|
||||
)
|
||||
: childItem?.permission?.ability && childItem?.permission?.subject
|
||||
? ability.can(
|
||||
childItem.permission.ability,
|
||||
childItem.permission.subject,
|
||||
)
|
||||
: true;
|
||||
})
|
||||
: [];
|
||||
|
||||
return {
|
||||
...item,
|
||||
...(isArray(item.children)
|
||||
? {
|
||||
children,
|
||||
}
|
||||
: {}),
|
||||
};
|
||||
})
|
||||
.filter((item) => {
|
||||
return isArray(item.permission)
|
||||
? item.permission.some((per) =>
|
||||
ability.can(per.ability, per.subject),
|
||||
)
|
||||
: item?.permission?.ability && item?.permission?.subject
|
||||
? ability.can(item.permission.ability, item.permission.subject)
|
||||
: true;
|
||||
})
|
||||
.filter((item) =>
|
||||
isEmpty(item.children) && !item.href && !item.label && !item.divider
|
||||
? false
|
||||
: true,
|
||||
);
|
||||
}
|
||||
@@ -6,14 +6,36 @@ import { randomNumber } from 'utils';
|
||||
/**
|
||||
* Skeleton component.
|
||||
*/
|
||||
export default function Skeleton({
|
||||
export function Skeleton({
|
||||
Tag = 'span',
|
||||
minWidth = 40,
|
||||
maxWidth = 100,
|
||||
children,
|
||||
}) {
|
||||
const randomWidth = useMemo(() => randomNumber(minWidth, maxWidth), [
|
||||
minWidth,
|
||||
maxWidth,
|
||||
]);
|
||||
return <Tag className={'skeleton'} style={{ width: `${randomWidth}%` }} />;
|
||||
const randomWidth = useMemo(
|
||||
() => randomNumber(minWidth, maxWidth),
|
||||
[minWidth, maxWidth],
|
||||
);
|
||||
return (
|
||||
<Tag
|
||||
className={'skeleton'}
|
||||
style={{ width: `${randomWidth}%` }}
|
||||
children={children}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export function SkeletonText({
|
||||
Tag = 'span',
|
||||
charsLength,
|
||||
minChars = 40,
|
||||
maxChars = 100,
|
||||
}) {
|
||||
const computedCharLength = useMemo(
|
||||
() => (charsLength ? charsLength : randomNumber(minChars, maxChars)),
|
||||
[charsLength, minChars, maxChars],
|
||||
);
|
||||
const randamText = 'X'.repeat(computedCharLength);
|
||||
|
||||
return <Tag className={'skeleton'}>{randamText}</Tag>;
|
||||
}
|
||||
|
||||
33
src/components/Table/index.js
Normal file
33
src/components/Table/index.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import styled from 'styled-components';
|
||||
|
||||
export const Table = styled.table`
|
||||
width: 100%;
|
||||
vertical-align: top;
|
||||
border-color: #dee2e6;
|
||||
border-spacing: 0;
|
||||
`;
|
||||
export const TBody = styled.tbody``;
|
||||
export const TR = styled.tr``;
|
||||
export const TD = styled.td`
|
||||
padding: 0.5rem 0.5rem;
|
||||
border-bottom-width: 1px;
|
||||
border-bottom-color: inherit;
|
||||
border-bottom-style: solid;
|
||||
|
||||
${(props) =>
|
||||
props.textAlign === 'right' &&
|
||||
`
|
||||
text-align: right;`}
|
||||
`;
|
||||
|
||||
export const TRDarkSingleLine = styled(TR)`
|
||||
${TD} {
|
||||
border-bottom: 1px solid #000;
|
||||
}
|
||||
`;
|
||||
|
||||
export const TRDarkDoubleLines = styled(TR)`
|
||||
${TD} {
|
||||
border-bottom: 3px double #000;
|
||||
}
|
||||
`;
|
||||
11
src/components/Tags/CurrencyTag.js
Normal file
11
src/components/Tags/CurrencyTag.js
Normal file
@@ -0,0 +1,11 @@
|
||||
import styled from 'styled-components';
|
||||
|
||||
export const CurrencyTag = styled.span`
|
||||
background: #3e9215;
|
||||
color: #fff;
|
||||
display: inline-block;
|
||||
border-radius: 3px;
|
||||
padding: 2px 4px;
|
||||
line-height: 1;
|
||||
margin-left: 4px;
|
||||
`;
|
||||
3
src/components/Tags/index.js
Normal file
3
src/components/Tags/index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
|
||||
export * from './CurrencyTag';
|
||||
28
src/components/TextStatus/index.js
Normal file
28
src/components/TextStatus/index.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
|
||||
export function TextStatus({ intent, children }) {
|
||||
return <TextStatusRoot intent={intent}>{children}</TextStatusRoot>;
|
||||
}
|
||||
|
||||
const TextStatusRoot = styled.span`
|
||||
${(props) =>
|
||||
props.intent === 'warning' &&
|
||||
`
|
||||
color: #ec5b0a;`}
|
||||
|
||||
${(props) =>
|
||||
props.intent === 'success' &&
|
||||
`
|
||||
color: #2ba01d;`}
|
||||
|
||||
${(props) =>
|
||||
props.intent === 'none' &&
|
||||
`
|
||||
color: #777;`}
|
||||
|
||||
${(props) =>
|
||||
props.intent === 'primary' &&
|
||||
`
|
||||
color: #1652c8;`}
|
||||
`;
|
||||
@@ -1,12 +0,0 @@
|
||||
.total_lines {}
|
||||
|
||||
|
||||
.total_line {
|
||||
display: flex;
|
||||
border-bottom: 1px solid #d2dde2;
|
||||
|
||||
:global .amount,
|
||||
:global .title{
|
||||
padding: 8px;
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,93 @@
|
||||
import React from 'react';
|
||||
import clsx from 'classnames';
|
||||
import styled from 'styled-components';
|
||||
|
||||
import TotalLinesCls from './TotalLines.module.scss';
|
||||
export const TotalLineBorderStyle = {
|
||||
SingleDark: 'SingleDark',
|
||||
DoubleDark: 'DoubleDark',
|
||||
};
|
||||
|
||||
export function TotalLines({ children, className }) {
|
||||
export const TotalLineTextStyle = {
|
||||
Regular: 'Regular',
|
||||
Bold: 'Bold',
|
||||
};
|
||||
|
||||
export function TotalLines({
|
||||
children,
|
||||
amountColWidth,
|
||||
labelColWidth,
|
||||
className,
|
||||
}) {
|
||||
return (
|
||||
<div className={clsx('total_lines', TotalLinesCls.total_lines, className)}>
|
||||
<TotalLinesRoot
|
||||
className={className}
|
||||
amountColWidth={amountColWidth}
|
||||
labelColWidth={labelColWidth}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
</TotalLinesRoot>
|
||||
);
|
||||
}
|
||||
|
||||
export function TotalLine({ title, value, className }) {
|
||||
export function TotalLine({ title, value, borderStyle, textStyle, className }) {
|
||||
return (
|
||||
<div
|
||||
className={clsx('total_lines_line', TotalLinesCls.total_line, className)}
|
||||
<TotalLineRoot
|
||||
borderStyle={borderStyle}
|
||||
textStyle={textStyle}
|
||||
className={className}
|
||||
>
|
||||
<div class="title">{title}</div>
|
||||
<div class="amount">{value}</div>
|
||||
</div>
|
||||
</TotalLineRoot>
|
||||
);
|
||||
}
|
||||
|
||||
export const TotalLinesRoot = styled.div`
|
||||
display: table;
|
||||
|
||||
${(props) =>
|
||||
props.amountColWidth &&
|
||||
`
|
||||
.amount{
|
||||
width: ${props.amountColWidth}
|
||||
}
|
||||
`}
|
||||
|
||||
${(props) =>
|
||||
props.labelColWidth &&
|
||||
`
|
||||
.title{
|
||||
width: ${props.labelColWidth}
|
||||
}
|
||||
`}
|
||||
`;
|
||||
|
||||
export const TotalLineRoot = styled.div`
|
||||
display: table-row;
|
||||
|
||||
.amount,
|
||||
.title {
|
||||
display: table-cell;
|
||||
padding: 8px;
|
||||
border-bottom: 1px solid #d2dde2;
|
||||
|
||||
${(props) =>
|
||||
props.borderStyle === TotalLineBorderStyle.DoubleDark &&
|
||||
`
|
||||
border-bottom: 3px double #000;
|
||||
`}
|
||||
${(props) =>
|
||||
props.borderStyle === TotalLineBorderStyle.SingleDark &&
|
||||
`
|
||||
border-bottom: 1px double #000;
|
||||
`}
|
||||
${(props) =>
|
||||
props.textStyle === TotalLineTextStyle.Bold &&
|
||||
`
|
||||
font-weight: 600;
|
||||
`}
|
||||
}
|
||||
|
||||
.amount {
|
||||
text-align: right;
|
||||
}
|
||||
`;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user