From 5861fe2c39f956ff7fc1de853957c1e282da8710 Mon Sep 17 00:00:00 2001 From: Jenny <42087770+jayhoney@users.noreply.github.com> Date: Fri, 20 Nov 2020 18:49:03 +0300 Subject: [PATCH] Shops table update (#316) * implemented basic logic of new shop tables * fixed karma * refactored implementation, removed unused code * added tests * changed tests configs * fixed linter * fixed review issues * fixed ci * test ci * fixed startWith generics, added todos * fixed review issues * fixed review issues * fixed review issues * fixed review issues * fixed reload bug * added tslint rules, fixed review issues, added some tests * fixed build errors Co-authored-by: egrigorieva --- karma.conf.js | 2 +- package-lock.json | 281 ++++++++++ package.json | 4 +- src/app/api/analytics/analytics.service.ts | 12 +- .../{shop.service.ts => api-shops.service.ts} | 4 +- src/app/api/shop/index.ts | 2 +- src/app/api/shop/shop.module.ts | 4 +- src/app/app.component.ts | 2 +- .../actionbar/actionbar.component.ts | 2 +- src/app/container/brand/brand.component.ts | 2 +- .../toolbar/toolbar-links.service.ts | 4 +- .../container/toolbar/toolbar.component.ts | 2 +- .../create-invoice-template.service.ts | 5 +- .../create-invoice/create-invoice.service.ts | 3 +- ...ate-shop-russian-legal-entity.component.ts | 4 +- ...reate-shop-russian-legal-entity.service.ts | 4 +- .../status-details-item.component.ts | 2 +- .../main/parts/payments/payments.service.ts | 4 +- ...authority-confirming-document.component.ts | 3 +- .../page-not-found.component.ts | 2 +- .../details/details.component.ts | 2 +- .../cancel-hold/cancel-hold.component.ts | 2 +- .../confirm-hold/confirm-hold.component.ts | 2 +- .../hold-details/hold-details.component.ts | 2 +- .../invoice-details.component.ts | 2 +- .../make-recurrent.component.ts | 2 +- .../customer-payer.component.ts | 2 +- .../payer-details/payer-details.component.ts | 2 +- .../payment-resource-payer.component.ts | 2 +- .../payment-details.component.ts | 2 +- .../bank-card/bank-card.component.ts | 2 +- .../digital-wallet.component.ts | 2 +- .../payment-terminal.component.ts | 2 +- .../payment-tool/payment-tool.component.ts | 2 +- .../recurrent-details.component.ts | 2 +- .../create-refund/create-refund.component.ts | 2 +- .../create-refund/create-refund.service.ts | 4 +- .../refund-item/refund-item.component.ts | 2 +- .../refunds/refunds.component.ts | 2 +- .../payment-details/refunds/refunds.module.ts | 4 +- .../status-details-item.component.ts | 2 +- .../analytics-search-filters.component.ts | 4 +- .../analytics-search-filters.module.ts | 4 +- .../average-payment.component.ts | 2 +- .../bar-chart-item.component.ts | 2 +- .../donut-chart-item.component.ts | 2 +- .../payment-split-amount.component.ts | 2 +- .../payment-split-count.component.ts | 2 +- .../payments-amount.component.ts | 2 +- .../payments-count.component.ts | 2 +- .../payments-error-distribution.component.ts | 2 +- .../payments-tool-distribution.component.ts | 2 +- .../percent-difference.component.ts | 2 +- .../refunds-amount.component.ts | 2 +- .../stat-item/stat-item.component.ts | 2 +- ...ate-invoice-or-invoice-template.service.ts | 4 +- .../create-shop-dialog.component.html | 0 .../create-shop-dialog.component.scss | 0 .../create-shop-dialog.component.spec.ts | 1 + .../create-shop-dialog.component.ts | 0 .../shops/create-shop-dialog/index.ts | 1 - .../services/fetch-shops/combine-shop-item.ts | 21 + .../fetch-shops/fetch-shops.service.spec.ts | 485 ++++++++++++++++++ .../fetch-shops/fetch-shops.service.ts | 124 +++++ .../shops-balance.service.spec.ts | 201 ++++++++ .../shops-balance/shops-balance.service.ts | 44 ++ .../shop-row-header.component.html | 10 + .../shop-row-header.component.spec.ts | 1 + .../shop-row-header.component.ts | 8 + .../shop-row/shop-row.component.html | 14 + .../shop-row/shop-row.component.spec.ts | 1 + .../components/shop-row/shop-row.component.ts | 12 + .../shops-expanded-id-manager.service.spec.ts | 16 + .../shops-expanded-id-manager.service.ts | 19 + .../shops/shops-list/shop-balance/index.ts | 1 + .../shop-balance/shop-balance.component.html | 8 + .../shop-balance.component.spec.ts | 58 +++ .../shop-balance/shop-balance.component.ts | 12 + .../shop-balance/shop-balance.module.ts | 12 + .../shop-actions/shop-actions.component.html | 22 + .../shop-actions.component.spec.ts | 226 ++++++++ .../shop-actions/shop-actions.component.ts | 38 ++ .../shop-contract-details.component.html | 0 .../shop-contract-details.component.spec.ts | 1 + .../shop-contract-details.component.ts | 2 +- .../components/shop-id/shop-id.component.html | 9 + .../shop-id/shop-id.component.spec.ts | 60 +++ .../components/shop-id/shop-id.component.ts | 18 + .../shop-info/shop-info.component.html | 15 + .../shop-info/shop-info.component.spec.ts | 102 ++++ .../shop-info/shop-info.component.ts | 32 ++ .../shop-payout-tool-details.component.html | 0 ...shop-payout-tool-details.component.spec.ts | 1 + .../shop-payout-tool-details.component.ts | 4 +- .../shops/shops-list/shop-details/index.ts | 2 + .../category/category.service.spec.ts | 16 + .../services/category/category.service.ts | 27 + .../shop-actions/is-successful-shop-action.ts | 5 + .../shop-actions/shop-actions.service.spec.ts | 16 + .../shop-actions/shop-actions.service.ts | 61 +++ .../shop-contract-details.service.spec.ts | 1 + .../shop-contract-details.service.ts | 4 +- .../shop-payout-tool-details.service.spec.ts | 1 + .../shop-payout-tool-details.service.ts | 6 +- .../shop-details/shop-details.component.html | 15 + .../shop-details.component.spec.ts | 24 + .../shop-details/shop-details.component.ts | 18 + .../shop-details/shop-details.module.ts | 49 ++ .../shop-details/types}/payout-tool-params.ts | 0 .../shop-details/types/shop-action-result.ts | 4 + .../shops/shops-list/shop-list.module.ts | 39 ++ .../shops-list/shops-list.component.html | 36 ++ .../shops-list/shops-list.component.spec.ts | 24 + .../shops/shops-list/shops-list.component.ts | 46 ++ .../shops/shops-panels-list/category.pipe.ts | 31 -- .../shops/shops-panels-list/index.ts | 2 - .../shops-panels-list/shop-balance/index.ts | 1 - .../shop-balance/shop-balance.component.html | 4 - .../shop-balance/shop-balance.component.ts | 23 - .../shop-balance/shop-balance.service.ts | 37 -- .../shop-contract-details/index.ts | 1 - .../shop-payout-tool-details/index.ts | 2 - .../shops-panels-list.component.html | 89 ---- .../shops-panels-list.component.ts | 51 -- .../shops-panels-list.module.ts | 59 --- .../shops-panels-list.service.ts | 55 -- .../integrations/shops/shops.component.html | 32 +- .../shops/shops.component.spec.ts | 1 + .../integrations/shops/shops.component.ts | 54 +- .../integrations/shops/shops.module.ts | 12 +- .../integrations/shops/shops.service.ts | 69 --- .../integrations/shops/types/shop-balance.ts | 6 + .../integrations/shops/types/shop-item.ts | 6 + .../create-webhook-form.component.ts | 6 +- .../webhook-details/webhook-details.module.ts | 2 +- .../webhook-list/webhook-list.module.ts | 2 +- .../operations/invoices/invoices.service.ts | 4 +- .../operations/payments/payments.service.ts | 4 +- .../search-form/search-form.service.ts | 4 +- .../operations/refunds/refunds.service.ts | 4 +- .../create-payout-dialog.component.ts | 4 +- .../create-payout-dialog.service.ts | 4 +- .../create-payout/create-payout.module.ts | 2 +- .../payouts-details/payouts-details.module.ts | 3 +- .../payouts-list/payouts-list.module.ts | 2 +- .../payouts-search-filters.component.ts | 4 +- .../payouts-search-filters.module.ts | 2 +- .../create-report-dialog.component.ts | 4 +- .../shop-details/shop-details.component.ts | 2 +- .../shop-details/shop-details.service.ts | 4 +- .../shop-location-url.component.ts | 2 +- .../shop-selector/shop-selector.component.ts | 4 +- .../account-info/account-info.component.ts | 2 +- .../deposits/deposits.component.ts | 2 +- .../wallet-details-headline.component.ts | 2 +- .../withdrawals/withdrawals.component.ts | 2 +- .../webhook-details/webhook-details.module.ts | 2 +- .../pipes/api-model-refs/shop-details.pipe.ts | 4 +- src/app/test-shop.service.ts | 4 +- .../charts/bar-chart/bar-chart.component.ts | 2 +- .../donut-chart/donut-chart.component.ts | 2 +- .../multi-value-filter.component.ts | 6 +- .../radio-group-filter.component.ts | 2 +- .../value-filter/value-filter.component.ts | 2 +- src/type-utils/dict.ts | 3 + src/type-utils/index.ts | 1 + tsconfig.json | 2 +- tslint.json | 30 +- 168 files changed, 2467 insertions(+), 602 deletions(-) rename src/app/api/shop/{shop.service.ts => api-shops.service.ts} (94%) rename src/app/sections/payment-section/integrations/shops/{ => components}/create-shop-dialog/create-shop-dialog.component.html (100%) rename src/app/sections/payment-section/integrations/shops/{ => components}/create-shop-dialog/create-shop-dialog.component.scss (100%) create mode 100644 src/app/sections/payment-section/integrations/shops/components/create-shop-dialog/create-shop-dialog.component.spec.ts rename src/app/sections/payment-section/integrations/shops/{ => components}/create-shop-dialog/create-shop-dialog.component.ts (100%) delete mode 100644 src/app/sections/payment-section/integrations/shops/create-shop-dialog/index.ts create mode 100644 src/app/sections/payment-section/integrations/shops/services/fetch-shops/combine-shop-item.ts create mode 100644 src/app/sections/payment-section/integrations/shops/services/fetch-shops/fetch-shops.service.spec.ts create mode 100644 src/app/sections/payment-section/integrations/shops/services/fetch-shops/fetch-shops.service.ts create mode 100644 src/app/sections/payment-section/integrations/shops/services/shops-balance/shops-balance.service.spec.ts create mode 100644 src/app/sections/payment-section/integrations/shops/services/shops-balance/shops-balance.service.ts create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/components/shop-row-header/shop-row-header.component.html create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/components/shop-row-header/shop-row-header.component.spec.ts create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/components/shop-row-header/shop-row-header.component.ts create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/components/shop-row/shop-row.component.html create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/components/shop-row/shop-row.component.spec.ts create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/components/shop-row/shop-row.component.ts create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/services/shops-expanded-id-manager/shops-expanded-id-manager.service.spec.ts create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/services/shops-expanded-id-manager/shops-expanded-id-manager.service.ts create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/shop-balance/index.ts create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/shop-balance/shop-balance.component.html create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/shop-balance/shop-balance.component.spec.ts create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/shop-balance/shop-balance.component.ts create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/shop-balance/shop-balance.module.ts create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-actions/shop-actions.component.html create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-actions/shop-actions.component.spec.ts create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-actions/shop-actions.component.ts rename src/app/sections/payment-section/integrations/shops/{shops-panels-list => shops-list/shop-details/components}/shop-contract-details/shop-contract-details.component.html (100%) create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-contract-details/shop-contract-details.component.spec.ts rename src/app/sections/payment-section/integrations/shops/{shops-panels-list => shops-list/shop-details/components}/shop-contract-details/shop-contract-details.component.ts (85%) create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-id/shop-id.component.html create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-id/shop-id.component.spec.ts create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-id/shop-id.component.ts create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-info/shop-info.component.html create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-info/shop-info.component.spec.ts create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-info/shop-info.component.ts rename src/app/sections/payment-section/integrations/shops/{shops-panels-list => shops-list/shop-details/components}/shop-payout-tool-details/shop-payout-tool-details.component.html (100%) create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-payout-tool-details/shop-payout-tool-details.component.spec.ts rename src/app/sections/payment-section/integrations/shops/{shops-panels-list => shops-list/shop-details/components}/shop-payout-tool-details/shop-payout-tool-details.component.ts (78%) create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/shop-details/index.ts create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/shop-details/services/category/category.service.spec.ts create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/shop-details/services/category/category.service.ts create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/shop-details/services/shop-actions/is-successful-shop-action.ts create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/shop-details/services/shop-actions/shop-actions.service.spec.ts create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/shop-details/services/shop-actions/shop-actions.service.ts create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/shop-details/services/shop-contract-details/shop-contract-details.service.spec.ts rename src/app/sections/payment-section/integrations/shops/{shops-panels-list => shops-list/shop-details/services}/shop-contract-details/shop-contract-details.service.ts (90%) create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/shop-details/services/shop-payout-tool-details/shop-payout-tool-details.service.spec.ts rename src/app/sections/payment-section/integrations/shops/{shops-panels-list => shops-list/shop-details/services}/shop-payout-tool-details/shop-payout-tool-details.service.ts (88%) create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/shop-details/shop-details.component.html create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/shop-details/shop-details.component.spec.ts create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/shop-details/shop-details.component.ts create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/shop-details/shop-details.module.ts rename src/app/sections/payment-section/integrations/shops/{shops-panels-list/shop-payout-tool-details => shops-list/shop-details/types}/payout-tool-params.ts (100%) create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/shop-details/types/shop-action-result.ts create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/shop-list.module.ts create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/shops-list.component.html create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/shops-list.component.spec.ts create mode 100644 src/app/sections/payment-section/integrations/shops/shops-list/shops-list.component.ts delete mode 100644 src/app/sections/payment-section/integrations/shops/shops-panels-list/category.pipe.ts delete mode 100644 src/app/sections/payment-section/integrations/shops/shops-panels-list/index.ts delete mode 100644 src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-balance/index.ts delete mode 100644 src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-balance/shop-balance.component.html delete mode 100644 src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-balance/shop-balance.component.ts delete mode 100644 src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-balance/shop-balance.service.ts delete mode 100644 src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-contract-details/index.ts delete mode 100644 src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-payout-tool-details/index.ts delete mode 100644 src/app/sections/payment-section/integrations/shops/shops-panels-list/shops-panels-list.component.html delete mode 100644 src/app/sections/payment-section/integrations/shops/shops-panels-list/shops-panels-list.component.ts delete mode 100644 src/app/sections/payment-section/integrations/shops/shops-panels-list/shops-panels-list.module.ts delete mode 100644 src/app/sections/payment-section/integrations/shops/shops-panels-list/shops-panels-list.service.ts create mode 100644 src/app/sections/payment-section/integrations/shops/shops.component.spec.ts delete mode 100644 src/app/sections/payment-section/integrations/shops/shops.service.ts create mode 100644 src/app/sections/payment-section/integrations/shops/types/shop-balance.ts create mode 100644 src/app/sections/payment-section/integrations/shops/types/shop-item.ts create mode 100644 src/type-utils/dict.ts diff --git a/karma.conf.js b/karma.conf.js index 6a4bebe7..51bd9bfd 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -26,7 +26,7 @@ module.exports = function (config) { colors: true, logLevel: config.LOG_INFO, autoWatch: true, - browsers: ['Chrome'], + browsers: ['ChromeHeadless'], singleRun: false, restartOnFileChange: true, }); diff --git a/package-lock.json b/package-lock.json index 2fe48a1d..70691988 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3246,6 +3246,16 @@ "source-map": "^0.6.1" } }, + "@types/yauzl": { + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.9.1.tgz", + "integrity": "sha512-A1b8SU4D10uoPjwb0lnHmmu8wZhR9d+9o2PKBQT2jU5YPTKsxac6M2qGAdY7VcL+dHHhARVUDmeg0rOrcd9EjA==", + "dev": true, + "optional": true, + "requires": { + "@types/node": "*" + } + }, "@webassemblyjs/ast": { "version": "1.8.5", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.8.5.tgz", @@ -4051,6 +4061,40 @@ "integrity": "sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw==", "dev": true }, + "bl": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/bl/-/bl-4.0.3.tgz", + "integrity": "sha512-fs4G6/Hu4/EE+F75J8DuN/0IpQqNjAdC7aEQv7Qt8MHGUH7Ckv2MwTEEeN9QehD0pfIDkMI1bkHYkKy7xHyKIg==", + "dev": true, + "requires": { + "buffer": "^5.5.0", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + }, + "dependencies": { + "buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "dev": true, + "requires": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "dev": true, + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + } + } + }, "blob": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/blob/-/blob-0.0.5.tgz", @@ -5756,6 +5800,12 @@ "integrity": "sha512-ZIzRpLJrOj7jjP2miAtgqIfmzbxa4ZOr5jJc601zklsfEx9oTzmmj2nVpIPRpNlRTIh8lc1kyViIY7BWSGNmKw==", "dev": true }, + "devtools-protocol": { + "version": "0.0.818844", + "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.818844.tgz", + "integrity": "sha512-AD1hi7iVJ8OD0aMLQU5VK0XH9LDlA1+BcPIgrAxPfaibx2DbWucuyOhc4oyQCbnvDDO68nN6/LcKfqTP343Jjg==", + "dev": true + }, "dezalgo": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/dezalgo/-/dezalgo-1.0.3.tgz", @@ -6873,6 +6923,12 @@ "readable-stream": "^2.0.0" } }, + "fs-constants": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==", + "dev": true + }, "fs-extra": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz", @@ -9197,6 +9253,15 @@ "integrity": "sha512-nCeAiw37MIMA9w9IXso7bRaLl+c/ef3wnxsoSAlYrzS+Ot0zTG6nU8G/cIfGkqpkjX2wNaIW9RFG0TwIFnG6bA==", "dev": true }, + "jasmine-marbles": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/jasmine-marbles/-/jasmine-marbles-0.6.0.tgz", + "integrity": "sha512-1uzgjEesEeCb+r+v46qn5x326TiGqk5SUZa+A3O+XnMCjG/pGcUOhL9Xsg5L7gLC6RFHyWGTkB5fei4rcvIOiQ==", + "dev": true, + "requires": { + "lodash": "^4.5.0" + } + }, "jasmine-spec-reporter": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/jasmine-spec-reporter/-/jasmine-spec-reporter-4.2.1.tgz", @@ -10414,6 +10479,12 @@ "minimist": "^1.2.5" } }, + "mkdirp-classic": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", + "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==", + "dev": true + }, "moment": { "version": "2.24.0", "resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz", @@ -10593,6 +10664,12 @@ "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", "dev": true }, + "node-fetch": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", + "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==", + "dev": true + }, "node-fetch-npm": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/node-fetch-npm/-/node-fetch-npm-2.0.4.tgz", @@ -12574,6 +12651,12 @@ "ipaddr.js": "1.9.0" } }, + "proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", + "dev": true + }, "prr": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", @@ -12645,6 +12728,144 @@ "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", "dev": true }, + "puppeteer": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-5.5.0.tgz", + "integrity": "sha512-OM8ZvTXAhfgFA7wBIIGlPQzvyEETzDjeRa4mZRCRHxYL+GNH5WAuYUQdja3rpWZvkX/JKqmuVgbsxDNsDFjMEg==", + "dev": true, + "requires": { + "debug": "^4.1.0", + "devtools-protocol": "0.0.818844", + "extract-zip": "^2.0.0", + "https-proxy-agent": "^4.0.0", + "node-fetch": "^2.6.1", + "pkg-dir": "^4.2.0", + "progress": "^2.0.1", + "proxy-from-env": "^1.0.0", + "rimraf": "^3.0.2", + "tar-fs": "^2.0.0", + "unbzip2-stream": "^1.3.3", + "ws": "^7.2.3" + }, + "dependencies": { + "agent-base": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-5.1.1.tgz", + "integrity": "sha512-TMeqbNl2fMW0nMjTEPOwe3J/PRFP4vqeoNuQMG0HlMrtm5QxKqdvAkZ1pRBQ/ulIyDD5Yq0nJ7YbdD8ey0TO3g==", + "dev": true + }, + "debug": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz", + "integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "extract-zip": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-2.0.1.tgz", + "integrity": "sha512-GDhU9ntwuKyGXdZBUgTIe+vXnWj0fppUEtMDL0+idd5Sta8TGpHssn/eusA9mrPr9qNDym6SxAYZjNvCn/9RBg==", + "dev": true, + "requires": { + "@types/yauzl": "^2.9.1", + "debug": "^4.1.1", + "get-stream": "^5.1.0", + "yauzl": "^2.10.0" + } + }, + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "get-stream": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz", + "integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==", + "dev": true, + "requires": { + "pump": "^3.0.0" + } + }, + "https-proxy-agent": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-4.0.0.tgz", + "integrity": "sha512-zoDhWrkR3of1l9QAL8/scJZyLu8j/gBkcwcaQOZh7Gyh/+uJQzGVETdgT30akuwkpL8HTRfssqI3BZuV18teDg==", + "dev": true, + "requires": { + "agent-base": "5", + "debug": "4" + } + }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "requires": { + "p-locate": "^4.1.0" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "requires": { + "p-limit": "^2.2.0" + } + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true + }, + "pkg-dir": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", + "dev": true, + "requires": { + "find-up": "^4.0.0" + } + }, + "progress": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", + "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", + "dev": true + }, + "rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + }, + "ws": { + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.0.tgz", + "integrity": "sha512-kyFwXuV/5ymf+IXhS6f0+eAFvydbaBW3zjpT6hUdAh/hbVjTIB5EHBGi0bPoCLSK2wcuz3BrEkB9LrYv1Nm4NQ==", + "dev": true + } + } + }, "q": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/q/-/q-1.4.1.tgz", @@ -14778,6 +14999,44 @@ } } }, + "tar-fs": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz", + "integrity": "sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==", + "dev": true, + "requires": { + "chownr": "^1.1.1", + "mkdirp-classic": "^0.5.2", + "pump": "^3.0.0", + "tar-stream": "^2.1.4" + } + }, + "tar-stream": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.1.4.tgz", + "integrity": "sha512-o3pS2zlG4gxr67GmFYBLlq+dM8gyRGUOvsrHclSkvtVtQbjV0s/+ZE8OpICbaj8clrX3tjeHngYGP7rweaBnuw==", + "dev": true, + "requires": { + "bl": "^4.0.3", + "end-of-stream": "^1.4.1", + "fs-constants": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1" + }, + "dependencies": { + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "dev": true, + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + } + } + }, "terser": { "version": "4.6.10", "resolved": "https://registry.npmjs.org/terser/-/terser-4.6.10.tgz", @@ -15193,6 +15452,28 @@ "integrity": "sha512-UIEXBNeYmKptWH6z8ZnqTeS8fV74zG0/eRU9VGkpzz+LIJNs8W/zM/L+7ctCkRrgbNnnR0xxw4bKOr0cW0N0Og==", "dev": true }, + "unbzip2-stream": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/unbzip2-stream/-/unbzip2-stream-1.4.3.tgz", + "integrity": "sha512-mlExGW4w71ebDJviH16lQLtZS32VKqsSfk80GCfUlwT/4/hNRFsoscrF/c++9xinkMzECL1uL9DDwXqFWkruPg==", + "dev": true, + "requires": { + "buffer": "^5.2.1", + "through": "^2.3.8" + }, + "dependencies": { + "buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "dev": true, + "requires": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + } + } + }, "unicode-canonical-property-names-ecmascript": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz", diff --git a/package.json b/package.json index ec694ba0..bea4454e 100644 --- a/package.json +++ b/package.json @@ -102,9 +102,10 @@ "codelyzer": "^5.1.2", "del": "^5.1.0", "jasmine-core": "~3.5.0", + "jasmine-marbles": "^0.6.0", "jasmine-spec-reporter": "~4.2.1", "karma": "~4.4.1", - "karma-chrome-launcher": "~3.1.0", + "karma-chrome-launcher": "^3.1.0", "karma-coverage-istanbul-reporter": "~2.0.5", "karma-jasmine": "~3.1.1", "karma-jasmine-html-reporter": "^1.4.2", @@ -113,6 +114,7 @@ "npm-run-all": "^4.1.5", "prettier": "^2.0.5", "protractor": "~5.4.2", + "puppeteer": "^5.5.0", "ts-node": "~8.8.1", "tslint": "~6.1.0", "tslint-config-prettier": "^1.18.0", diff --git a/src/app/api/analytics/analytics.service.ts b/src/app/api/analytics/analytics.service.ts index 0a3c566a..54c2b9b0 100644 --- a/src/app/api/analytics/analytics.service.ts +++ b/src/app/api/analytics/analytics.service.ts @@ -1,6 +1,7 @@ import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs'; -import { AnalyticsService as APIAnalyticsService, SplitUnit } from '../../api-codegen/anapi'; +import { AnalyticsService as APIAnalyticsService, InlineResponse200, SplitUnit } from '../../api-codegen/anapi'; import { PaymentInstitutionRealm } from '../model'; import { genXRequestID, toDateLike } from '../utils'; @@ -215,4 +216,13 @@ export class AnalyticsService { params.paymentInstitutionRealm ); } + + getGroupBalances(params: { shopIDs?: string[]; excludeShopIDs?: string[] }): Observable { + return this.analyticsService.getCurrentBalancesGroupByShop( + genXRequestID(), + undefined, + params.shopIDs, + params.excludeShopIDs + ); + } } diff --git a/src/app/api/shop/shop.service.ts b/src/app/api/shop/api-shops.service.ts similarity index 94% rename from src/app/api/shop/shop.service.ts rename to src/app/api/shop/api-shops.service.ts index da65777a..6620efd7 100644 --- a/src/app/api/shop/shop.service.ts +++ b/src/app/api/shop/api-shops.service.ts @@ -8,11 +8,11 @@ import { SHARE_REPLAY_CONF } from '../../custom-operators'; import { genXRequestID } from '../utils'; @Injectable() -export class ShopService { +export class ApiShopsService { private reloadShops$ = new Subject(); shops$: Observable = this.reloadShops$.pipe( - startWith(undefined as Shop[]), + startWith(null), switchMapTo(this.shopsService.getShops(genXRequestID())), shareReplay(SHARE_REPLAY_CONF) ); diff --git a/src/app/api/shop/index.ts b/src/app/api/shop/index.ts index c9475935..1d4c2723 100644 --- a/src/app/api/shop/index.ts +++ b/src/app/api/shop/index.ts @@ -1,3 +1,3 @@ -export * from './shop.service'; +export * from './api-shops.service'; export * from './shop.module'; export * from './operators'; diff --git a/src/app/api/shop/shop.module.ts b/src/app/api/shop/shop.module.ts index 5ee9bae9..831e4dca 100644 --- a/src/app/api/shop/shop.module.ts +++ b/src/app/api/shop/shop.module.ts @@ -1,10 +1,10 @@ import { NgModule } from '@angular/core'; import { CAPIModule } from '../capi'; -import { ShopService } from './shop.service'; +import { ApiShopsService } from './api-shops.service'; @NgModule({ imports: [CAPIModule], - providers: [ShopService], + providers: [ApiShopsService], }) export class ShopModule {} diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 3948c6a2..5132d99c 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -5,7 +5,7 @@ import { TestShopService } from './test-shop.service'; @Component({ selector: 'dsh-root', - templateUrl: './app.component.html', + templateUrl: 'app.component.html', providers: [TestShopService], }) export class AppComponent implements OnInit { diff --git a/src/app/container/actionbar/actionbar.component.ts b/src/app/container/actionbar/actionbar.component.ts index 21656702..b22c4555 100644 --- a/src/app/container/actionbar/actionbar.component.ts +++ b/src/app/container/actionbar/actionbar.component.ts @@ -6,7 +6,7 @@ import { ThemeManager, ThemeName } from '../../theme-manager'; @Component({ selector: 'dsh-actionbar', - templateUrl: './actionbar.component.html', + templateUrl: 'actionbar.component.html', changeDetection: ChangeDetectionStrategy.OnPush, }) export class ActionbarComponent { diff --git a/src/app/container/brand/brand.component.ts b/src/app/container/brand/brand.component.ts index 89100563..cbe8f2cb 100644 --- a/src/app/container/brand/brand.component.ts +++ b/src/app/container/brand/brand.component.ts @@ -4,7 +4,7 @@ import { BrandType } from './brand-type'; @Component({ selector: 'dsh-brand', - templateUrl: './brand.component.html', + templateUrl: 'brand.component.html', styleUrls: ['./brand.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush, }) diff --git a/src/app/container/toolbar/toolbar-links.service.ts b/src/app/container/toolbar/toolbar-links.service.ts index cdd384ad..4f01d75f 100644 --- a/src/app/container/toolbar/toolbar-links.service.ts +++ b/src/app/container/toolbar/toolbar-links.service.ts @@ -1,5 +1,5 @@ import { Injectable } from '@angular/core'; -import { Router } from '@angular/router'; +import { Event, Router } from '@angular/router'; import { combineLatest } from 'rxjs'; import { distinctUntilChanged, map, shareReplay, startWith } from 'rxjs/operators'; @@ -22,7 +22,7 @@ export enum LinkId { @Injectable() export class ToolbarLinksService { private url$ = this.router.events.pipe( - startWith(null), + startWith(null), map(() => this.router.url), distinctUntilChanged(), shareReplay(1) diff --git a/src/app/container/toolbar/toolbar.component.ts b/src/app/container/toolbar/toolbar.component.ts index 437f34f8..a0bad6e7 100644 --- a/src/app/container/toolbar/toolbar.component.ts +++ b/src/app/container/toolbar/toolbar.component.ts @@ -6,7 +6,7 @@ import { LinkId, ToolbarLinksService } from './toolbar-links.service'; @Component({ selector: 'dsh-toolbar', - templateUrl: './toolbar.component.html', + templateUrl: 'toolbar.component.html', styleUrls: ['./toolbar.component.scss'], providers: [ToolbarLinksService], changeDetection: ChangeDetectionStrategy.OnPush, diff --git a/src/app/sections/create-invoice-template/create-invoice-template.service.ts b/src/app/sections/create-invoice-template/create-invoice-template.service.ts index c88022e3..28b72e98 100644 --- a/src/app/sections/create-invoice-template/create-invoice-template.service.ts +++ b/src/app/sections/create-invoice-template/create-invoice-template.service.ts @@ -47,7 +47,8 @@ export class CreateInvoiceTemplateService { form = this.createForm(); summary$ = this.cartForm.valueChanges.pipe( - startWith(this.cartForm.value), + // TODO: add form types + startWith(this.cartForm.value), map((v) => v.reduce((sum, c) => sum + c.price * c.quantity, 0)), shareReplay(1) ); @@ -123,7 +124,7 @@ export class CreateInvoiceTemplateService { private subscribeFormChanges() { const templateType$ = this.form.controls.templateType.valueChanges.pipe( - startWith(this.form.value.templateType), + startWith(this.form.value.templateType), shareReplay(SHARE_REPLAY_CONF) ); const costType$ = this.form.controls.costType.valueChanges.pipe(startWith(this.form.value.costType)); diff --git a/src/app/sections/create-invoice/create-invoice.service.ts b/src/app/sections/create-invoice/create-invoice.service.ts index 40ddb6b1..563d821f 100644 --- a/src/app/sections/create-invoice/create-invoice.service.ts +++ b/src/app/sections/create-invoice/create-invoice.service.ts @@ -19,7 +19,8 @@ export class CreateInvoiceService { form = this.createForm(); totalAmount$ = this.form.controls.cart.valueChanges.pipe( - startWith(this.form.controls.cart.value), + // TODO: add form types + startWith(this.form.controls.cart.value), map((v) => v.map(({ price, quantity }) => price * quantity).reduce((sum, s) => (sum += s), 0)), shareReplay(SHARE_REPLAY_CONF) ); diff --git a/src/app/sections/create-shop/create-shop-russian-legal-entity/create-shop-russian-legal-entity.component.ts b/src/app/sections/create-shop/create-shop-russian-legal-entity/create-shop-russian-legal-entity.component.ts index b1bd430c..99cf3373 100644 --- a/src/app/sections/create-shop/create-shop-russian-legal-entity/create-shop-russian-legal-entity.component.ts +++ b/src/app/sections/create-shop/create-shop-russian-legal-entity/create-shop-russian-legal-entity.component.ts @@ -6,7 +6,7 @@ import { TranslocoService } from '@ngneat/transloco'; import { of, ReplaySubject } from 'rxjs'; import { map, shareReplay, startWith, switchMap } from 'rxjs/operators'; -import { ShopService } from '../../../api'; +import { ApiShopsService } from '../../../api'; import { BankContent } from '../../../api-codegen/aggr-proxy'; import { BankAccount } from '../../../api-codegen/capi'; import { filterShopsByRealm } from '../../payment-section/operations/operators'; @@ -58,7 +58,7 @@ export class CreateShopRussianLegalEntityComponent { constructor( private fb: FormBuilder, private createShopRussianLegalEntityService: CreateShopRussianLegalEntityService, - private shopService: ShopService, + private shopService: ApiShopsService, private transloco: TranslocoService, private snackBar: MatSnackBar, private router: Router diff --git a/src/app/sections/create-shop/create-shop-russian-legal-entity/create-shop-russian-legal-entity.service.ts b/src/app/sections/create-shop/create-shop-russian-legal-entity/create-shop-russian-legal-entity.service.ts index 7ec733ff..01e215fe 100644 --- a/src/app/sections/create-shop/create-shop-russian-legal-entity/create-shop-russian-legal-entity.service.ts +++ b/src/app/sections/create-shop/create-shop-russian-legal-entity/create-shop-russian-legal-entity.service.ts @@ -4,11 +4,11 @@ import { map, pluck, switchMap, switchMapTo } from 'rxjs/operators'; import uuid from 'uuid'; import { + ApiShopsService, ClaimsService, createDocumentModificationUnit, PayoutsService, QuestionaryService, - ShopService, } from '../../../api'; import { BankAccount, @@ -22,7 +22,7 @@ import { export class CreateShopRussianLegalEntityService { constructor( private claimsService: ClaimsService, - private shopService: ShopService, + private shopService: ApiShopsService, private payoutsService: PayoutsService, private questionaryService: QuestionaryService ) {} diff --git a/src/app/sections/invoice-details/details/status-details-item/status-details-item.component.ts b/src/app/sections/invoice-details/details/status-details-item/status-details-item.component.ts index d2c079fd..f18566d2 100644 --- a/src/app/sections/invoice-details/details/status-details-item/status-details-item.component.ts +++ b/src/app/sections/invoice-details/details/status-details-item/status-details-item.component.ts @@ -9,7 +9,7 @@ export interface StatusViewInfo { @Component({ selector: 'dsh-details-status-item', - templateUrl: './status-details-item.component.html', + templateUrl: 'status-details-item.component.html', }) export class StatusDetailsItemComponent { @Input() color: Color; diff --git a/src/app/sections/main/parts/payments/payments.service.ts b/src/app/sections/main/parts/payments/payments.service.ts index 90b119f3..2f579ac6 100644 --- a/src/app/sections/main/parts/payments/payments.service.ts +++ b/src/app/sections/main/parts/payments/payments.service.ts @@ -4,7 +4,7 @@ import { TranslocoService } from '@ngneat/transloco'; import { combineLatest, Observable } from 'rxjs'; import { pluck } from 'rxjs/operators'; -import { ClaimsService, ShopService } from '../../../../api'; +import { ApiShopsService, ClaimsService } from '../../../../api'; import { ClaimStatus } from '../../../../api/claims'; import { booleanDelay, takeError } from '../../../../custom-operators'; import { ActionBtnContent, TestEnvBtnContent } from './content-config'; @@ -18,7 +18,7 @@ export class PaymentsService { isLoading$: Observable; constructor( - private shopService: ShopService, + private shopService: ApiShopsService, private claimService: ClaimsService, private snackBar: MatSnackBar, private transloco: TranslocoService diff --git a/src/app/sections/onboarding/data-flow/forms/subforms/authority-confirming-document/authority-confirming-document.component.ts b/src/app/sections/onboarding/data-flow/forms/subforms/authority-confirming-document/authority-confirming-document.component.ts index 448ab309..241bd88d 100644 --- a/src/app/sections/onboarding/data-flow/forms/subforms/authority-confirming-document/authority-confirming-document.component.ts +++ b/src/app/sections/onboarding/data-flow/forms/subforms/authority-confirming-document/authority-confirming-document.component.ts @@ -26,7 +26,8 @@ export class AuthorityConfirmingDocumentComponent { switchMap((form) => form ? form.valueChanges.pipe( - startWith(form.value), + // TODO: add form types + startWith(form.value), map((v) => v.type === this.customType) ) : of(false) diff --git a/src/app/sections/page-not-found/page-not-found.component.ts b/src/app/sections/page-not-found/page-not-found.component.ts index 2cdef50f..b31bf4fc 100644 --- a/src/app/sections/page-not-found/page-not-found.component.ts +++ b/src/app/sections/page-not-found/page-not-found.component.ts @@ -3,7 +3,7 @@ import { Router } from '@angular/router'; @Component({ selector: 'dsh-page-not-found', - templateUrl: './page-not-found.component.html', + templateUrl: 'page-not-found.component.html', }) export class PageNotFoundComponent { constructor(private router: Router) {} diff --git a/src/app/sections/payment-details/details/details.component.ts b/src/app/sections/payment-details/details/details.component.ts index 956ba478..1731d4be 100644 --- a/src/app/sections/payment-details/details/details.component.ts +++ b/src/app/sections/payment-details/details/details.component.ts @@ -7,7 +7,7 @@ import { getPaymentStatusInfo } from '../../get-payment-status-info'; @Component({ selector: 'dsh-details', - templateUrl: './details.component.html', + templateUrl: 'details.component.html', }) export class DetailsComponent implements OnChanges { @Input() payment: PaymentSearchResult; diff --git a/src/app/sections/payment-details/hold-details/cancel-hold/cancel-hold.component.ts b/src/app/sections/payment-details/hold-details/cancel-hold/cancel-hold.component.ts index d0785680..b693d46f 100644 --- a/src/app/sections/payment-details/hold-details/cancel-hold/cancel-hold.component.ts +++ b/src/app/sections/payment-details/hold-details/cancel-hold/cancel-hold.component.ts @@ -15,7 +15,7 @@ export interface CancelHoldData { @Component({ selector: 'dsh-cancel-hold', - templateUrl: './cancel-hold.component.html', + templateUrl: 'cancel-hold.component.html', providers: [PaymentService], }) export class CancelHoldComponent { diff --git a/src/app/sections/payment-details/hold-details/confirm-hold/confirm-hold.component.ts b/src/app/sections/payment-details/hold-details/confirm-hold/confirm-hold.component.ts index e5d153e5..3391ff1d 100644 --- a/src/app/sections/payment-details/hold-details/confirm-hold/confirm-hold.component.ts +++ b/src/app/sections/payment-details/hold-details/confirm-hold/confirm-hold.component.ts @@ -21,7 +21,7 @@ export interface ConfirmHoldData { @Component({ selector: 'dsh-confirm-hold', - templateUrl: './confirm-hold.component.html', + templateUrl: 'confirm-hold.component.html', providers: [PaymentService], }) export class ConfirmHoldComponent { diff --git a/src/app/sections/payment-details/hold-details/hold-details.component.ts b/src/app/sections/payment-details/hold-details/hold-details.component.ts index 6d5123b2..43b6b40c 100644 --- a/src/app/sections/payment-details/hold-details/hold-details.component.ts +++ b/src/app/sections/payment-details/hold-details/hold-details.component.ts @@ -11,7 +11,7 @@ const onHoldExpirationEnum = PaymentFlowHold.OnHoldExpirationEnum; @Component({ selector: 'dsh-hold-details', - templateUrl: './hold-details.component.html', + templateUrl: 'hold-details.component.html', }) export class HoldDetailsComponent { @Input() payment: PaymentSearchResult; diff --git a/src/app/sections/payment-details/invoice-details/invoice-details.component.ts b/src/app/sections/payment-details/invoice-details/invoice-details.component.ts index 9ccc0fcc..bab43e96 100644 --- a/src/app/sections/payment-details/invoice-details/invoice-details.component.ts +++ b/src/app/sections/payment-details/invoice-details/invoice-details.component.ts @@ -9,7 +9,7 @@ import { InvoiceDetailsService } from './invoice-details.service'; @Component({ selector: 'dsh-invoice-details', - templateUrl: './invoice-details.component.html', + templateUrl: 'invoice-details.component.html', styleUrls: ['./invoice-details.component.scss'], providers: [InvoiceDetailsService], }) diff --git a/src/app/sections/payment-details/make-recurrent/make-recurrent.component.ts b/src/app/sections/payment-details/make-recurrent/make-recurrent.component.ts index d62c54f8..e18601f2 100644 --- a/src/app/sections/payment-details/make-recurrent/make-recurrent.component.ts +++ b/src/app/sections/payment-details/make-recurrent/make-recurrent.component.ts @@ -2,6 +2,6 @@ import { Component } from '@angular/core'; @Component({ selector: 'dsh-make-recurrent', - templateUrl: './make-recurrent.component.html', + templateUrl: 'make-recurrent.component.html', }) export class MakeRecurrentComponent {} diff --git a/src/app/sections/payment-details/payer-details/customer-payer/customer-payer.component.ts b/src/app/sections/payment-details/payer-details/customer-payer/customer-payer.component.ts index 35b9a8e3..40cc30b6 100644 --- a/src/app/sections/payment-details/payer-details/customer-payer/customer-payer.component.ts +++ b/src/app/sections/payment-details/payer-details/customer-payer/customer-payer.component.ts @@ -4,7 +4,7 @@ import { CustomerPayer } from '../../../../api-codegen/capi/swagger-codegen'; @Component({ selector: 'dsh-customer-payer', - templateUrl: './customer-payer.component.html', + templateUrl: 'customer-payer.component.html', }) export class CustomerPayerComponent { @Input() customerPayer: CustomerPayer; diff --git a/src/app/sections/payment-details/payer-details/payer-details.component.ts b/src/app/sections/payment-details/payer-details/payer-details.component.ts index 30b99760..639b6afc 100644 --- a/src/app/sections/payment-details/payer-details/payer-details.component.ts +++ b/src/app/sections/payment-details/payer-details/payer-details.component.ts @@ -11,7 +11,7 @@ export enum PayerType { @Component({ selector: 'dsh-payer-details', - templateUrl: './payer-details.component.html', + templateUrl: 'payer-details.component.html', }) export class PayerDetailsComponent { @Input() payer: Payer; diff --git a/src/app/sections/payment-details/payer-details/payment-resource-payer/payment-resource-payer.component.ts b/src/app/sections/payment-details/payer-details/payment-resource-payer/payment-resource-payer.component.ts index 68c86b3b..eecbc2b1 100644 --- a/src/app/sections/payment-details/payer-details/payment-resource-payer/payment-resource-payer.component.ts +++ b/src/app/sections/payment-details/payer-details/payment-resource-payer/payment-resource-payer.component.ts @@ -5,7 +5,7 @@ import { LAYOUT_GAP } from '../../../constants'; @Component({ selector: 'dsh-payment-resource-payer', - templateUrl: './payment-resource-payer.component.html', + templateUrl: 'payment-resource-payer.component.html', }) export class PaymentResourcePayerComponent { @Input() paymentResourcePayer: PaymentResourcePayer; diff --git a/src/app/sections/payment-details/payment-details.component.ts b/src/app/sections/payment-details/payment-details.component.ts index 2fcfca89..56bcb981 100644 --- a/src/app/sections/payment-details/payment-details.component.ts +++ b/src/app/sections/payment-details/payment-details.component.ts @@ -7,7 +7,7 @@ import { PayerType } from './payer-details'; import { ReceivePaymentService } from './receive-payment.service'; @Component({ - templateUrl: './payment-details.component.html', + templateUrl: 'payment-details.component.html', styleUrls: ['./payment-details.component.scss'], providers: [ReceivePaymentService], }) diff --git a/src/app/sections/payment-details/payment-tool/bank-card/bank-card.component.ts b/src/app/sections/payment-details/payment-tool/bank-card/bank-card.component.ts index f95c5453..4bdb752c 100644 --- a/src/app/sections/payment-details/payment-tool/bank-card/bank-card.component.ts +++ b/src/app/sections/payment-details/payment-tool/bank-card/bank-card.component.ts @@ -4,7 +4,7 @@ import { BankCardDetails, PaymentToolDetailsBankCard } from '../../../../api-cod @Component({ selector: 'dsh-bank-card', - templateUrl: './bank-card.component.html', + templateUrl: 'bank-card.component.html', }) export class BankCardComponent { @Input() bankCard: BankCardDetails; diff --git a/src/app/sections/payment-details/payment-tool/digital-wallet/digital-wallet.component.ts b/src/app/sections/payment-details/payment-tool/digital-wallet/digital-wallet.component.ts index 258ac5f4..620189c0 100644 --- a/src/app/sections/payment-details/payment-tool/digital-wallet/digital-wallet.component.ts +++ b/src/app/sections/payment-details/payment-tool/digital-wallet/digital-wallet.component.ts @@ -9,7 +9,7 @@ import DigitalWalletDetailsTypeEnum = PaymentToolDetailsDigitalWallet.DigitalWal @Component({ selector: 'dsh-digital-wallet', - templateUrl: './digital-wallet.component.html', + templateUrl: 'digital-wallet.component.html', }) export class DigitalWalletComponent implements OnChanges { @Input() digitalWallet: DigitalWalletDetails; diff --git a/src/app/sections/payment-details/payment-tool/payment-terminal/payment-terminal.component.ts b/src/app/sections/payment-details/payment-tool/payment-terminal/payment-terminal.component.ts index 3e784582..9e554f4f 100644 --- a/src/app/sections/payment-details/payment-tool/payment-terminal/payment-terminal.component.ts +++ b/src/app/sections/payment-details/payment-tool/payment-terminal/payment-terminal.component.ts @@ -4,7 +4,7 @@ import { PaymentTerminalDetails } from '../../../../api-codegen/capi/swagger-cod @Component({ selector: 'dsh-payment-terminal', - templateUrl: './payment-terminal.component.html', + templateUrl: 'payment-terminal.component.html', }) export class PaymentTerminalComponent { @Input() paymentTerminal: PaymentTerminalDetails; diff --git a/src/app/sections/payment-details/payment-tool/payment-tool.component.ts b/src/app/sections/payment-details/payment-tool/payment-tool.component.ts index 2bdf5f24..030e3dd0 100644 --- a/src/app/sections/payment-details/payment-tool/payment-tool.component.ts +++ b/src/app/sections/payment-details/payment-tool/payment-tool.component.ts @@ -5,7 +5,7 @@ import { PaymentToolDetails } from '../../../api-codegen/capi'; @Component({ selector: 'dsh-payment-tool', - templateUrl: './payment-tool.component.html', + templateUrl: 'payment-tool.component.html', }) export class PaymentToolComponent { @Input() paymentToolDetails: PaymentToolDetails; diff --git a/src/app/sections/payment-details/recurrent-details/recurrent-details.component.ts b/src/app/sections/payment-details/recurrent-details/recurrent-details.component.ts index 9cf9191c..deb03fe1 100644 --- a/src/app/sections/payment-details/recurrent-details/recurrent-details.component.ts +++ b/src/app/sections/payment-details/recurrent-details/recurrent-details.component.ts @@ -5,7 +5,7 @@ import { LAYOUT_GAP } from '../../constants'; @Component({ selector: 'dsh-recurrent-details', - templateUrl: './recurrent-details.component.html', + templateUrl: 'recurrent-details.component.html', }) export class RecurrentDetailsComponent { @Input() recurrentPayer: RecurrentPayer; diff --git a/src/app/sections/payment-details/refunds/create-refund/create-refund.component.ts b/src/app/sections/payment-details/refunds/create-refund/create-refund.component.ts index c45dce49..d79bea0b 100644 --- a/src/app/sections/payment-details/refunds/create-refund/create-refund.component.ts +++ b/src/app/sections/payment-details/refunds/create-refund/create-refund.component.ts @@ -23,7 +23,7 @@ export interface CreateRefundData { @Component({ selector: 'dsh-create-refund', - templateUrl: './create-refund.component.html', + templateUrl: 'create-refund.component.html', providers: [CreateRefundService], }) export class CreateRefundComponent implements OnInit { diff --git a/src/app/sections/payment-details/refunds/create-refund/create-refund.service.ts b/src/app/sections/payment-details/refunds/create-refund/create-refund.service.ts index f8e18457..ecbc2632 100644 --- a/src/app/sections/payment-details/refunds/create-refund/create-refund.service.ts +++ b/src/app/sections/payment-details/refunds/create-refund/create-refund.service.ts @@ -5,13 +5,13 @@ import { switchMap } from 'rxjs/operators'; import { Account, Refund, RefundParams, Shop } from '../../../../api-codegen/capi/swagger-codegen'; import { AccountService } from '../../../../api/account'; import { RefundService } from '../../../../api/refund'; -import { ShopService } from '../../../../api/shop'; +import { ApiShopsService } from '../../../../api/shop'; @Injectable() export class CreateRefundService { constructor( private refundService: RefundService, - private shopService: ShopService, + private shopService: ApiShopsService, private accountService: AccountService ) {} diff --git a/src/app/sections/payment-details/refunds/refund-item/refund-item.component.ts b/src/app/sections/payment-details/refunds/refund-item/refund-item.component.ts index 3ddf6f59..7d6a8282 100644 --- a/src/app/sections/payment-details/refunds/refund-item/refund-item.component.ts +++ b/src/app/sections/payment-details/refunds/refund-item/refund-item.component.ts @@ -6,7 +6,7 @@ import { LAYOUT_GAP } from '../../../constants'; @Component({ selector: 'dsh-refund-item', - templateUrl: './refund-item.component.html', + templateUrl: 'refund-item.component.html', }) export class RefundItemComponent implements OnChanges { @Input() refund: RefundSearchResult; diff --git a/src/app/sections/payment-details/refunds/refunds.component.ts b/src/app/sections/payment-details/refunds/refunds.component.ts index b43d5ea6..ba895594 100644 --- a/src/app/sections/payment-details/refunds/refunds.component.ts +++ b/src/app/sections/payment-details/refunds/refunds.component.ts @@ -11,7 +11,7 @@ const PaymentStatuses = PaymentSearchResult.StatusEnum; @Component({ selector: 'dsh-refunds', - templateUrl: './refunds.component.html', + templateUrl: 'refunds.component.html', styleUrls: ['./refunds.component.scss'], providers: [RefundsService], }) diff --git a/src/app/sections/payment-details/refunds/refunds.module.ts b/src/app/sections/payment-details/refunds/refunds.module.ts index ca787c95..3d728bf7 100644 --- a/src/app/sections/payment-details/refunds/refunds.module.ts +++ b/src/app/sections/payment-details/refunds/refunds.module.ts @@ -15,7 +15,7 @@ import { DetailsItemModule, LayoutModule } from '@dsh/components/layout'; import { AccountService } from '../../../api/account'; import { RefundService } from '../../../api/refund'; import { RefundSearchService } from '../../../api/search'; -import { ShopService } from '../../../api/shop'; +import { ApiShopsService } from '../../../api/shop'; import { ToMajorModule } from '../../../to-major'; import { StatusDetailsItemModule } from '../status-details-item'; import { CreateRefundComponent } from './create-refund'; @@ -41,7 +41,7 @@ import { RefundsComponent } from './refunds.component'; ], declarations: [CreateRefundComponent, RefundsComponent, RefundItemComponent], exports: [RefundsComponent], - providers: [RefundSearchService, RefundService, ShopService, AccountService], + providers: [RefundSearchService, RefundService, ApiShopsService, AccountService], entryComponents: [CreateRefundComponent], }) export class RefundsModule {} diff --git a/src/app/sections/payment-details/status-details-item/status-details-item.component.ts b/src/app/sections/payment-details/status-details-item/status-details-item.component.ts index 743f9459..d0e9ee16 100644 --- a/src/app/sections/payment-details/status-details-item/status-details-item.component.ts +++ b/src/app/sections/payment-details/status-details-item/status-details-item.component.ts @@ -9,7 +9,7 @@ export interface StatusViewInfo { @Component({ selector: 'dsh-details-status-item', - templateUrl: './status-details-item.component.html', + templateUrl: 'status-details-item.component.html', }) export class StatusDetailsItemComponent { @Input() color: Color; diff --git a/src/app/sections/payment-section/analytics/analytics-search-filters/analytics-search-filters.component.ts b/src/app/sections/payment-section/analytics/analytics-search-filters/analytics-search-filters.component.ts index c707c539..5760a456 100644 --- a/src/app/sections/payment-section/analytics/analytics-search-filters/analytics-search-filters.component.ts +++ b/src/app/sections/payment-section/analytics/analytics-search-filters/analytics-search-filters.component.ts @@ -14,7 +14,7 @@ import { distinctUntilChanged, map, scan, shareReplay, switchMap, take } from 'r import { Daterange } from '@dsh/pipes/daterange'; import { Shop } from '../../../../api-codegen/capi'; -import { ShopService } from '../../../../api/shop'; +import { ApiShopsService } from '../../../../api/shop'; import { filterShopsByRealm, removeEmptyProperties } from '../../operations/operators'; import { searchFilterParamsToDaterange } from '../../reports/reports-search-filters/search-filter-params-to-daterange'; import { SearchParams } from '../search-params'; @@ -66,7 +66,7 @@ export class AnalyticsSearchFiltersComponent implements OnChanges { shareReplay(1) ); - constructor(private shopService: ShopService) { + constructor(private shopService: ApiShopsService) { this.selectedCurrency$.subscribe((currency) => { this.searchParams$.next({ currency }); this.selectedShopIDs$.next([]); diff --git a/src/app/sections/payment-section/analytics/analytics-search-filters/analytics-search-filters.module.ts b/src/app/sections/payment-section/analytics/analytics-search-filters/analytics-search-filters.module.ts index 8fb630c2..3d01786a 100644 --- a/src/app/sections/payment-section/analytics/analytics-search-filters/analytics-search-filters.module.ts +++ b/src/app/sections/payment-section/analytics/analytics-search-filters/analytics-search-filters.module.ts @@ -2,10 +2,10 @@ import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; import { FlexModule } from '@angular/flex-layout'; -import { FilterShopsModule } from '@dsh/app/shared/*'; +import { FilterShopsModule } from '@dsh/app/shared/components'; +import { CurrencyFilterModule } from '@dsh/app/shared/components/filters/currency-filter'; import { DaterangeFilterModule } from '@dsh/components/filters/daterange-filter'; -import { CurrencyFilterModule } from '../../../../shared/components/filters/currency-filter'; import { AnalyticsSearchFiltersComponent } from './analytics-search-filters.component'; @NgModule({ diff --git a/src/app/sections/payment-section/analytics/average-payment/average-payment.component.ts b/src/app/sections/payment-section/analytics/average-payment/average-payment.component.ts index 659c8d20..9efe2b16 100644 --- a/src/app/sections/payment-section/analytics/average-payment/average-payment.component.ts +++ b/src/app/sections/payment-section/analytics/average-payment/average-payment.component.ts @@ -7,7 +7,7 @@ import { AveragePaymentService } from './average-payment.service'; @Component({ selector: 'dsh-average-payment', - templateUrl: './average-payment.component.html', + templateUrl: 'average-payment.component.html', providers: [AveragePaymentService], }) export class AveragePaymentComponent implements OnChanges { diff --git a/src/app/sections/payment-section/analytics/bar-chart-item/bar-chart-item.component.ts b/src/app/sections/payment-section/analytics/bar-chart-item/bar-chart-item.component.ts index 05ff4590..cf7aed77 100644 --- a/src/app/sections/payment-section/analytics/bar-chart-item/bar-chart-item.component.ts +++ b/src/app/sections/payment-section/analytics/bar-chart-item/bar-chart-item.component.ts @@ -6,7 +6,7 @@ import { ChartData } from '../utils'; @Component({ selector: 'dsh-bar-chart-item', - templateUrl: './bar-chart-item.component.html', + templateUrl: 'bar-chart-item.component.html', }) export class BarChartItemComponent implements OnChanges { @Input() spinnerType: SpinnerType; diff --git a/src/app/sections/payment-section/analytics/donut-chart-item/donut-chart-item.component.ts b/src/app/sections/payment-section/analytics/donut-chart-item/donut-chart-item.component.ts index 96c0da2f..65e2fe3d 100644 --- a/src/app/sections/payment-section/analytics/donut-chart-item/donut-chart-item.component.ts +++ b/src/app/sections/payment-section/analytics/donut-chart-item/donut-chart-item.component.ts @@ -6,7 +6,7 @@ import { DistributionChartData } from '../utils'; @Component({ selector: 'dsh-donut-chart-item', - templateUrl: './donut-chart-item.component.html', + templateUrl: 'donut-chart-item.component.html', styleUrls: ['donut-chart-item.component.scss'], }) export class DonutChartItemComponent implements OnChanges { diff --git a/src/app/sections/payment-section/analytics/payment-split-amount/payment-split-amount.component.ts b/src/app/sections/payment-section/analytics/payment-split-amount/payment-split-amount.component.ts index 4c2befd7..2533da43 100644 --- a/src/app/sections/payment-section/analytics/payment-split-amount/payment-split-amount.component.ts +++ b/src/app/sections/payment-section/analytics/payment-split-amount/payment-split-amount.component.ts @@ -8,7 +8,7 @@ import { PaymentSplitAmountService } from './payment-split-amount.service'; @Component({ selector: 'dsh-payment-split-amount', - templateUrl: './payment-split-amount.component.html', + templateUrl: 'payment-split-amount.component.html', providers: [PaymentSplitAmountService], }) export class PaymentSplitAmountComponent implements OnChanges { diff --git a/src/app/sections/payment-section/analytics/payment-split-count/payment-split-count.component.ts b/src/app/sections/payment-section/analytics/payment-split-count/payment-split-count.component.ts index 9a5a2aa7..e92feeed 100644 --- a/src/app/sections/payment-section/analytics/payment-split-count/payment-split-count.component.ts +++ b/src/app/sections/payment-section/analytics/payment-split-count/payment-split-count.component.ts @@ -8,7 +8,7 @@ import { PaymentSplitCountService } from './payment-split-count.service'; @Component({ selector: 'dsh-payment-split-count', - templateUrl: './payment-split-count.component.html', + templateUrl: 'payment-split-count.component.html', providers: [PaymentSplitCountService], }) export class PaymentSplitCountComponent implements OnChanges { diff --git a/src/app/sections/payment-section/analytics/payments-amount/payments-amount.component.ts b/src/app/sections/payment-section/analytics/payments-amount/payments-amount.component.ts index 20354b8d..23f9f3d3 100644 --- a/src/app/sections/payment-section/analytics/payments-amount/payments-amount.component.ts +++ b/src/app/sections/payment-section/analytics/payments-amount/payments-amount.component.ts @@ -7,7 +7,7 @@ import { PaymentsAmountService } from './payments-amount.service'; @Component({ selector: 'dsh-payments-amount', - templateUrl: './payments-amount.component.html', + templateUrl: 'payments-amount.component.html', providers: [PaymentsAmountService], }) export class PaymentsAmountComponent implements OnChanges { diff --git a/src/app/sections/payment-section/analytics/payments-count/payments-count.component.ts b/src/app/sections/payment-section/analytics/payments-count/payments-count.component.ts index c4d72d8e..eed7f172 100644 --- a/src/app/sections/payment-section/analytics/payments-count/payments-count.component.ts +++ b/src/app/sections/payment-section/analytics/payments-count/payments-count.component.ts @@ -7,7 +7,7 @@ import { PaymentsCountService } from './payments-count.service'; @Component({ selector: 'dsh-payments-count', - templateUrl: './payments-count.component.html', + templateUrl: 'payments-count.component.html', providers: [PaymentsCountService], }) export class PaymentsCountComponent implements OnChanges { diff --git a/src/app/sections/payment-section/analytics/payments-error-distribution/payments-error-distribution.component.ts b/src/app/sections/payment-section/analytics/payments-error-distribution/payments-error-distribution.component.ts index 37fe3f21..046e913f 100644 --- a/src/app/sections/payment-section/analytics/payments-error-distribution/payments-error-distribution.component.ts +++ b/src/app/sections/payment-section/analytics/payments-error-distribution/payments-error-distribution.component.ts @@ -8,7 +8,7 @@ import { PaymentsErrorDistributionService } from './payments-error-distribution. @Component({ selector: 'dsh-payments-error-distribution', - templateUrl: './payments-error-distribution.component.html', + templateUrl: 'payments-error-distribution.component.html', providers: [PaymentsErrorDistributionService], encapsulation: ViewEncapsulation.Emulated, }) diff --git a/src/app/sections/payment-section/analytics/payments-tool-distribution/payments-tool-distribution.component.ts b/src/app/sections/payment-section/analytics/payments-tool-distribution/payments-tool-distribution.component.ts index 8791bcf7..951c392c 100644 --- a/src/app/sections/payment-section/analytics/payments-tool-distribution/payments-tool-distribution.component.ts +++ b/src/app/sections/payment-section/analytics/payments-tool-distribution/payments-tool-distribution.component.ts @@ -8,7 +8,7 @@ import { PaymentsToolDistributionService } from './payments-tool-distribution.se @Component({ selector: 'dsh-payments-tool-distribution', - templateUrl: './payments-tool-distribution.component.html', + templateUrl: 'payments-tool-distribution.component.html', providers: [PaymentsToolDistributionService], }) export class PaymentsToolDistributionComponent implements OnChanges { diff --git a/src/app/sections/payment-section/analytics/percent-difference/percent-difference.component.ts b/src/app/sections/payment-section/analytics/percent-difference/percent-difference.component.ts index e42846a2..5e5a34ed 100644 --- a/src/app/sections/payment-section/analytics/percent-difference/percent-difference.component.ts +++ b/src/app/sections/payment-section/analytics/percent-difference/percent-difference.component.ts @@ -2,7 +2,7 @@ import { Component, Input, OnChanges, SimpleChanges } from '@angular/core'; @Component({ selector: 'dsh-percent-difference', - templateUrl: './percent-difference.component.html', + templateUrl: 'percent-difference.component.html', }) export class PercentDifferenceComponent implements OnChanges { @Input() current: number; diff --git a/src/app/sections/payment-section/analytics/refunds-amount/refunds-amount.component.ts b/src/app/sections/payment-section/analytics/refunds-amount/refunds-amount.component.ts index f494f0a0..98526ef0 100644 --- a/src/app/sections/payment-section/analytics/refunds-amount/refunds-amount.component.ts +++ b/src/app/sections/payment-section/analytics/refunds-amount/refunds-amount.component.ts @@ -7,7 +7,7 @@ import { RefundsAmountService } from './refunds-amount.service'; @Component({ selector: 'dsh-refunds-amount', - templateUrl: './refunds-amount.component.html', + templateUrl: 'refunds-amount.component.html', providers: [RefundsAmountService], }) export class RefundsAmountComponent implements OnChanges { diff --git a/src/app/sections/payment-section/analytics/stat-item/stat-item.component.ts b/src/app/sections/payment-section/analytics/stat-item/stat-item.component.ts index dae219b2..2f79aac8 100644 --- a/src/app/sections/payment-section/analytics/stat-item/stat-item.component.ts +++ b/src/app/sections/payment-section/analytics/stat-item/stat-item.component.ts @@ -7,7 +7,7 @@ import { StatData } from '../utils'; @Component({ selector: 'dsh-stat-item', - templateUrl: './stat-item.component.html', + templateUrl: 'stat-item.component.html', styleUrls: ['./stat-item.component.scss'], }) export class StatItemComponent implements OnChanges { diff --git a/src/app/sections/payment-section/integrations/payment-link/create-invoice-or-invoice-template/create-invoice-or-invoice-template.service.ts b/src/app/sections/payment-section/integrations/payment-link/create-invoice-or-invoice-template/create-invoice-or-invoice-template.service.ts index 7d04ebb8..e7bc43e3 100644 --- a/src/app/sections/payment-section/integrations/payment-link/create-invoice-or-invoice-template/create-invoice-or-invoice-template.service.ts +++ b/src/app/sections/payment-section/integrations/payment-link/create-invoice-or-invoice-template/create-invoice-or-invoice-template.service.ts @@ -3,7 +3,7 @@ import { FormBuilder } from '@angular/forms'; import { ActivatedRoute } from '@angular/router'; import { pluck, shareReplay } from 'rxjs/operators'; -import { ShopService } from '../../../../../api'; +import { ApiShopsService } from '../../../../../api'; import { SHARE_REPLAY_CONF } from '../../../../../custom-operators'; import { filterShopsByRealm } from '../../../operations/operators'; @@ -17,5 +17,5 @@ export class CreateInvoiceOrInvoiceTemplateService { shareReplay(SHARE_REPLAY_CONF) ); - constructor(private fb: FormBuilder, private route: ActivatedRoute, private shopService: ShopService) {} + constructor(private fb: FormBuilder, private route: ActivatedRoute, private shopService: ApiShopsService) {} } diff --git a/src/app/sections/payment-section/integrations/shops/create-shop-dialog/create-shop-dialog.component.html b/src/app/sections/payment-section/integrations/shops/components/create-shop-dialog/create-shop-dialog.component.html similarity index 100% rename from src/app/sections/payment-section/integrations/shops/create-shop-dialog/create-shop-dialog.component.html rename to src/app/sections/payment-section/integrations/shops/components/create-shop-dialog/create-shop-dialog.component.html diff --git a/src/app/sections/payment-section/integrations/shops/create-shop-dialog/create-shop-dialog.component.scss b/src/app/sections/payment-section/integrations/shops/components/create-shop-dialog/create-shop-dialog.component.scss similarity index 100% rename from src/app/sections/payment-section/integrations/shops/create-shop-dialog/create-shop-dialog.component.scss rename to src/app/sections/payment-section/integrations/shops/components/create-shop-dialog/create-shop-dialog.component.scss diff --git a/src/app/sections/payment-section/integrations/shops/components/create-shop-dialog/create-shop-dialog.component.spec.ts b/src/app/sections/payment-section/integrations/shops/components/create-shop-dialog/create-shop-dialog.component.spec.ts new file mode 100644 index 00000000..2ad5cca1 --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/components/create-shop-dialog/create-shop-dialog.component.spec.ts @@ -0,0 +1 @@ +// TODO: add unit tests diff --git a/src/app/sections/payment-section/integrations/shops/create-shop-dialog/create-shop-dialog.component.ts b/src/app/sections/payment-section/integrations/shops/components/create-shop-dialog/create-shop-dialog.component.ts similarity index 100% rename from src/app/sections/payment-section/integrations/shops/create-shop-dialog/create-shop-dialog.component.ts rename to src/app/sections/payment-section/integrations/shops/components/create-shop-dialog/create-shop-dialog.component.ts diff --git a/src/app/sections/payment-section/integrations/shops/create-shop-dialog/index.ts b/src/app/sections/payment-section/integrations/shops/create-shop-dialog/index.ts deleted file mode 100644 index df25622a..00000000 --- a/src/app/sections/payment-section/integrations/shops/create-shop-dialog/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './create-shop-dialog.component'; diff --git a/src/app/sections/payment-section/integrations/shops/services/fetch-shops/combine-shop-item.ts b/src/app/sections/payment-section/integrations/shops/services/fetch-shops/combine-shop-item.ts new file mode 100644 index 00000000..e7c84e1c --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/services/fetch-shops/combine-shop-item.ts @@ -0,0 +1,21 @@ +import { isNil } from '@ngneat/transloco'; + +import { Dict } from '../../../../../../../type-utils'; +import { Shop as ApiShop } from '../../../../../../api-codegen/capi/swagger-codegen'; +import { ShopBalance } from '../../types/shop-balance'; +import { ShopItem } from '../../types/shop-item'; + +export function combineShopItem(shops: ApiShop[], balances: ShopBalance[]): ShopItem[] { + const balancesMap = balances.reduce((acc: Dict, el: ShopBalance) => { + acc[el.id] = el; + return acc; + }, {}); + + return shops.map((shop: ApiShop) => { + const balance = balancesMap[shop.id]; + return { + ...shop, + balance: isNil(balance) ? null : balance.data, + } as ShopItem; + }); +} diff --git a/src/app/sections/payment-section/integrations/shops/services/fetch-shops/fetch-shops.service.spec.ts b/src/app/sections/payment-section/integrations/shops/services/fetch-shops/fetch-shops.service.spec.ts new file mode 100644 index 00000000..cbed7d47 --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/services/fetch-shops/fetch-shops.service.spec.ts @@ -0,0 +1,485 @@ +import { TestBed } from '@angular/core/testing'; +import { cold } from 'jasmine-marbles'; +import { Observable, of, ReplaySubject } from 'rxjs'; +import { map } from 'rxjs/operators'; + +import { InlineResponse200, ShopLocation } from '../../../../../../api-codegen/anapi/swagger-codegen'; +import { Shop } from '../../../../../../api-codegen/capi/swagger-codegen'; +import { AnalyticsService } from '../../../../../../api/analytics'; +import { PaymentInstitutionRealm } from '../../../../../../api/model'; +import { ApiShopsService } from '../../../../../../api/shop'; +import { ShopBalanceModule } from '../../shops-list/shop-balance'; +import { ShopsBalanceService } from '../shops-balance/shops-balance.service'; +import { FetchShopsService } from './fetch-shops.service'; + +class MockApiShopsService { + shops$: Observable; + + private innerShops$ = new ReplaySubject(1); + private mockShops: Shop[]; + + constructor() { + this.shops$ = this.innerShops$.asObservable(); + } + + reloadShops(): void { + this.innerShops$.next(this.mockShops); + } + + setMockShops(shops: Shop[]): void { + this.mockShops = shops; + } +} + +class MockAnalyticsService { + private innerResponse: InlineResponse200 = { + result: [], + }; + + getGroupBalances(): Observable { + console.log('getGroupBalances'); + return of(this.innerResponse); + } + + setMockBalancesResponse(response: InlineResponse200): void { + this.innerResponse = response; + } +} + +describe('FetchShopsService', () => { + let service: FetchShopsService; + let apiShopsService: MockApiShopsService; + let analyticsService: MockAnalyticsService; + let balancesService: ShopBalanceModule; + + beforeEach(() => { + apiShopsService = new MockApiShopsService(); + analyticsService = new MockAnalyticsService(); + }); + + beforeEach(() => { + TestBed.configureTestingModule({ + providers: [ + FetchShopsService, + ShopsBalanceService, + { + provide: ApiShopsService, + useValue: apiShopsService, + }, + { + provide: AnalyticsService, + useValue: analyticsService, + }, + ], + }); + }); + + beforeEach(() => { + service = TestBed.inject(FetchShopsService); + balancesService = TestBed.inject(ShopsBalanceService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); + + describe('initRealm', () => { + it('should init realm and init allShops$ work', () => { + apiShopsService.setMockShops([ + { + id: 'mock1', + createdAt: new Date(), + isBlocked: false, + isSuspended: false, + categoryID: 1, + location: { + locationType: ShopLocation.LocationTypeEnum.ShopLocationUrl, + }, + details: { + name: 'my name', + description: 'some description', + }, + contractID: 'contractID', + payoutToolID: 'payoutToolID', + scheduleID: 1, + account: { + currency: 'USD', + guaranteeID: 2, + settlementID: 2, + }, + }, + { + id: 'mock2', + createdAt: new Date(), + isBlocked: false, + isSuspended: false, + categoryID: 1, + location: { + locationType: ShopLocation.LocationTypeEnum.ShopLocationUrl, + }, + details: { + name: 'my name', + description: 'some description', + }, + contractID: 'contractID', + payoutToolID: 'payoutToolID', + scheduleID: 1, + account: { + currency: 'USD', + guaranteeID: 2, + settlementID: 2, + }, + }, + { + id: 'mock3', + createdAt: new Date(), + isBlocked: false, + isSuspended: false, + categoryID: 3, + location: { + locationType: ShopLocation.LocationTypeEnum.ShopLocationUrl, + }, + details: { + name: 'my name', + description: 'some description', + }, + contractID: 'contractID', + payoutToolID: 'payoutToolID', + scheduleID: 1, + account: { + currency: 'USD', + guaranteeID: 2, + settlementID: 2, + }, + }, + ]); + + const expectedShops$ = cold('a', { + a: ['mock1', 'mock2'], + }); + + apiShopsService.reloadShops(); + service.initRealm(PaymentInstitutionRealm.test); + + expect( + service.allShops$.pipe( + map((list) => { + return list.map(({ id }) => id); + }) + ) + ).toBeObservable(expectedShops$); + }); + }); + + describe('initOffsetIndex', () => { + it('should init shop$ working', () => { + apiShopsService.setMockShops([ + { + id: 'mock1', + createdAt: new Date(), + isBlocked: false, + isSuspended: false, + categoryID: 1, + location: { + locationType: ShopLocation.LocationTypeEnum.ShopLocationUrl, + }, + details: { + name: 'my name', + description: 'some description', + }, + contractID: 'contractID', + payoutToolID: 'payoutToolID', + scheduleID: 1, + account: { + currency: 'USD', + guaranteeID: 2, + settlementID: 2, + }, + }, + { + id: 'mock2', + createdAt: new Date(), + isBlocked: false, + isSuspended: false, + categoryID: 1, + location: { + locationType: ShopLocation.LocationTypeEnum.ShopLocationUrl, + }, + details: { + name: 'my name', + description: 'some description', + }, + contractID: 'contractID', + payoutToolID: 'payoutToolID', + scheduleID: 1, + account: { + currency: 'USD', + guaranteeID: 2, + settlementID: 2, + }, + }, + { + id: 'mock3', + createdAt: new Date(), + isBlocked: false, + isSuspended: false, + categoryID: 1, + location: { + locationType: ShopLocation.LocationTypeEnum.ShopLocationUrl, + }, + details: { + name: 'my name', + description: 'some description', + }, + contractID: 'contractID', + payoutToolID: 'payoutToolID', + scheduleID: 1, + account: { + currency: 'USD', + guaranteeID: 2, + settlementID: 2, + }, + }, + { + id: 'mock4', + createdAt: new Date(), + isBlocked: false, + isSuspended: false, + categoryID: 1, + location: { + locationType: ShopLocation.LocationTypeEnum.ShopLocationUrl, + }, + details: { + name: 'my name', + description: 'some description', + }, + contractID: 'contractID', + payoutToolID: 'payoutToolID', + scheduleID: 1, + account: { + currency: 'USD', + guaranteeID: 2, + settlementID: 2, + }, + }, + { + id: 'mock5', + createdAt: new Date(), + isBlocked: false, + isSuspended: false, + categoryID: 1, + location: { + locationType: ShopLocation.LocationTypeEnum.ShopLocationUrl, + }, + details: { + name: 'my name', + description: 'some description', + }, + contractID: 'contractID', + payoutToolID: 'payoutToolID', + scheduleID: 1, + account: { + currency: 'USD', + guaranteeID: 2, + settlementID: 2, + }, + }, + { + id: 'mock6', + createdAt: new Date(), + isBlocked: false, + isSuspended: false, + categoryID: 1, + location: { + locationType: ShopLocation.LocationTypeEnum.ShopLocationUrl, + }, + details: { + name: 'my name', + description: 'some description', + }, + contractID: 'contractID', + payoutToolID: 'payoutToolID', + scheduleID: 1, + account: { + currency: 'USD', + guaranteeID: 2, + settlementID: 2, + }, + }, + { + id: 'mock7', + createdAt: new Date(), + isBlocked: false, + isSuspended: false, + categoryID: 1, + location: { + locationType: ShopLocation.LocationTypeEnum.ShopLocationUrl, + }, + details: { + name: 'my name', + description: 'some description', + }, + contractID: 'contractID', + payoutToolID: 'payoutToolID', + scheduleID: 1, + account: { + currency: 'USD', + guaranteeID: 2, + settlementID: 2, + }, + }, + ]); + + const expectedShops$ = cold('a', { + a: ['mock1', 'mock2', 'mock3', 'mock4', 'mock5'], + }); + + apiShopsService.reloadShops(); + service.initRealm(PaymentInstitutionRealm.test); + service.initOffsetIndex(3); + + expect( + service.loadedShops$.pipe( + map((list) => { + return list.map(({ id }) => id); + }) + ) + ).toBeObservable(expectedShops$); + }); + }); + + describe('refreshData', () => { + it('should call apiShopService reload method', () => { + const spyOnApiShopService = spyOn(apiShopsService, 'reloadShops').and.callThrough(); + + service.refreshData(); + + expect(spyOnApiShopService).toHaveBeenCalledTimes(1); + }); + + it('should update allShops list', () => { + apiShopsService.setMockShops([ + { + id: 'mock6', + createdAt: new Date(), + isBlocked: false, + isSuspended: false, + categoryID: 1, + location: { + locationType: ShopLocation.LocationTypeEnum.ShopLocationUrl, + }, + details: { + name: 'my name', + description: 'some description', + }, + contractID: 'contractID', + payoutToolID: 'payoutToolID', + scheduleID: 1, + account: { + currency: 'USD', + guaranteeID: 2, + settlementID: 2, + }, + }, + ]); + + service.initRealm(PaymentInstitutionRealm.test); + apiShopsService.reloadShops(); + + apiShopsService.setMockShops([ + { + id: 'mock6', + createdAt: new Date(), + isBlocked: false, + isSuspended: false, + categoryID: 1, + location: { + locationType: ShopLocation.LocationTypeEnum.ShopLocationUrl, + }, + details: { + name: 'my name', + description: 'some description', + }, + contractID: 'contractID', + payoutToolID: 'payoutToolID', + scheduleID: 1, + account: { + currency: 'USD', + guaranteeID: 2, + settlementID: 2, + }, + }, + { + id: 'mock16', + createdAt: new Date(), + isBlocked: false, + isSuspended: false, + categoryID: 1, + location: { + locationType: ShopLocation.LocationTypeEnum.ShopLocationUrl, + }, + details: { + name: 'my name', + description: 'some description', + }, + contractID: 'contractID', + payoutToolID: 'payoutToolID', + scheduleID: 1, + account: { + currency: 'USD', + guaranteeID: 2, + settlementID: 2, + }, + }, + ]); + + service.refreshData(); + + const expectedShops$ = cold('a', { + a: ['mock6', 'mock16'], + }); + + expect( + service.allShops$.pipe( + map((list) => { + return list.map(({ id }) => id); + }) + ) + ).toBeObservable(expectedShops$); + }); + + it('should update loading value', () => { + apiShopsService.setMockShops([]); + + apiShopsService.reloadShops(); + service.initRealm(PaymentInstitutionRealm.test); + service.initOffsetIndex(-1); + + service.refreshData(); + + expect(service.isLoading$).toBeObservable( + cold('a', { + a: true, + }) + ); + }); + }); + + describe('showMore', () => { + it('should update loading value', () => { + apiShopsService.setMockShops([]); + + apiShopsService.reloadShops(); + service.initRealm(PaymentInstitutionRealm.test); + service.initOffsetIndex(-1); + + service.showMore(); + + expect(service.isLoading$).toBeObservable( + cold('a', { + a: true, + }) + ); + }); + }); +}); diff --git a/src/app/sections/payment-section/integrations/shops/services/fetch-shops/fetch-shops.service.ts b/src/app/sections/payment-section/integrations/shops/services/fetch-shops/fetch-shops.service.ts new file mode 100644 index 00000000..c32fd10d --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/services/fetch-shops/fetch-shops.service.ts @@ -0,0 +1,124 @@ +import { Injectable } from '@angular/core'; +import { BehaviorSubject, combineLatest, Observable, ReplaySubject } from 'rxjs'; +import { + distinctUntilChanged, + map, + mapTo, + pluck, + scan, + shareReplay, + switchMap, + tap, + withLatestFrom, +} from 'rxjs/operators'; + +import { Shop as ApiShop } from '../../../../../../api-codegen/capi/swagger-codegen'; +import { PaymentInstitutionRealm } from '../../../../../../api/model'; +import { ApiShopsService } from '../../../../../../api/shop'; +import { SHARE_REPLAY_CONF } from '../../../../../../custom-operators'; +import { filterShopsByRealm, mapToTimestamp } from '../../../../operations/operators'; +import { ShopBalance } from '../../types/shop-balance'; +import { ShopItem } from '../../types/shop-item'; +import { ShopsBalanceService } from '../shops-balance/shops-balance.service'; +import { combineShopItem } from './combine-shop-item'; + +const LIST_OFFSET = 5; + +@Injectable() +export class FetchShopsService { + allShops$: Observable; + loadedShops$: Observable; + lastUpdated$: Observable; + isLoading$: Observable; + hasMore$: Observable; + + private selectedIndex$ = new ReplaySubject(1); + private listOffset$: Observable; + + private realmData$ = new ReplaySubject(1); + + private showMore$ = new ReplaySubject(1); + private loader$ = new BehaviorSubject(true); + + constructor(private apiShopsService: ApiShopsService, private shopsBalance: ShopsBalanceService) { + this.initAllShopsFetching(); + this.initOffsetObservable(); + this.initShownShopsObservable(); + this.initIndicators(); + } + + initRealm(realm: PaymentInstitutionRealm): void { + this.realmData$.next(realm); + } + + initOffsetIndex(offsetIndex: number): void { + this.selectedIndex$.next(offsetIndex); + this.showMore$.next(); + } + + refreshData(): void { + this.startLoading(); + this.apiShopsService.reloadShops(); + } + + showMore(): void { + this.startLoading(); + this.showMore$.next(); + } + + protected startLoading(): void { + this.loader$.next(true); + } + + protected stopLoading(): void { + this.loader$.next(false); + } + + protected updateShopsBalances(shops: ApiShop[]): void { + const shopIds: string[] = shops.map(({ id }: ApiShop) => id); + this.shopsBalance.setShopIds(shopIds); + } + + private initAllShopsFetching(): void { + this.allShops$ = this.realmData$.pipe( + filterShopsByRealm(this.apiShopsService.shops$), + shareReplay(SHARE_REPLAY_CONF) + ); + } + + private initOffsetObservable(): void { + this.listOffset$ = this.showMore$.pipe( + mapTo(LIST_OFFSET), + withLatestFrom(this.selectedIndex$), + map(([curOffset]: [number, number]) => curOffset), + scan((offset: number, limit: number) => offset + limit, 0), + shareReplay(SHARE_REPLAY_CONF) + ); + } + + private initShownShopsObservable(): void { + this.loadedShops$ = combineLatest([this.allShops$, this.listOffset$]).pipe( + map(([shops, showedCount]: [ShopItem[], number]) => shops.slice(0, showedCount)), + tap((shops: ApiShop[]) => { + this.updateShopsBalances(shops); + }), + switchMap((shops: ApiShop[]) => { + return this.shopsBalance.balances$.pipe( + distinctUntilChanged(), + map((balances: ShopBalance[]) => combineShopItem(shops, balances)) + ); + }), + tap(() => this.stopLoading()), + shareReplay(SHARE_REPLAY_CONF) + ); + } + + private initIndicators(): void { + this.lastUpdated$ = this.allShops$.pipe(mapToTimestamp, shareReplay(1)); + this.isLoading$ = this.loader$.asObservable(); + this.hasMore$ = combineLatest([this.allShops$.pipe(pluck('length')), this.listOffset$]).pipe( + map(([count, showedCount]: [number, number]) => count > showedCount), + shareReplay(SHARE_REPLAY_CONF) + ); + } +} diff --git a/src/app/sections/payment-section/integrations/shops/services/shops-balance/shops-balance.service.spec.ts b/src/app/sections/payment-section/integrations/shops/services/shops-balance/shops-balance.service.spec.ts new file mode 100644 index 00000000..69eafabb --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/services/shops-balance/shops-balance.service.spec.ts @@ -0,0 +1,201 @@ +import { Injectable } from '@angular/core'; +import { TestBed } from '@angular/core/testing'; +import { cold } from 'jasmine-marbles'; +import { Observable, of } from 'rxjs'; +import { map } from 'rxjs/operators'; + +import { AnalyticsService as APIAnalyticsService } from '../../../../../../api-codegen/anapi'; +import { InlineResponse200 } from '../../../../../../api-codegen/anapi/swagger-codegen'; +import { AnalyticsService } from '../../../../../../api/analytics'; +import { ShopsBalanceService } from './shops-balance.service'; + +@Injectable() +class MockAnalyticsService extends AnalyticsService { + set mockGroupBalances(value: InlineResponse200) { + this._mockGroupBalances = value; + } + private _mockGroupBalances: InlineResponse200; + + getGroupBalances(): Observable { + return of(this._mockGroupBalances); + } +} + +describe('ShopsBalanceService', () => { + let service: ShopsBalanceService; + let analyticsService: MockAnalyticsService; + + beforeEach(() => { + TestBed.configureTestingModule({ + providers: [ + ShopsBalanceService, + { + provide: AnalyticsService, + useClass: MockAnalyticsService, + }, + { + provide: APIAnalyticsService, + useValue: null, // not used + }, + ], + }); + service = TestBed.inject(ShopsBalanceService); + analyticsService = TestBed.inject(AnalyticsService) as MockAnalyticsService; + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); + + describe('balances$', () => { + it('should return balances list from AnalyticsService', () => { + const expected$ = cold('a', { + a: [ + { + id: 'first-shop', + data: { + amount: 20, + currency: 'USD', + }, + }, + { + id: 'second-shop', + data: { + amount: 4, + currency: 'USD', + }, + }, + { + id: 'third-shop', + data: { + amount: 2, + currency: 'USD', + }, + }, + ], + }); + + analyticsService.mockGroupBalances = { + result: [ + { + groupBySHopResults: [ + { + id: 'first-shop', + amountResults: [ + { + amount: 20, + currency: 'USD', + }, + ], + }, + { + id: 'second-shop', + amountResults: [ + { + amount: 4, + currency: 'USD', + }, + ], + }, + { + id: 'third-shop', + amountResults: [ + { + amount: 2, + currency: 'USD', + }, + ], + }, + ], + }, + ], + }; + + expect(service.balances$).toBeObservable(expected$); + }); + + it('should return list with nullable data if api has no data for some shops', () => { + const expected$ = cold('a', { + a: [ + { + id: 'first-shop', + data: null, + }, + { + id: 'second-shop', + data: null, + }, + { + id: 'third-shop', + data: { + amount: 2, + currency: 'USD', + }, + }, + ], + }); + + analyticsService.mockGroupBalances = { + result: [ + { + groupBySHopResults: [ + { + id: 'first-shop', + amountResults: [], + }, + { + id: 'second-shop', + }, + { + id: 'third-shop', + amountResults: [ + { + amount: 2, + currency: 'USD', + }, + ], + }, + ], + }, + ], + }; + + expect(service.balances$).toBeObservable(expected$); + }); + + it('should return empty balances list if api has no data', () => { + const expected$ = cold('a', { + a: [], + }); + + analyticsService.mockGroupBalances = { + result: [ + { + groupBySHopResults: [], + }, + ], + }; + + expect(service.balances$).toBeObservable(expected$); + }); + + it('should return empty balances list if there was an error', () => { + const expected$ = cold('a', { + a: [], + }); + + analyticsService.getGroupBalances = () => { + return of({ + result: [], + }).pipe( + map(() => { + throw new Error('[TEST ERROR] Mock Error'); + }) + ); + }; + + expect(service.balances$).toBeObservable(expected$); + }); + }); + // setShopIds +}); diff --git a/src/app/sections/payment-section/integrations/shops/services/shops-balance/shops-balance.service.ts b/src/app/sections/payment-section/integrations/shops/services/shops-balance/shops-balance.service.ts new file mode 100644 index 00000000..04c155c4 --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/services/shops-balance/shops-balance.service.ts @@ -0,0 +1,44 @@ +import { Injectable } from '@angular/core'; +import { isNil } from '@ngneat/transloco'; +import { Observable, of, ReplaySubject } from 'rxjs'; +import { catchError, distinctUntilChanged, map, shareReplay, switchMap } from 'rxjs/operators'; + +import { AnalyticsService } from '../../../../../../api/analytics'; +import { SHARE_REPLAY_CONF } from '../../../../../../custom-operators'; +import { ShopBalance } from '../../types/shop-balance'; + +@Injectable() +export class ShopsBalanceService { + balances$: Observable; + + private shopIDsChange$ = new ReplaySubject(1); + + constructor(private analyticsService: AnalyticsService) { + this.balances$ = this.shopIDsChange$.pipe( + distinctUntilChanged(), + switchMap((shopIDs: string[]) => { + return this.analyticsService.getGroupBalances({ shopIDs }).pipe( + map(({ result }) => { + return result + .flatMap(({ groupBySHopResults }) => groupBySHopResults) + .map(({ id, amountResults = [] }) => { + return { + id, + data: isNil(amountResults) || isNil(amountResults[0]) ? null : amountResults[0], + }; + }); + }), + catchError((err) => { + console.error(err); + return of([]); + }) + ); + }), + shareReplay(SHARE_REPLAY_CONF) + ); + } + + setShopIds(shopIDs: string[]): void { + this.shopIDsChange$.next(shopIDs); + } +} diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/components/shop-row-header/shop-row-header.component.html b/src/app/sections/payment-section/integrations/shops/shops-list/components/shop-row-header/shop-row-header.component.html new file mode 100644 index 00000000..cb46b02b --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/components/shop-row-header/shop-row-header.component.html @@ -0,0 +1,10 @@ + + {{ s('panel.name') }} + {{ s('panel.balance') }} + diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/components/shop-row-header/shop-row-header.component.spec.ts b/src/app/sections/payment-section/integrations/shops/shops-list/components/shop-row-header/shop-row-header.component.spec.ts new file mode 100644 index 00000000..2ad5cca1 --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/components/shop-row-header/shop-row-header.component.spec.ts @@ -0,0 +1 @@ +// TODO: add unit tests diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/components/shop-row-header/shop-row-header.component.ts b/src/app/sections/payment-section/integrations/shops/shops-list/components/shop-row-header/shop-row-header.component.ts new file mode 100644 index 00000000..473996dc --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/components/shop-row-header/shop-row-header.component.ts @@ -0,0 +1,8 @@ +import { ChangeDetectionStrategy, Component } from '@angular/core'; + +@Component({ + selector: 'dsh-shop-row-header', + templateUrl: 'shop-row-header.component.html', + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class ShopRowHeaderComponent {} diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/components/shop-row/shop-row.component.html b/src/app/sections/payment-section/integrations/shops/shops-list/components/shop-row/shop-row.component.html new file mode 100644 index 00000000..34e8d0b6 --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/components/shop-row/shop-row.component.html @@ -0,0 +1,14 @@ + + + + + + Loading ... + + + + {{ item.details.name }} + + + + diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/components/shop-row/shop-row.component.spec.ts b/src/app/sections/payment-section/integrations/shops/shops-list/components/shop-row/shop-row.component.spec.ts new file mode 100644 index 00000000..2ad5cca1 --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/components/shop-row/shop-row.component.spec.ts @@ -0,0 +1 @@ +// TODO: add unit tests diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/components/shop-row/shop-row.component.ts b/src/app/sections/payment-section/integrations/shops/shops-list/components/shop-row/shop-row.component.ts new file mode 100644 index 00000000..d229e222 --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/components/shop-row/shop-row.component.ts @@ -0,0 +1,12 @@ +import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; + +import { ShopItem } from '../../../types/shop-item'; + +@Component({ + selector: 'dsh-shop-row', + templateUrl: 'shop-row.component.html', + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class ShopRowComponent { + @Input() shop: ShopItem; +} diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/services/shops-expanded-id-manager/shops-expanded-id-manager.service.spec.ts b/src/app/sections/payment-section/integrations/shops/shops-list/services/shops-expanded-id-manager/shops-expanded-id-manager.service.spec.ts new file mode 100644 index 00000000..e88ad2ce --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/services/shops-expanded-id-manager/shops-expanded-id-manager.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { ShopsExpandedIdManagerService } from './shops-expanded-id-manager.service'; + +describe('ShopsExpandedIdManagerService', () => { + let service: ShopsExpandedIdManagerService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(ShopsExpandedIdManagerService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/services/shops-expanded-id-manager/shops-expanded-id-manager.service.ts b/src/app/sections/payment-section/integrations/shops/shops-list/services/shops-expanded-id-manager/shops-expanded-id-manager.service.ts new file mode 100644 index 00000000..ca53d1ec --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/services/shops-expanded-id-manager/shops-expanded-id-manager.service.ts @@ -0,0 +1,19 @@ +import { Injectable } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; +import { Observable } from 'rxjs'; + +import { ExpandedIdManager } from '@dsh/app/shared/services'; + +import { Shop } from '../../../../../../../api-codegen/capi/swagger-codegen'; +import { FetchShopsService } from '../../../services/fetch-shops/fetch-shops.service'; + +@Injectable() +export class ShopsExpandedIdManagerService extends ExpandedIdManager { + constructor(protected route: ActivatedRoute, protected router: Router, private shopsService: FetchShopsService) { + super(route, router); + } + + protected get dataSet$(): Observable { + return this.shopsService.allShops$; + } +} diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/shop-balance/index.ts b/src/app/sections/payment-section/integrations/shops/shops-list/shop-balance/index.ts new file mode 100644 index 00000000..27e85103 --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/shop-balance/index.ts @@ -0,0 +1 @@ +export * from './shop-balance.module'; diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/shop-balance/shop-balance.component.html b/src/app/sections/payment-section/integrations/shops/shops-list/shop-balance/shop-balance.component.html new file mode 100644 index 00000000..d5c285b1 --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/shop-balance/shop-balance.component.html @@ -0,0 +1,8 @@ + + + + {{ balance.amount | toMajor | currency: balance.currency:'symbol' }} + +--/-- diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/shop-balance/shop-balance.component.spec.ts b/src/app/sections/payment-section/integrations/shops/shops-list/shop-balance/shop-balance.component.spec.ts new file mode 100644 index 00000000..fdcabdfc --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/shop-balance/shop-balance.component.spec.ts @@ -0,0 +1,58 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ShopLocation } from '../../../../../../api-codegen/anapi/swagger-codegen'; +import { ToMajorModule } from '../../../../../../to-major'; +import { ShopItem } from '../../types/shop-item'; +import { ShopBalanceComponent } from './shop-balance.component'; + +const mockShop: ShopItem = { + id: 'mock', + createdAt: new Date(), + isBlocked: false, + isSuspended: false, + categoryID: 1, + location: { + locationType: ShopLocation.LocationTypeEnum.ShopLocationUrl, + url: 'example.com', + }, + details: { + name: 'my name', + description: 'some description', + }, + contractID: 'contractID', + payoutToolID: 'payoutToolID', + scheduleID: 1, + account: { + currency: 'USD', + guaranteeID: 2, + settlementID: 2, + }, + balance: { + amount: 20, + currency: 'USD', + }, +}; + +describe('ShopBalanceComponent', () => { + let component: ShopBalanceComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [ToMajorModule], + declarations: [ShopBalanceComponent], + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ShopBalanceComponent); + component = fixture.componentInstance; + + component.shop = mockShop; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/shop-balance/shop-balance.component.ts b/src/app/sections/payment-section/integrations/shops/shops-list/shop-balance/shop-balance.component.ts new file mode 100644 index 00000000..c97f564a --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/shop-balance/shop-balance.component.ts @@ -0,0 +1,12 @@ +import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; + +import { ShopItem } from '../../types/shop-item'; + +@Component({ + selector: 'dsh-shop-balance', + templateUrl: 'shop-balance.component.html', + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class ShopBalanceComponent { + @Input() shop: ShopItem; +} diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/shop-balance/shop-balance.module.ts b/src/app/sections/payment-section/integrations/shops/shops-list/shop-balance/shop-balance.module.ts new file mode 100644 index 00000000..cf8da5a3 --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/shop-balance/shop-balance.module.ts @@ -0,0 +1,12 @@ +import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; + +import { ToMajorModule } from '../../../../../../to-major'; +import { ShopBalanceComponent } from './shop-balance.component'; + +@NgModule({ + imports: [CommonModule, ToMajorModule], + declarations: [ShopBalanceComponent], + exports: [ShopBalanceComponent], +}) +export class ShopBalanceModule {} diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-actions/shop-actions.component.html b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-actions/shop-actions.component.html new file mode 100644 index 00000000..b763f75f --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-actions/shop-actions.component.html @@ -0,0 +1,22 @@ + +
{{ p('actions') }}
+
+ +
+
+ + + + + + + + + + + + diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-actions/shop-actions.component.spec.ts b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-actions/shop-actions.component.spec.ts new file mode 100644 index 00000000..b285280c --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-actions/shop-actions.component.spec.ts @@ -0,0 +1,226 @@ +import { Injectable } from '@angular/core'; +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { MatDialog, MatDialogRef } from '@angular/material/dialog'; +import { MatSnackBarModule } from '@angular/material/snack-bar'; +import { TranslocoTestingModule } from '@ngneat/transloco'; +import cloneDeep from 'lodash.clonedeep'; +import { Observable, of } from 'rxjs'; + +import { ShopLocation } from '../../../../../../../../api-codegen/anapi/swagger-codegen'; +import { ShopsService } from '../../../../../../../../api-codegen/capi/shops.service'; +import { Shop } from '../../../../../../../../api-codegen/capi/swagger-codegen'; +import { ApiShopsService } from '../../../../../../../../api/shop'; +import { ShopItem } from '../../../../types/shop-item'; +import { ShopActionsService } from '../../services/shop-actions/shop-actions.service'; +import { ShopActionResult } from '../../types/shop-action-result'; +import { ShopActionsComponent } from './shop-actions.component'; + +const mockShop: ShopItem = { + id: 'mock', + createdAt: new Date(), + isBlocked: false, + isSuspended: false, + categoryID: 1, + location: { + locationType: ShopLocation.LocationTypeEnum.ShopLocationUrl, + url: 'example.com', + }, + details: { + name: 'my name', + description: 'some description', + }, + contractID: 'contractID', + payoutToolID: 'payoutToolID', + scheduleID: 1, + account: { + currency: 'USD', + guaranteeID: 2, + settlementID: 2, + }, + balance: { + amount: 20, + currency: 'USD', + }, +}; + +class MockShopsService { + getShops(): Observable { + return of([]); + } +} + +@Injectable() +class MockApiShopsService extends ApiShopsService { + set mockShops(shops: Shop[]) { + this._shops = shops; + } + private _shops: Shop[] = []; + + set mockActionResponse(response: any) { + this._actionResponse = response; + } + private _actionResponse: any; + + getShopByID(shopID: string): Observable { + return of(this._shops.find(({ id }) => id === shopID)); + } + + getShops(): Observable { + return of(this._shops); + } + + reloadShops() { + this._shops = cloneDeep(this._shops); + } + + suspendShop() { + return of(this._actionResponse); + } + + activateShop() { + return of(this._actionResponse); + } +} + +class MockMatDialogRef extends MatDialogRef {} + +class MockMatDialog { + private _dialogRef: MockMatDialogRef; + + get dialogRef(): MockMatDialogRef { + return this._dialogRef; + } + + open(): MockMatDialogRef { + this._dialogRef = new MockMatDialogRef(null, null); + return this._dialogRef; + } +} + +describe('ShopActionsComponent', () => { + let component: ShopActionsComponent; + let fixture: ComponentFixture; + let mockDialog: MockMatDialog; + let actionsService: ShopActionsService; + + beforeEach(async(() => { + mockDialog = new MockMatDialog(); + + TestBed.configureTestingModule({ + imports: [ + TranslocoTestingModule.withLangs({ + en: { + shops: { + panel: { + activate: 'activate', + suspend: 'suspend', + }, + suspend: { + success: 'success suspend', + error: 'error suspend', + }, + activate: { + success: 'success activate', + error: 'error activate', + }, + }, + }, + }), + MatSnackBarModule, + ], + declarations: [ShopActionsComponent], + providers: [ + ShopActionsService, + { + provide: ApiShopsService, + useClass: MockApiShopsService, + }, + { + provide: ShopsService, + useClass: MockShopsService, + }, + { + provide: MatDialog, + useValue: mockDialog, + }, + ], + }) + .overrideComponent(ShopActionsComponent, { set: { providers: [] } }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ShopActionsComponent); + component = fixture.componentInstance; + actionsService = TestBed.inject(ShopActionsService); + + component.shop = mockShop; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); + + describe('suspend', () => { + it('should call service suspend method', () => { + const spyOnSuspend = spyOn(actionsService, 'suspend').and.returnValue(of(ShopActionResult.SUCCESS)); + + component.suspend('id'); + + expect(spyOnSuspend).toHaveBeenCalledTimes(1); + expect(spyOnSuspend).toHaveBeenCalledWith('id'); + }); + + it('should emit update data if suspend was successful', () => { + const spyOnSuspend = spyOn(actionsService, 'suspend').and.returnValue(of(ShopActionResult.SUCCESS)); + const spyOnUpdateData = spyOn(component.updateData, 'emit'); + + component.suspend('id'); + + expect(spyOnSuspend).toHaveBeenCalledTimes(1); + expect(spyOnUpdateData).toHaveBeenCalledTimes(1); + }); + + it('should emit update data if suspend was not successful', () => { + const spyOnSuspend = spyOn(actionsService, 'suspend').and.returnValue(of(ShopActionResult.ERROR)); + const spyOnUpdateData = spyOn(component.updateData, 'emit'); + + component.suspend('id'); + + expect(spyOnSuspend).toHaveBeenCalledTimes(1); + expect(spyOnUpdateData).not.toHaveBeenCalledTimes(1); + }); + }); + + describe('activate', () => { + it('should call service activate method', () => { + const spyOnActivate = spyOn(actionsService, 'activate').and.returnValue(of(ShopActionResult.SUCCESS)); + + component.activate('id'); + + expect(spyOnActivate).toHaveBeenCalledTimes(1); + expect(spyOnActivate).toHaveBeenCalledWith('id'); + }); + + it('should emit update data if activate was successful', () => { + const spyOnActivate = spyOn(actionsService, 'activate').and.returnValue(of(ShopActionResult.SUCCESS)); + const spyOnUpdateData = spyOn(component.updateData, 'emit'); + + component.activate('id'); + + expect(spyOnActivate).toHaveBeenCalledTimes(1); + expect(spyOnUpdateData).toHaveBeenCalledTimes(1); + }); + + it('should emit update data if activate was not successful', () => { + const spyOnActivate = spyOn(actionsService, 'activate').and.returnValue(of(ShopActionResult.ERROR)); + const spyOnUpdateData = spyOn(component.updateData, 'emit'); + + component.activate('id'); + + expect(spyOnActivate).toHaveBeenCalledTimes(1); + expect(spyOnUpdateData).not.toHaveBeenCalledTimes(1); + }); + }); +}); diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-actions/shop-actions.component.ts b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-actions/shop-actions.component.ts new file mode 100644 index 00000000..49fea05b --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-actions/shop-actions.component.ts @@ -0,0 +1,38 @@ +import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core'; +import { filter, take } from 'rxjs/operators'; + +import { ShopItem } from '../../../../types/shop-item'; +import { isSuccessfulShopAction } from '../../services/shop-actions/is-successful-shop-action'; +import { ShopActionsService } from '../../services/shop-actions/shop-actions.service'; + +@Component({ + selector: 'dsh-shop-actions', + templateUrl: 'shop-actions.component.html', + changeDetection: ChangeDetectionStrategy.OnPush, + providers: [ShopActionsService], +}) +export class ShopActionsComponent { + @Input() shop: ShopItem; + + @Output() updateData = new EventEmitter(); + + constructor(private shopActions: ShopActionsService) {} + + suspend(id: string): void { + this.shopActions + .suspend(id) + .pipe(take(1), filter(isSuccessfulShopAction)) + .subscribe(() => { + this.updateData.emit(); + }); + } + + activate(id: string): void { + this.shopActions + .activate(id) + .pipe(take(1), filter(isSuccessfulShopAction)) + .subscribe(() => { + this.updateData.emit(); + }); + } +} diff --git a/src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-contract-details/shop-contract-details.component.html b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-contract-details/shop-contract-details.component.html similarity index 100% rename from src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-contract-details/shop-contract-details.component.html rename to src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-contract-details/shop-contract-details.component.html diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-contract-details/shop-contract-details.component.spec.ts b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-contract-details/shop-contract-details.component.spec.ts new file mode 100644 index 00000000..2ad5cca1 --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-contract-details/shop-contract-details.component.spec.ts @@ -0,0 +1 @@ +// TODO: add unit tests diff --git a/src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-contract-details/shop-contract-details.component.ts b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-contract-details/shop-contract-details.component.ts similarity index 85% rename from src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-contract-details/shop-contract-details.component.ts rename to src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-contract-details/shop-contract-details.component.ts index 27cc8a89..386ebe7c 100644 --- a/src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-contract-details/shop-contract-details.component.ts +++ b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-contract-details/shop-contract-details.component.ts @@ -1,6 +1,6 @@ import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; -import { ShopContractDetailsService } from './shop-contract-details.service'; +import { ShopContractDetailsService } from '../../services/shop-contract-details/shop-contract-details.service'; @Component({ selector: 'dsh-shop-contract-details', diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-id/shop-id.component.html b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-id/shop-id.component.html new file mode 100644 index 00000000..73b248c0 --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-id/shop-id.component.html @@ -0,0 +1,9 @@ + +
{{ p('id') }}
+
{{ id }}
+
+ +
+
diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-id/shop-id.component.spec.ts b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-id/shop-id.component.spec.ts new file mode 100644 index 00000000..5913f41c --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-id/shop-id.component.spec.ts @@ -0,0 +1,60 @@ +import { ClipboardModule } from '@angular/cdk/clipboard'; +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar'; +import { TranslocoTestingModule } from '@ngneat/transloco'; + +import { ShopIdComponent } from './shop-id.component'; + +describe('ShopIdComponent', () => { + let component: ShopIdComponent; + let fixture: ComponentFixture; + let snackbar: MatSnackBar; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [ + TranslocoTestingModule.withLangs({ + en: { + copied: 'Copied!', + copyFailed: 'CopyFailed!', + }, + }), + MatSnackBarModule, + ClipboardModule, + ], + declarations: [ShopIdComponent], + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ShopIdComponent); + component = fixture.componentInstance; + snackbar = TestBed.inject(MatSnackBar); + + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); + + describe('copied', () => { + it('should open snackbar with successful copy text', () => { + const spyOnSnackBar = spyOn(snackbar, 'open').and.returnValue(null); + + component.copied(true); + + expect(spyOnSnackBar).toHaveBeenCalledTimes(1); + expect(spyOnSnackBar).toHaveBeenCalledWith('en.copied', 'OK', { duration: 1000 }); + }); + + it('should open snackbar with error copy text', () => { + const spyOnSnackBar = spyOn(snackbar, 'open').and.returnValue(null); + + component.copied(false); + + expect(spyOnSnackBar).toHaveBeenCalledTimes(1); + expect(spyOnSnackBar).toHaveBeenCalledWith('en.copyFailed', 'OK', { duration: 1000 }); + }); + }); +}); diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-id/shop-id.component.ts b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-id/shop-id.component.ts new file mode 100644 index 00000000..4444802d --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-id/shop-id.component.ts @@ -0,0 +1,18 @@ +import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; +import { MatSnackBar } from '@angular/material/snack-bar'; +import { TranslocoService } from '@ngneat/transloco'; + +@Component({ + selector: 'dsh-shop-id', + templateUrl: 'shop-id.component.html', + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class ShopIdComponent { + @Input() id: string; + + constructor(private snackBar: MatSnackBar, private transloco: TranslocoService) {} + + copied(isCopied: boolean) { + this.snackBar.open(this.transloco.translate(isCopied ? 'copied' : 'copyFailed'), 'OK', { duration: 1000 }); + } +} diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-info/shop-info.component.html b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-info/shop-info.component.html new file mode 100644 index 00000000..e5303abb --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-info/shop-info.component.html @@ -0,0 +1,15 @@ +
+ {{ shop.details.name }} + {{ shop.location.url }} +
+ + + + {{ + shop.createdAt | date: 'dd MMMM yyyy, HH:mm:ss' + }} + {{ + (category$ | async)?.name + }} +
+
diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-info/shop-info.component.spec.ts b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-info/shop-info.component.spec.ts new file mode 100644 index 00000000..bfa713a8 --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-info/shop-info.component.spec.ts @@ -0,0 +1,102 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { FlexLayoutModule } from '@angular/flex-layout'; +import { TranslocoTestingModule } from '@ngneat/transloco'; +import { Subject } from 'rxjs'; + +import { DetailsItemModule } from '@dsh/components/layout'; + +import { ShopLocation } from '../../../../../../../../api-codegen/anapi/swagger-codegen'; +import { Category } from '../../../../../../../../api-codegen/capi/swagger-codegen'; +import { ShopItem } from '../../../../types/shop-item'; +import { ShopBalanceModule } from '../../../shop-balance'; +import { CategoryService } from '../../services/category/category.service'; +import { ShopInfoComponent } from './shop-info.component'; + +const mockShop: ShopItem = { + id: 'mock', + createdAt: new Date(), + isBlocked: false, + isSuspended: false, + categoryID: 1, + location: { + locationType: ShopLocation.LocationTypeEnum.ShopLocationUrl, + url: 'example.com', + }, + details: { + name: 'my name', + description: 'some description', + }, + contractID: 'contractID', + payoutToolID: 'payoutToolID', + scheduleID: 1, + account: { + currency: 'USD', + guaranteeID: 2, + settlementID: 2, + }, + balance: { + amount: 20, + currency: 'USD', + }, +}; + +class MockCategoryService { + category$ = new Subject(); + + updateID(categoryID: number) { + this.category$.next({ + categoryID, + name: 'Mock Category', + }); + } +} + +describe('ShopInfoComponent', () => { + let component: ShopInfoComponent; + let fixture: ComponentFixture; + let mockCategoryService: MockCategoryService; + + beforeEach(async(() => { + mockCategoryService = new MockCategoryService(); + + TestBed.configureTestingModule({ + imports: [ + TranslocoTestingModule.withLangs({ + en: { + shops: { + panel: { + name: 'PanelName', + url: 'PanelUrl', + balance: 'PanelBalance', + createdAt: 'PanelCreatedAt', + category: 'PanelCategory', + }, + }, + }, + }), + FlexLayoutModule, + DetailsItemModule, + ShopBalanceModule, + ], + declarations: [ShopInfoComponent], + providers: [ + { + provide: CategoryService, + useValue: mockCategoryService, + }, + ], + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ShopInfoComponent); + component = fixture.componentInstance; + + component.shop = mockShop; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-info/shop-info.component.ts b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-info/shop-info.component.ts new file mode 100644 index 00000000..8e372830 --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-info/shop-info.component.ts @@ -0,0 +1,32 @@ +import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; +import isNil from 'lodash.isnil'; +import { Observable } from 'rxjs'; + +import { Category } from '../../../../../../../../api-codegen/capi/swagger-codegen'; +import { ShopItem } from '../../../../types/shop-item'; +import { CategoryService } from '../../services/category/category.service'; + +@Component({ + selector: 'dsh-shop-info', + templateUrl: 'shop-info.component.html', + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class ShopInfoComponent { + @Input() + get shop(): ShopItem { + return this._shop; + } + set shop(shopItem: ShopItem) { + this._shop = shopItem; + if (isNil(shopItem)) { + return; + } + this.categoryService.updateID(shopItem.categoryID); + } + + category$: Observable = this.categoryService.category$; + + private _shop: ShopItem; + + constructor(private categoryService: CategoryService) {} +} diff --git a/src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-payout-tool-details/shop-payout-tool-details.component.html b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-payout-tool-details/shop-payout-tool-details.component.html similarity index 100% rename from src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-payout-tool-details/shop-payout-tool-details.component.html rename to src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-payout-tool-details/shop-payout-tool-details.component.html diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-payout-tool-details/shop-payout-tool-details.component.spec.ts b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-payout-tool-details/shop-payout-tool-details.component.spec.ts new file mode 100644 index 00000000..2ad5cca1 --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-payout-tool-details/shop-payout-tool-details.component.spec.ts @@ -0,0 +1 @@ +// TODO: add unit tests diff --git a/src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-payout-tool-details/shop-payout-tool-details.component.ts b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-payout-tool-details/shop-payout-tool-details.component.ts similarity index 78% rename from src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-payout-tool-details/shop-payout-tool-details.component.ts rename to src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-payout-tool-details/shop-payout-tool-details.component.ts index e9196e79..c793755f 100644 --- a/src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-payout-tool-details/shop-payout-tool-details.component.ts +++ b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/components/shop-payout-tool-details/shop-payout-tool-details.component.ts @@ -1,7 +1,7 @@ import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; -import { PayoutToolParams } from './payout-tool-params'; -import { ShopPayoutToolDetailsService } from './shop-payout-tool-details.service'; +import { ShopPayoutToolDetailsService } from '../../services/shop-payout-tool-details/shop-payout-tool-details.service'; +import { PayoutToolParams } from '../../types/payout-tool-params'; @Component({ selector: 'dsh-shop-payout-tool-details', diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/index.ts b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/index.ts new file mode 100644 index 00000000..7f8373a5 --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/index.ts @@ -0,0 +1,2 @@ +export * from './shop-details.component'; +export * from './shop-details.module'; diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/services/category/category.service.spec.ts b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/services/category/category.service.spec.ts new file mode 100644 index 00000000..496428cc --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/services/category/category.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { CategoryService } from './category.service'; + +describe('CategoryService', () => { + let service: CategoryService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(CategoryService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/services/category/category.service.ts b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/services/category/category.service.ts new file mode 100644 index 00000000..d3e8a4c6 --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/services/category/category.service.ts @@ -0,0 +1,27 @@ +import { Injectable } from '@angular/core'; +import { combineLatest, Observable, Subject } from 'rxjs'; +import { map, shareReplay } from 'rxjs/operators'; + +import { Category } from '../../../../../../../../api-codegen/capi/swagger-codegen'; +import { CategoriesService } from '../../../../../../../../api/categories'; +import { SHARE_REPLAY_CONF } from '../../../../../../../../custom-operators'; + +@Injectable() +export class CategoryService { + category$: Observable; + + private categoryID$ = new Subject(); + + constructor(private categoriesService: CategoriesService) { + this.category$ = combineLatest([this.categoryID$, this.categoriesService.categories$]).pipe( + map(([categoryID, categories]: [number, Category[]]) => + categories.find((c) => c.categoryID === categoryID) + ), + shareReplay(SHARE_REPLAY_CONF) + ); + } + + updateID(categoryID: number): void { + this.categoryID$.next(categoryID); + } +} diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/services/shop-actions/is-successful-shop-action.ts b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/services/shop-actions/is-successful-shop-action.ts new file mode 100644 index 00000000..70143c54 --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/services/shop-actions/is-successful-shop-action.ts @@ -0,0 +1,5 @@ +import { ShopActionResult } from '../../types/shop-action-result'; + +export function isSuccessfulShopAction(action: ShopActionResult): boolean { + return action === ShopActionResult.SUCCESS; +} diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/services/shop-actions/shop-actions.service.spec.ts b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/services/shop-actions/shop-actions.service.spec.ts new file mode 100644 index 00000000..b3fc2aa1 --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/services/shop-actions/shop-actions.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { ShopActionsService } from './shop-actions.service'; + +describe('ShopActionsService', () => { + let service: ShopActionsService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(ShopActionsService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/services/shop-actions/shop-actions.service.ts b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/services/shop-actions/shop-actions.service.ts new file mode 100644 index 00000000..5eb82066 --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/services/shop-actions/shop-actions.service.ts @@ -0,0 +1,61 @@ +import { Injectable } from '@angular/core'; +import { MatDialog } from '@angular/material/dialog'; +import { MatSnackBar } from '@angular/material/snack-bar'; +import { TranslocoService } from '@ngneat/transloco'; +import { Observable, of } from 'rxjs'; +import { catchError, filter, map, switchMap } from 'rxjs/operators'; + +import { ConfirmActionDialogComponent } from '@dsh/components/popups'; + +import { ApiShopsService } from '../../../../../../../../api/shop'; +import { ShopActionResult } from '../../types/shop-action-result'; + +@Injectable() +export class ShopActionsService { + constructor( + private shopService: ApiShopsService, + private dialog: MatDialog, + private snackBar: MatSnackBar, + private transloco: TranslocoService + ) {} + + suspend(shopID: string): Observable { + return this.dialog + .open(ConfirmActionDialogComponent) + .afterClosed() + .pipe( + filter((r) => r === 'confirm'), + switchMap(() => this.shopService.suspendShop(shopID)), + map(() => { + this.snackBar.open(this.transloco.translate('suspend.success', null, 'shops'), 'OK', { + duration: 3000, + }); + return ShopActionResult.SUCCESS; + }), + catchError(() => { + this.snackBar.open(this.transloco.translate('suspend.error', null, 'shops'), 'OK'); + return of(ShopActionResult.ERROR); + }) + ); + } + + activate(shopID: string): Observable { + return this.dialog + .open(ConfirmActionDialogComponent) + .afterClosed() + .pipe( + filter((r) => r === 'confirm'), + switchMap(() => this.shopService.activateShop(shopID)), + map(() => { + this.snackBar.open(this.transloco.translate('activate.success', null, 'shops'), 'OK', { + duration: 3000, + }); + return ShopActionResult.SUCCESS; + }), + catchError(() => { + this.snackBar.open(this.transloco.translate('activate.error', null, 'shops'), 'OK'); + return of(ShopActionResult.ERROR); + }) + ); + } +} diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/services/shop-contract-details/shop-contract-details.service.spec.ts b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/services/shop-contract-details/shop-contract-details.service.spec.ts new file mode 100644 index 00000000..2ad5cca1 --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/services/shop-contract-details/shop-contract-details.service.spec.ts @@ -0,0 +1 @@ +// TODO: add unit tests diff --git a/src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-contract-details/shop-contract-details.service.ts b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/services/shop-contract-details/shop-contract-details.service.ts similarity index 90% rename from src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-contract-details/shop-contract-details.service.ts rename to src/app/sections/payment-section/integrations/shops/shops-list/shop-details/services/shop-contract-details/shop-contract-details.service.ts index db7e0cbd..3d39d3a4 100644 --- a/src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-contract-details/shop-contract-details.service.ts +++ b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/services/shop-contract-details/shop-contract-details.service.ts @@ -2,8 +2,8 @@ import { Injectable } from '@angular/core'; import { BehaviorSubject, Observable, of, Subject } from 'rxjs'; import { catchError, distinctUntilChanged, filter, switchMap, tap } from 'rxjs/operators'; -import { Contract } from '../../../../../../api-codegen/capi'; -import { ContractsService } from '../../../../../../api/contracts'; +import { Contract } from '../../../../../../../../api-codegen/capi'; +import { ContractsService } from '../../../../../../../../api/contracts'; @Injectable() export class ShopContractDetailsService { diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/services/shop-payout-tool-details/shop-payout-tool-details.service.spec.ts b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/services/shop-payout-tool-details/shop-payout-tool-details.service.spec.ts new file mode 100644 index 00000000..2ad5cca1 --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/services/shop-payout-tool-details/shop-payout-tool-details.service.spec.ts @@ -0,0 +1 @@ +// TODO: add unit tests diff --git a/src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-payout-tool-details/shop-payout-tool-details.service.ts b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/services/shop-payout-tool-details/shop-payout-tool-details.service.ts similarity index 88% rename from src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-payout-tool-details/shop-payout-tool-details.service.ts rename to src/app/sections/payment-section/integrations/shops/shops-list/shop-details/services/shop-payout-tool-details/shop-payout-tool-details.service.ts index acbac0f5..3aad2198 100644 --- a/src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-payout-tool-details/shop-payout-tool-details.service.ts +++ b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/services/shop-payout-tool-details/shop-payout-tool-details.service.ts @@ -2,9 +2,9 @@ import { Injectable } from '@angular/core'; import { BehaviorSubject, Observable, of, Subject } from 'rxjs'; import { catchError, distinctUntilChanged, filter, switchMap, tap } from 'rxjs/operators'; -import { PayoutsService } from '../../../../../../api'; -import { PayoutTool } from '../../../../../../api-codegen/capi'; -import { PayoutToolParams } from './payout-tool-params'; +import { PayoutsService } from '../../../../../../../../api'; +import { PayoutTool } from '../../../../../../../../api-codegen/capi'; +import { PayoutToolParams } from '../../types/payout-tool-params'; @Injectable() export class ShopPayoutToolDetailsService { diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/shop-details.component.html b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/shop-details.component.html new file mode 100644 index 00000000..96a098e1 --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/shop-details.component.html @@ -0,0 +1,15 @@ +
+ + + + + + + + + + + +
diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/shop-details.component.spec.ts b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/shop-details.component.spec.ts new file mode 100644 index 00000000..9325977d --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/shop-details.component.spec.ts @@ -0,0 +1,24 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ShopDetailsComponent } from './shop-details.component'; + +describe('ShopDetailsComponent', () => { + let component: ShopDetailsComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ShopDetailsComponent], + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ShopDetailsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/shop-details.component.ts b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/shop-details.component.ts new file mode 100644 index 00000000..c0d9a559 --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/shop-details.component.ts @@ -0,0 +1,18 @@ +import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core'; + +import { ShopItem } from '../../types/shop-item'; + +@Component({ + selector: 'dsh-shop-details', + templateUrl: 'shop-details.component.html', + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class ShopDetailsComponent { + @Input() shop: ShopItem; + + @Output() updateData = new EventEmitter(); + + requestUpdateData(): void { + this.updateData.emit(); + } +} diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/shop-details.module.ts b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/shop-details.module.ts new file mode 100644 index 00000000..daa1a69b --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/shop-details.module.ts @@ -0,0 +1,49 @@ +import { ClipboardModule } from '@angular/cdk/clipboard'; +import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; +import { FlexLayoutModule } from '@angular/flex-layout'; +import { MatDividerModule } from '@angular/material/divider'; +import { TranslocoModule } from '@ngneat/transloco'; + +import { ContractDetailsModule, PayoutToolModule } from '@dsh/app/shared/components'; +import { ButtonModule } from '@dsh/components/buttons'; +import { DetailsItemModule } from '@dsh/components/layout'; + +import { CategoriesModule } from '../../../../../../api/categories'; +import { ContractsModule } from '../../../../../../api/contracts'; +import { ShopBalanceModule } from '../shop-balance'; +import { ShopActionsComponent } from './components/shop-actions/shop-actions.component'; +import { ShopContractDetailsComponent } from './components/shop-contract-details/shop-contract-details.component'; +import { ShopIdComponent } from './components/shop-id/shop-id.component'; +import { ShopInfoComponent } from './components/shop-info/shop-info.component'; +import { ShopPayoutToolDetailsComponent } from './components/shop-payout-tool-details/shop-payout-tool-details.component'; +import { CategoryService } from './services/category/category.service'; +import { ShopDetailsComponent } from './shop-details.component'; + +@NgModule({ + imports: [ + CommonModule, + FlexLayoutModule, + ButtonModule, + TranslocoModule, + MatDividerModule, + DetailsItemModule, + ClipboardModule, + ContractDetailsModule, + PayoutToolModule, + ShopBalanceModule, + CategoriesModule, + ContractsModule, + ], + declarations: [ + ShopDetailsComponent, + ShopContractDetailsComponent, + ShopPayoutToolDetailsComponent, + ShopActionsComponent, + ShopIdComponent, + ShopInfoComponent, + ], + exports: [ShopDetailsComponent], + providers: [CategoryService], +}) +export class ShopDetailsModule {} diff --git a/src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-payout-tool-details/payout-tool-params.ts b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/types/payout-tool-params.ts similarity index 100% rename from src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-payout-tool-details/payout-tool-params.ts rename to src/app/sections/payment-section/integrations/shops/shops-list/shop-details/types/payout-tool-params.ts diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/types/shop-action-result.ts b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/types/shop-action-result.ts new file mode 100644 index 00000000..36280a74 --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/shop-details/types/shop-action-result.ts @@ -0,0 +1,4 @@ +export enum ShopActionResult { + SUCCESS = 'success', + ERROR = 'error', +} diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/shop-list.module.ts b/src/app/sections/payment-section/integrations/shops/shops-list/shop-list.module.ts new file mode 100644 index 00000000..91f33014 --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/shop-list.module.ts @@ -0,0 +1,39 @@ +import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; +import { FlexLayoutModule } from '@angular/flex-layout'; +import { TranslocoModule } from '@ngneat/transloco'; + +import { EmptySearchResultModule } from '@dsh/components/empty-search-result'; +import { SpinnerModule } from '@dsh/components/indicators'; +import { LastUpdatedModule } from '@dsh/components/indicators/last-updated/last-updated.module'; +import { AccordionModule, CardModule, ExpandPanelModule, RowModule } from '@dsh/components/layout'; +import { ShowMorePanelModule } from '@dsh/components/show-more-panel'; + +import { ToMajorModule } from '../../../../../to-major'; +import { ShopRowHeaderComponent } from './components/shop-row-header/shop-row-header.component'; +import { ShopRowComponent } from './components/shop-row/shop-row.component'; +import { ShopBalanceModule } from './shop-balance'; +import { ShopDetailsModule } from './shop-details'; +import { ShopsListComponent } from './shops-list.component'; + +@NgModule({ + imports: [ + CommonModule, + LastUpdatedModule, + AccordionModule, + CardModule, + RowModule, + ToMajorModule, + ShowMorePanelModule, + EmptySearchResultModule, + SpinnerModule, + ShopDetailsModule, + FlexLayoutModule, + TranslocoModule, + ShopBalanceModule, + ExpandPanelModule, + ], + declarations: [ShopsListComponent, ShopRowHeaderComponent, ShopRowComponent], + exports: [ShopsListComponent], +}) +export class ShopListModule {} diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/shops-list.component.html b/src/app/sections/payment-section/integrations/shops/shops-list/shops-list.component.html new file mode 100644 index 00000000..2a33871a --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/shops-list.component.html @@ -0,0 +1,36 @@ +
+ + + +
+ +
+
+
+ + + + + + + + {{ s('panel.details') }} + + + + + + +
+ {{ t('emptySearchResult') }} +
+
diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/shops-list.component.spec.ts b/src/app/sections/payment-section/integrations/shops/shops-list/shops-list.component.spec.ts new file mode 100644 index 00000000..f168b817 --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/shops-list.component.spec.ts @@ -0,0 +1,24 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ShopsListComponent } from './shops-list.component'; + +describe('ShopsListComponent', () => { + let component: ShopsListComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ShopsListComponent], + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ShopsListComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/sections/payment-section/integrations/shops/shops-list/shops-list.component.ts b/src/app/sections/payment-section/integrations/shops/shops-list/shops-list.component.ts new file mode 100644 index 00000000..d70093d7 --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops-list/shops-list.component.ts @@ -0,0 +1,46 @@ +import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core'; +import isNil from 'lodash.isnil'; +import { Observable } from 'rxjs'; + +import { ShopItem } from '../types/shop-item'; +import { ShopsExpandedIdManagerService } from './services/shops-expanded-id-manager/shops-expanded-id-manager.service'; + +@Component({ + selector: 'dsh-shops-list', + templateUrl: 'shops-list.component.html', + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class ShopsListComponent { + @Input() shopList: ShopItem[]; + + @Input() lastUpdated: string; + @Input() isLoading: boolean; + @Input() hasMore: boolean; + + @Output() refresh = new EventEmitter(); + @Output() showMore = new EventEmitter(); + + expandedId$: Observable = this.expandedIdManager.expandedId$; + + constructor(private expandedIdManager: ShopsExpandedIdManagerService) {} + + get isListExist(): boolean { + return !isNil(this.shopList); + } + + get isEmptyList(): boolean { + return this.isListExist && this.shopList.length === 0; + } + + refreshList(): void { + this.refresh.emit(); + } + + showMoreElements(): void { + this.showMore.emit(); + } + + expandedIdChange(id: number) { + this.expandedIdManager.expandedIdChange(id); + } +} diff --git a/src/app/sections/payment-section/integrations/shops/shops-panels-list/category.pipe.ts b/src/app/sections/payment-section/integrations/shops/shops-panels-list/category.pipe.ts deleted file mode 100644 index 8c7388c3..00000000 --- a/src/app/sections/payment-section/integrations/shops/shops-panels-list/category.pipe.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { ChangeDetectorRef, OnDestroy, Pipe, PipeTransform } from '@angular/core'; -import { combineLatest, Subject } from 'rxjs'; -import { map } from 'rxjs/operators'; - -import { CategoriesService } from '../../../../../api'; -import { Category } from '../../../../../api-codegen/capi'; - -@Pipe({ name: 'category', pure: false }) -export class CategoryPipe implements PipeTransform, OnDestroy { - private categoryID$ = new Subject(); - private subscription = combineLatest([this.categoryID$, this.categoriesService.categories$]) - .pipe(map(([categoryID, categories]) => categories.find((c) => c.categoryID === categoryID))) - .subscribe((category) => this.updateValue(category)); - private latestValue: Category; - - constructor(private categoriesService: CategoriesService, private ref: ChangeDetectorRef) {} - - ngOnDestroy() { - this.subscription.unsubscribe(); - } - - transform(categoryID: number): Category { - this.categoryID$.next(categoryID); - return this.latestValue; - } - - private updateValue(category: Category) { - this.latestValue = category; - this.ref.markForCheck(); - } -} diff --git a/src/app/sections/payment-section/integrations/shops/shops-panels-list/index.ts b/src/app/sections/payment-section/integrations/shops/shops-panels-list/index.ts deleted file mode 100644 index 8cf58521..00000000 --- a/src/app/sections/payment-section/integrations/shops/shops-panels-list/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './shops-panels-list.module'; -export * from './shops-panels-list.component'; diff --git a/src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-balance/index.ts b/src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-balance/index.ts deleted file mode 100644 index e10dfa8e..00000000 --- a/src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-balance/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './shop-balance.component'; diff --git a/src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-balance/shop-balance.component.html b/src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-balance/shop-balance.component.html deleted file mode 100644 index 01570c7b..00000000 --- a/src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-balance/shop-balance.component.html +++ /dev/null @@ -1,4 +0,0 @@ - - {{ b.amount | toMajor | currency: b.currency:'symbol' }} - ---/-- diff --git a/src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-balance/shop-balance.component.ts b/src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-balance/shop-balance.component.ts deleted file mode 100644 index 5b92390e..00000000 --- a/src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-balance/shop-balance.component.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { ChangeDetectionStrategy, Component, Input, OnDestroy } from '@angular/core'; - -import { ShopBalanceService } from './shop-balance.service'; - -@Component({ - selector: 'dsh-shop-balance', - templateUrl: 'shop-balance.component.html', - changeDetection: ChangeDetectionStrategy.OnPush, - providers: [ShopBalanceService], -}) -export class ShopBalanceComponent implements OnDestroy { - @Input() set shopID(shopID: string) { - this.shopBalanceService.setShopId(shopID); - } - - balance$ = this.shopBalanceService.balance$; - - constructor(private shopBalanceService: ShopBalanceService) {} - - ngOnDestroy() { - this.shopBalanceService.destroy(); - } -} diff --git a/src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-balance/shop-balance.service.ts b/src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-balance/shop-balance.service.ts deleted file mode 100644 index 70efa08a..00000000 --- a/src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-balance/shop-balance.service.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { Injectable } from '@angular/core'; -import { BehaviorSubject, Observable, of, Subject } from 'rxjs'; -import { catchError, distinctUntilChanged, pluck, shareReplay, switchMap, takeUntil } from 'rxjs/operators'; - -import { AnalyticsService } from '../../../../../../api'; -import { AmountResult } from '../../../../../../api-codegen/anapi'; - -@Injectable() -export class ShopBalanceService { - private shopIDChange$: Subject = new BehaviorSubject(null); - private destroy$: Subject = new Subject(); - - balance$: Observable = this.shopIDChange$.pipe( - distinctUntilChanged(), - switchMap((shopID) => - this.analyticsService.getCurrentBalances({ shopIDs: [shopID] }).pipe( - catchError((ex) => { - console.error(ex); - return of({ result: [] }); - }) - ) - ), - pluck('result', 0), - takeUntil(this.destroy$), - shareReplay(1) - ); - - constructor(private analyticsService: AnalyticsService) {} - - setShopId(shopID: string) { - this.shopIDChange$.next(shopID); - } - - destroy() { - this.destroy$.next(); - } -} diff --git a/src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-contract-details/index.ts b/src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-contract-details/index.ts deleted file mode 100644 index eae1b07c..00000000 --- a/src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-contract-details/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './shop-contract-details.component'; diff --git a/src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-payout-tool-details/index.ts b/src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-payout-tool-details/index.ts deleted file mode 100644 index fa96c404..00000000 --- a/src/app/sections/payment-section/integrations/shops/shops-panels-list/shop-payout-tool-details/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './shop-payout-tool-details.component'; -export * from './payout-tool-params'; diff --git a/src/app/sections/payment-section/integrations/shops/shops-panels-list/shops-panels-list.component.html b/src/app/sections/payment-section/integrations/shops/shops-panels-list/shops-panels-list.component.html deleted file mode 100644 index 61a4b47b..00000000 --- a/src/app/sections/payment-section/integrations/shops/shops-panels-list/shops-panels-list.component.html +++ /dev/null @@ -1,89 +0,0 @@ - - -
-
-
{{ shop?.details?.name }}
- -
-
-
{{ shop?.id }}
-
{{ shop?.isBlocked ? p('blocked') : shop?.isSuspended ? p('suspended') : p('active') }}
-
-
- - -
-
{{ p('details') }}
-
{{ shop?.isBlocked ? p('blocked') : shop?.isSuspended ? p('suspended') : p('active') }}
-
-
- - - - {{ shop?.details?.name }} - - - {{ shop?.location?.url }} - -
-
- - - -
-
- - {{ shop?.createdAt | date: 'd MMMM y, HH:mm:ss' }} - -
-
- - {{ (shop?.categoryID | category)?.name }} - -
-
- - -
{{ p('id') }}
-
{{ shop?.id }}
-
- -
- - - - - - - - -
{{ p('actions') }}
-
- - -
-
-
-
-
- -
diff --git a/src/app/sections/payment-section/integrations/shops/shops-panels-list/shops-panels-list.component.ts b/src/app/sections/payment-section/integrations/shops/shops-panels-list/shops-panels-list.component.ts deleted file mode 100644 index e33fc6e6..00000000 --- a/src/app/sections/payment-section/integrations/shops/shops-panels-list/shops-panels-list.component.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core'; -import { MatSnackBar } from '@angular/material/snack-bar'; -import { TranslocoService } from '@ngneat/transloco'; - -import { Shop } from '../../../../../api-codegen/capi'; -import { ShopsPanelsListService } from './shops-panels-list.service'; - -@Component({ - selector: 'dsh-shops-panels-list', - templateUrl: 'shops-panels-list.component.html', - providers: [ShopsPanelsListService], - changeDetection: ChangeDetectionStrategy.OnPush, -}) -export class ShopsPanelsListComponent { - @Input() set shops(shops: Shop[]) { - this.shopsPanelsListService.updateShops(shops); - } - - @Output() activateShop = new EventEmitter(); - @Output() suspendShop = new EventEmitter(); - - shops$ = this.shopsPanelsListService.shops$; - selectedPanelPosition$ = this.shopsPanelsListService.selectedPanelPosition$; - hasMore$ = this.shopsPanelsListService.hasMore$; - - constructor( - private shopsPanelsListService: ShopsPanelsListService, - private snackBar: MatSnackBar, - private transloco: TranslocoService - ) {} - - copied(isCopied: boolean) { - this.snackBar.open(this.transloco.translate(isCopied ? 'copied' : 'copyFailed'), 'OK', { duration: 1000 }); - } - - select(idx: number) { - this.shopsPanelsListService.select(idx); - } - - suspend(id: string) { - this.suspendShop.emit(id); - } - - activate(id: string) { - this.activateShop.emit(id); - } - - showMore() { - this.shopsPanelsListService.showMore(); - } -} diff --git a/src/app/sections/payment-section/integrations/shops/shops-panels-list/shops-panels-list.module.ts b/src/app/sections/payment-section/integrations/shops/shops-panels-list/shops-panels-list.module.ts deleted file mode 100644 index 815149c6..00000000 --- a/src/app/sections/payment-section/integrations/shops/shops-panels-list/shops-panels-list.module.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { ClipboardModule } from '@angular/cdk/clipboard'; -import { CommonModule } from '@angular/common'; -import { NgModule } from '@angular/core'; -import { FlexLayoutModule } from '@angular/flex-layout'; -import { MatDialogModule } from '@angular/material/dialog'; -import { MatDividerModule } from '@angular/material/divider'; -import { MatIconModule } from '@angular/material/icon'; -import { MatSnackBarModule } from '@angular/material/snack-bar'; -import { RouterModule } from '@angular/router'; -import { TranslocoModule } from '@ngneat/transloco'; - -import { ContractDetailsModule, PayoutToolModule } from '@dsh/app/shared/components'; -import { ButtonModule } from '@dsh/components/buttons'; -import { SpinnerModule } from '@dsh/components/indicators'; -import { LayoutModule } from '@dsh/components/layout'; -import { ConfirmActionDialogModule } from '@dsh/components/popups'; -import { ShowMorePanelModule } from '@dsh/components/show-more-panel'; - -import { CategoriesModule, ContractsModule, PayoutsModule } from '../../../../../api'; -import { ToMajorModule } from '../../../../../to-major'; -import { CategoryPipe } from './category.pipe'; -import { ShopBalanceComponent } from './shop-balance'; -import { ShopContractDetailsComponent } from './shop-contract-details'; -import { ShopPayoutToolDetailsComponent } from './shop-payout-tool-details'; -import { ShopsPanelsListComponent } from './shops-panels-list.component'; - -@NgModule({ - imports: [ - LayoutModule, - MatIconModule, - FlexLayoutModule, - CommonModule, - MatDividerModule, - ButtonModule, - TranslocoModule, - SpinnerModule, - RouterModule, - MatDialogModule, - MatSnackBarModule, - ClipboardModule, - ConfirmActionDialogModule, - CategoriesModule, - ShowMorePanelModule, - ToMajorModule, - ContractsModule, - PayoutsModule, - ContractDetailsModule, - PayoutToolModule, - ], - declarations: [ - ShopsPanelsListComponent, - CategoryPipe, - ShopBalanceComponent, - ShopContractDetailsComponent, - ShopPayoutToolDetailsComponent, - ], - exports: [ShopsPanelsListComponent], -}) -export class ShopsPanelsListModule {} diff --git a/src/app/sections/payment-section/integrations/shops/shops-panels-list/shops-panels-list.service.ts b/src/app/sections/payment-section/integrations/shops/shops-panels-list/shops-panels-list.service.ts deleted file mode 100644 index b6212ddc..00000000 --- a/src/app/sections/payment-section/integrations/shops/shops-panels-list/shops-panels-list.service.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { Injectable } from '@angular/core'; -import { ActivatedRoute, Router } from '@angular/router'; -import { combineLatest, merge, ReplaySubject, Subject } from 'rxjs'; -import { map, mapTo, pluck, scan, shareReplay, take } from 'rxjs/operators'; - -import { getOffsetBySelectedPanelPosition } from '../../../../../../utils'; -import { Shop } from '../../../../../api-codegen/capi'; -import { SHARE_REPLAY_CONF } from '../../../../../custom-operators'; - -const SHOPS_LIMIT = 5; - -@Injectable() -export class ShopsPanelsListService { - private allShops$ = new ReplaySubject(1); - private showMore$ = new Subject(); - - selectedPanelPosition$ = combineLatest([this.route.fragment.pipe(take(1)), this.allShops$]).pipe( - map(([fragment, shops]) => shops.findIndex(({ id }) => id === fragment)), - shareReplay(SHARE_REPLAY_CONF) - ); - - private offset$ = merge( - this.selectedPanelPosition$.pipe(map((idx) => getOffsetBySelectedPanelPosition(idx, SHOPS_LIMIT))), - this.showMore$.pipe(mapTo(SHOPS_LIMIT)) - ).pipe( - scan((offset, limit) => offset + limit, 0), - shareReplay(SHARE_REPLAY_CONF) - ); - - shops$ = combineLatest([this.allShops$, this.offset$]).pipe( - map(([shops, showedCount]) => shops.slice(0, showedCount)), - shareReplay(SHARE_REPLAY_CONF) - ); - - hasMore$ = combineLatest([this.allShops$.pipe(pluck('length')), this.offset$]).pipe( - map(([count, showedCount]) => count > showedCount), - shareReplay(SHARE_REPLAY_CONF) - ); - - constructor(private route: ActivatedRoute, private router: Router) {} - - select(idx: number) { - this.allShops$.pipe(pluck(idx, 'id')).subscribe((fragment) => { - this.router.navigate([], { fragment, queryParams: this.route.snapshot.queryParams }); - }); - } - - showMore() { - this.showMore$.next(); - } - - updateShops(shops: Shop[]) { - this.allShops$.next(shops); - } -} diff --git a/src/app/sections/payment-section/integrations/shops/shops.component.html b/src/app/sections/payment-section/integrations/shops/shops.component.html index b65c32ab..ea58c896 100644 --- a/src/app/sections/payment-section/integrations/shops/shops.component.html +++ b/src/app/sections/payment-section/integrations/shops/shops.component.html @@ -1,26 +1,16 @@ -
-
-
- {{ s('description') }} -
- +
+
- -
- -
-
- - -
- {{ t('emptySearchResult') }} -
-
+ +
diff --git a/src/app/sections/payment-section/integrations/shops/shops.component.spec.ts b/src/app/sections/payment-section/integrations/shops/shops.component.spec.ts new file mode 100644 index 00000000..2ad5cca1 --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/shops.component.spec.ts @@ -0,0 +1 @@ +// TODO: add unit tests diff --git a/src/app/sections/payment-section/integrations/shops/shops.component.ts b/src/app/sections/payment-section/integrations/shops/shops.component.ts index 5f7e3adf..e104a6b5 100644 --- a/src/app/sections/payment-section/integrations/shops/shops.component.ts +++ b/src/app/sections/payment-section/integrations/shops/shops.component.ts @@ -1,38 +1,59 @@ -import { ChangeDetectionStrategy, Component, Inject } from '@angular/core'; +import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; import { MatDialog } from '@angular/material/dialog'; import { ActivatedRoute } from '@angular/router'; +import { pluck, take } from 'rxjs/operators'; -import { booleanDebounceTime } from '../../../../custom-operators'; -import { LAYOUT_GAP } from '../../../constants'; -import { CreateShopDialogComponent } from './create-shop-dialog'; -import { ShopsService } from './shops.service'; +import { PaymentInstitutionRealm } from '../../../../api/model'; +import { CreateShopDialogComponent } from './components/create-shop-dialog/create-shop-dialog.component'; +import { FetchShopsService } from './services/fetch-shops/fetch-shops.service'; +import { ShopsBalanceService } from './services/shops-balance/shops-balance.service'; +import { ShopsExpandedIdManagerService } from './shops-list/services/shops-expanded-id-manager/shops-expanded-id-manager.service'; @Component({ selector: 'dsh-shops', templateUrl: 'shops.component.html', + styles: [ + ` + :host { + display: block; + width: 100%; + } + `, + ], changeDetection: ChangeDetectionStrategy.OnPush, - providers: [ShopsService], + providers: [FetchShopsService, ShopsBalanceService, ShopsExpandedIdManagerService], }) -export class ShopsComponent { - shops$ = this.shopsService.shops$; - isLoading$ = this.shopsService.isLoading$.pipe(booleanDebounceTime()); +export class ShopsComponent implements OnInit { + shops$ = this.shopsService.loadedShops$; + isLoading$ = this.shopsService.isLoading$; + lastUpdated$ = this.shopsService.lastUpdated$; + hasMore$ = this.shopsService.hasMore$; constructor( - @Inject(LAYOUT_GAP) public layoutGap: string, - private shopsService: ShopsService, + private shopsService: FetchShopsService, + private expandedIdManager: ShopsExpandedIdManagerService, private dialog: MatDialog, private route: ActivatedRoute ) {} - activate(id: string) { - this.shopsService.activate(id); + ngOnInit(): void { + this.route.params.pipe(take(1), pluck('realm')).subscribe((realm: PaymentInstitutionRealm) => { + this.shopsService.initRealm(realm); + }); + this.expandedIdManager.expandedId$.pipe(take(1)).subscribe((offsetIndex: number) => { + this.shopsService.initOffsetIndex(offsetIndex); + }); } - suspend(id: string) { - this.shopsService.suspend(id); + refreshData(): void { + this.shopsService.refreshData(); } - createShop() { + showMore(): void { + this.shopsService.showMore(); + } + + createShop(): void { this.dialog .open(CreateShopDialogComponent, { width: '552px', @@ -43,6 +64,7 @@ export class ShopsComponent { }, }) .afterClosed() + .pipe(take(1)) .subscribe(); } } diff --git a/src/app/sections/payment-section/integrations/shops/shops.module.ts b/src/app/sections/payment-section/integrations/shops/shops.module.ts index 62d4639d..72688117 100644 --- a/src/app/sections/payment-section/integrations/shops/shops.module.ts +++ b/src/app/sections/payment-section/integrations/shops/shops.module.ts @@ -1,18 +1,15 @@ import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; import { FlexLayoutModule } from '@angular/flex-layout'; -import { MatDividerModule } from '@angular/material/divider'; import { MatRadioModule } from '@angular/material/radio'; import { RouterModule } from '@angular/router'; import { TranslocoModule } from '@ngneat/transloco'; import { ButtonModule } from '@dsh/components/buttons'; -import { EmptySearchResultModule } from '@dsh/components/empty-search-result'; -import { SpinnerModule } from '@dsh/components/indicators'; import { CreateShopModule } from '../../../create-shop'; -import { CreateShopDialogComponent } from './create-shop-dialog'; -import { ShopsPanelsListModule } from './shops-panels-list'; +import { CreateShopDialogComponent } from './components/create-shop-dialog/create-shop-dialog.component'; +import { ShopListModule } from './shops-list/shop-list.module'; import { ShopsRoutingModule } from './shops-routing.module'; import { ShopsComponent } from './shops.component'; @@ -21,15 +18,12 @@ import { ShopsComponent } from './shops.component'; ShopsRoutingModule, FlexLayoutModule, TranslocoModule, - ShopsPanelsListModule, CommonModule, - SpinnerModule, - EmptySearchResultModule, - MatDividerModule, ButtonModule, CreateShopModule, RouterModule, MatRadioModule, + ShopListModule, ], declarations: [ShopsComponent, CreateShopDialogComponent], exports: [ShopsComponent], diff --git a/src/app/sections/payment-section/integrations/shops/shops.service.ts b/src/app/sections/payment-section/integrations/shops/shops.service.ts deleted file mode 100644 index 56cc9c23..00000000 --- a/src/app/sections/payment-section/integrations/shops/shops.service.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { Injectable } from '@angular/core'; -import { MatDialog } from '@angular/material/dialog'; -import { MatSnackBar } from '@angular/material/snack-bar'; -import { ActivatedRoute } from '@angular/router'; -import { TranslocoService } from '@ngneat/transloco'; -import { filter, pluck, shareReplay, switchMap } from 'rxjs/operators'; - -import { ConfirmActionDialogComponent } from '@dsh/components/popups'; - -import { ShopService } from '../../../../api'; -import { progress, SHARE_REPLAY_CONF } from '../../../../custom-operators'; -import { filterShopsByRealm } from '../../operations/operators'; - -@Injectable() -export class ShopsService { - shops$ = this.route.params.pipe( - pluck('realm'), - filterShopsByRealm(this.shopService.shops$), - shareReplay(SHARE_REPLAY_CONF) - ); - - isLoading$ = progress(this.route.params, this.shops$).pipe(shareReplay(SHARE_REPLAY_CONF)); - - constructor( - private route: ActivatedRoute, - private shopService: ShopService, - private dialog: MatDialog, - private snackBar: MatSnackBar, - private transloco: TranslocoService - ) {} - - suspend(id: string) { - this.dialog - .open(ConfirmActionDialogComponent) - .afterClosed() - .pipe( - filter((r) => r === 'confirm'), - switchMap(() => this.shopService.suspendShop(id)) - ) - .subscribe( - () => { - this.snackBar.open(this.transloco.translate('suspend.success', null, 'shops'), 'OK', { - duration: 3000, - }); - this.shopService.reloadShops(); - }, - () => this.snackBar.open(this.transloco.translate('suspend.error', null, 'shops'), 'OK') - ); - } - - activate(id: string) { - this.dialog - .open(ConfirmActionDialogComponent) - .afterClosed() - .pipe( - filter((r) => r === 'confirm'), - switchMap(() => this.shopService.activateShop(id)) - ) - .subscribe( - () => { - this.snackBar.open(this.transloco.translate('activate.success', null, 'shops'), 'OK', { - duration: 3000, - }); - this.shopService.reloadShops(); - }, - () => this.snackBar.open(this.transloco.translate('activate.error', null, 'shops'), 'OK') - ); - } -} diff --git a/src/app/sections/payment-section/integrations/shops/types/shop-balance.ts b/src/app/sections/payment-section/integrations/shops/types/shop-balance.ts new file mode 100644 index 00000000..b027f0f0 --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/types/shop-balance.ts @@ -0,0 +1,6 @@ +import { AmountResult } from '../../../../../api-codegen/anapi/swagger-codegen'; + +export interface ShopBalance { + id: string; + data: AmountResult | null; +} diff --git a/src/app/sections/payment-section/integrations/shops/types/shop-item.ts b/src/app/sections/payment-section/integrations/shops/types/shop-item.ts new file mode 100644 index 00000000..4c0815af --- /dev/null +++ b/src/app/sections/payment-section/integrations/shops/types/shop-item.ts @@ -0,0 +1,6 @@ +import { AmountResult, Shop as ApiShop, ShopLocationUrl } from '../../../../../api-codegen/anapi/swagger-codegen'; + +export interface ShopItem extends ApiShop { + balance: AmountResult; + location: ShopLocationUrl; +} diff --git a/src/app/sections/payment-section/integrations/webhooks/create-webhook/create-webhook-form/create-webhook-form.component.ts b/src/app/sections/payment-section/integrations/webhooks/create-webhook/create-webhook-form/create-webhook-form.component.ts index 2b43b42a..d951722d 100644 --- a/src/app/sections/payment-section/integrations/webhooks/create-webhook/create-webhook-form/create-webhook-form.component.ts +++ b/src/app/sections/payment-section/integrations/webhooks/create-webhook/create-webhook-form/create-webhook-form.component.ts @@ -4,7 +4,7 @@ import { BehaviorSubject } from 'rxjs'; import { oneMustBeSelected } from '@dsh/components/form-controls'; -import { ShopService } from '../../../../../../api'; +import { ApiShopsService } from '../../../../../../api'; import TopicEnum = WebhookScope.TopicEnum; import { WebhookScope } from '../../../../../../api-codegen/capi/swagger-codegen'; import { getEventsByTopic } from '../get-events-by-topic'; @@ -12,7 +12,7 @@ import { getEventsByTopic } from '../get-events-by-topic'; @Component({ selector: 'dsh-create-webhook-form', templateUrl: 'create-webhook-form.component.html', - providers: [ShopService], + providers: [ApiShopsService], }) export class CreateWebhookFormComponent implements OnInit { @Input() @@ -22,7 +22,7 @@ export class CreateWebhookFormComponent implements OnInit { activeTopic$ = new BehaviorSubject('InvoicesTopic'); - constructor(private shopService: ShopService, private fb: FormBuilder) {} + constructor(private shopService: ApiShopsService, private fb: FormBuilder) {} ngOnInit() { this.activeTopic$.subscribe((activeTopic) => { diff --git a/src/app/sections/payment-section/integrations/webhooks/webhook-details/webhook-details.module.ts b/src/app/sections/payment-section/integrations/webhooks/webhook-details/webhook-details.module.ts index 8bddbec0..b42fb1ed 100644 --- a/src/app/sections/payment-section/integrations/webhooks/webhook-details/webhook-details.module.ts +++ b/src/app/sections/payment-section/integrations/webhooks/webhook-details/webhook-details.module.ts @@ -6,7 +6,7 @@ import { MatDividerModule } from '@angular/material/divider'; import { MatSnackBarModule } from '@angular/material/snack-bar'; import { TranslocoModule } from '@ngneat/transloco'; -import { WebhookApiKeyModule } from '@dsh/app/shared/*'; +import { WebhookApiKeyModule } from '@dsh/app/shared/components'; import { ApiModelRefsModule } from '@dsh/app/shared/pipes'; import { ButtonModule } from '@dsh/components/buttons'; import { IndicatorsModule } from '@dsh/components/indicators'; diff --git a/src/app/sections/payment-section/integrations/webhooks/webhook-list/webhook-list.module.ts b/src/app/sections/payment-section/integrations/webhooks/webhook-list/webhook-list.module.ts index 31854a8b..5b633a3b 100644 --- a/src/app/sections/payment-section/integrations/webhooks/webhook-list/webhook-list.module.ts +++ b/src/app/sections/payment-section/integrations/webhooks/webhook-list/webhook-list.module.ts @@ -4,7 +4,7 @@ import { FlexLayoutModule } from '@angular/flex-layout'; import { MatSnackBarModule } from '@angular/material/snack-bar'; import { TranslocoModule } from '@ngneat/transloco'; -import { ApiModelRefsModule } from '@dsh/app/shared/*'; +import { ApiModelRefsModule } from '@dsh/app/shared/pipes'; import { IndicatorsModule } from '@dsh/components/indicators'; import { LayoutModule } from '@dsh/components/layout'; diff --git a/src/app/sections/payment-section/operations/invoices/invoices.service.ts b/src/app/sections/payment-section/operations/invoices/invoices.service.ts index 1706f3cd..5b127386 100644 --- a/src/app/sections/payment-section/operations/invoices/invoices.service.ts +++ b/src/app/sections/payment-section/operations/invoices/invoices.service.ts @@ -8,7 +8,7 @@ import { catchError, pluck, shareReplay, switchMap } from 'rxjs/operators'; import { InvoiceSearchService } from '../../../../api'; import { Invoice } from '../../../../api-codegen/anapi'; import { Shop } from '../../../../api-codegen/capi'; -import { ShopService } from '../../../../api/shop'; +import { ApiShopsService } from '../../../../api/shop'; import { SHARE_REPLAY_CONF } from '../../../../custom-operators'; import { FetchResult, PartialFetcher } from '../../../partial-fetcher'; import { filterShopsByRealm, mapToTimestamp } from '../operators'; @@ -42,7 +42,7 @@ export class InvoicesService extends PartialFetcher this.router.navigate([location.pathname], { queryParams: toQueryParams(formValues) }) diff --git a/src/app/sections/payment-section/operations/refunds/refunds.service.ts b/src/app/sections/payment-section/operations/refunds/refunds.service.ts index 80891d54..16cf568e 100644 --- a/src/app/sections/payment-section/operations/refunds/refunds.service.ts +++ b/src/app/sections/payment-section/operations/refunds/refunds.service.ts @@ -7,7 +7,7 @@ import { catchError, pluck, switchMap } from 'rxjs/operators'; import { RefundSearchResult } from '../../../../api-codegen/capi'; import { RefundSearchService } from '../../../../api/search'; -import { ShopService } from '../../../../api/shop'; +import { ApiShopsService } from '../../../../api/shop'; import { FetchResult, PartialFetcher } from '../../../partial-fetcher'; import { mapToTimestamp } from '../operators'; import { mapToRefundsTableData } from './map-to-refunds-table-data'; @@ -35,7 +35,7 @@ export class RefundsService extends PartialFetcher this.searchParams$.next({ shopIDs })); diff --git a/src/app/sections/payment-section/payouts/payouts-search-filters/payouts-search-filters.module.ts b/src/app/sections/payment-section/payouts/payouts-search-filters/payouts-search-filters.module.ts index e39aa6d6..d5cc22a9 100644 --- a/src/app/sections/payment-section/payouts/payouts-search-filters/payouts-search-filters.module.ts +++ b/src/app/sections/payment-section/payouts/payouts-search-filters/payouts-search-filters.module.ts @@ -2,7 +2,7 @@ import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; import { FlexModule } from '@angular/flex-layout'; -import { FilterShopsModule } from '@dsh/app/shared/*'; +import { FilterShopsModule } from '@dsh/app/shared/components'; import { DaterangeFilterModule } from '@dsh/components/filters/daterange-filter'; import { PayoutsSearchFiltersComponent } from './payouts-search-filters.component'; diff --git a/src/app/sections/payment-section/reports/create-report/create-report-dialog.component.ts b/src/app/sections/payment-section/reports/create-report/create-report-dialog.component.ts index 3551ec29..f3043c5e 100644 --- a/src/app/sections/payment-section/reports/create-report/create-report-dialog.component.ts +++ b/src/app/sections/payment-section/reports/create-report/create-report-dialog.component.ts @@ -6,7 +6,7 @@ import { TranslocoService } from '@ngneat/transloco'; import moment from 'moment'; import { of } from 'rxjs'; -import { ShopService } from '../../../../api'; +import { ApiShopsService } from '../../../../api'; import { filterShopsByRealm, mapToShopInfo } from '../../operations/operators'; import { CreateReportDialogService } from './create-report-dialog.service'; @@ -30,7 +30,7 @@ export class CreateReportDialogComponent implements OnInit { constructor( private dialogRef: MatDialogRef, - private shopService: ShopService, + private shopService: ApiShopsService, private fb: FormBuilder, private createReportDialogService: CreateReportDialogService, private transloco: TranslocoService, diff --git a/src/app/sections/shop-details/shop-details.component.ts b/src/app/sections/shop-details/shop-details.component.ts index f64ad7b3..b319892a 100644 --- a/src/app/sections/shop-details/shop-details.component.ts +++ b/src/app/sections/shop-details/shop-details.component.ts @@ -7,7 +7,7 @@ import { ShopDetailsService } from './shop-details.service'; @Component({ selector: 'dsh-shop-details', - templateUrl: './shop-details.component.html', + templateUrl: 'shop-details.component.html', }) export class ShopDetailsComponent implements OnInit { @Input() shopID: string; diff --git a/src/app/sections/shop-details/shop-details.service.ts b/src/app/sections/shop-details/shop-details.service.ts index 313f1d87..90153207 100644 --- a/src/app/sections/shop-details/shop-details.service.ts +++ b/src/app/sections/shop-details/shop-details.service.ts @@ -2,11 +2,11 @@ import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; import { Shop } from '../../api-codegen/capi/swagger-codegen'; -import { ShopService } from '../../api/shop'; +import { ApiShopsService } from '../../api/shop'; @Injectable() export class ShopDetailsService { - constructor(private shopService: ShopService) {} + constructor(private shopService: ApiShopsService) {} getShopByID(shopID: string): Observable { return this.shopService.getShopByID(shopID); diff --git a/src/app/sections/shop-details/shop-location-url/shop-location-url.component.ts b/src/app/sections/shop-details/shop-location-url/shop-location-url.component.ts index 083835fc..7dbc6342 100644 --- a/src/app/sections/shop-details/shop-location-url/shop-location-url.component.ts +++ b/src/app/sections/shop-details/shop-location-url/shop-location-url.component.ts @@ -4,7 +4,7 @@ import { ShopLocationUrl } from '../../../api-codegen/capi/swagger-codegen'; @Component({ selector: 'dsh-shop-location-url', - templateUrl: './shop-location-url.component.html', + templateUrl: 'shop-location-url.component.html', }) export class ShopLocationUrlComponent { @Input() shopLocationUrl: ShopLocationUrl; diff --git a/src/app/sections/shop-selector/shop-selector.component.ts b/src/app/sections/shop-selector/shop-selector.component.ts index d0c6c461..07f0ea2d 100644 --- a/src/app/sections/shop-selector/shop-selector.component.ts +++ b/src/app/sections/shop-selector/shop-selector.component.ts @@ -11,7 +11,7 @@ import { debounceTime, map, pluck, shareReplay, startWith, switchMap } from 'rxj import { CustomFormControl } from '@dsh/components/form-controls/utils'; import { PaymentInstitutionRealm } from '../../api'; -import { ShopService } from '../../api/shop'; +import { ApiShopsService } from '../../api/shop'; import { SHARE_REPLAY_CONF } from '../../custom-operators'; import { filterShopsByRealm, mapToShopInfo, ShopInfo } from '../payment-section/operations/operators'; import { filterByNameAndId } from './filter-shop-infos-by-name-and-id'; @@ -55,7 +55,7 @@ export class ShopSelectorComponent extends CustomFormControl implements OnChange @Optional() parentForm: NgForm, @Optional() parentFormGroup: FormGroupDirective, private route: ActivatedRoute, - private shopService: ShopService + private shopService: ApiShopsService ) { super( focusMonitor, diff --git a/src/app/sections/wallet-details/account-info/account-info.component.ts b/src/app/sections/wallet-details/account-info/account-info.component.ts index 64daf6f6..a280f1c6 100644 --- a/src/app/sections/wallet-details/account-info/account-info.component.ts +++ b/src/app/sections/wallet-details/account-info/account-info.component.ts @@ -4,7 +4,7 @@ import { WalletAccount } from '../../../api-codegen/wallet-api/swagger-codegen'; @Component({ selector: 'dsh-account-info', - templateUrl: './account-info.component.html', + templateUrl: 'account-info.component.html', styleUrls: ['./account-info.component.scss'], }) export class AccountInfoComponent { diff --git a/src/app/sections/wallet-details/deposits/deposits.component.ts b/src/app/sections/wallet-details/deposits/deposits.component.ts index 0c7021c0..91f22ba1 100644 --- a/src/app/sections/wallet-details/deposits/deposits.component.ts +++ b/src/app/sections/wallet-details/deposits/deposits.component.ts @@ -6,7 +6,7 @@ import { DepositsService } from './deposits.service'; @Component({ selector: 'dsh-deposits', - templateUrl: './deposits.component.html', + templateUrl: 'deposits.component.html', styleUrls: ['./deposits.component.scss'], providers: [DepositsService], }) diff --git a/src/app/sections/wallet-details/wallet-details-headline/wallet-details-headline.component.ts b/src/app/sections/wallet-details/wallet-details-headline/wallet-details-headline.component.ts index e8a2804c..ccd4f2c5 100644 --- a/src/app/sections/wallet-details/wallet-details-headline/wallet-details-headline.component.ts +++ b/src/app/sections/wallet-details/wallet-details-headline/wallet-details-headline.component.ts @@ -2,7 +2,7 @@ import { Component, Input } from '@angular/core'; @Component({ selector: 'dsh-wallet-details-headline', - templateUrl: './wallet-details-headline.component.html', + templateUrl: 'wallet-details-headline.component.html', }) export class WalletDetailsHeadlineComponent { @Input() walletID: string; diff --git a/src/app/sections/wallet-details/withdrawals/withdrawals.component.ts b/src/app/sections/wallet-details/withdrawals/withdrawals.component.ts index 036fc17b..53fc5a7e 100644 --- a/src/app/sections/wallet-details/withdrawals/withdrawals.component.ts +++ b/src/app/sections/wallet-details/withdrawals/withdrawals.component.ts @@ -6,7 +6,7 @@ import { WithdrawalsService } from './withdrawals.service'; @Component({ selector: 'dsh-withdrawals', - templateUrl: './withdrawals.component.html', + templateUrl: 'withdrawals.component.html', styleUrls: ['./withdrawals.component.scss'], providers: [WithdrawalsService], }) diff --git a/src/app/sections/wallet-section/integrations/webhooks/webhook-details/webhook-details.module.ts b/src/app/sections/wallet-section/integrations/webhooks/webhook-details/webhook-details.module.ts index 8bddbec0..b42fb1ed 100644 --- a/src/app/sections/wallet-section/integrations/webhooks/webhook-details/webhook-details.module.ts +++ b/src/app/sections/wallet-section/integrations/webhooks/webhook-details/webhook-details.module.ts @@ -6,7 +6,7 @@ import { MatDividerModule } from '@angular/material/divider'; import { MatSnackBarModule } from '@angular/material/snack-bar'; import { TranslocoModule } from '@ngneat/transloco'; -import { WebhookApiKeyModule } from '@dsh/app/shared/*'; +import { WebhookApiKeyModule } from '@dsh/app/shared/components'; import { ApiModelRefsModule } from '@dsh/app/shared/pipes'; import { ButtonModule } from '@dsh/components/buttons'; import { IndicatorsModule } from '@dsh/components/indicators'; diff --git a/src/app/shared/pipes/api-model-refs/shop-details.pipe.ts b/src/app/shared/pipes/api-model-refs/shop-details.pipe.ts index c7b705ea..330418ce 100644 --- a/src/app/shared/pipes/api-model-refs/shop-details.pipe.ts +++ b/src/app/shared/pipes/api-model-refs/shop-details.pipe.ts @@ -2,7 +2,7 @@ import { ChangeDetectorRef, OnDestroy, Pipe, PipeTransform } from '@angular/core import { BehaviorSubject, combineLatest, Subject } from 'rxjs'; import { distinctUntilChanged, map, pluck, takeUntil } from 'rxjs/operators'; -import { ShopService } from '../../../api'; +import { ApiShopsService } from '../../../api'; @Pipe({ name: 'shopDetails', @@ -13,7 +13,7 @@ export class ShopDetailsPipe implements PipeTransform, OnDestroy { private shopIDChange$: Subject = new Subject(); private destroy$: Subject = new Subject(); - constructor(private shopService: ShopService, private ref: ChangeDetectorRef) { + constructor(private shopService: ApiShopsService, private ref: ChangeDetectorRef) { combineLatest([this.shopService.shops$, this.shopIDChange$.pipe(distinctUntilChanged())]) .pipe( takeUntil(this.destroy$), diff --git a/src/app/test-shop.service.ts b/src/app/test-shop.service.ts index 9115cec9..b2e660dc 100644 --- a/src/app/test-shop.service.ts +++ b/src/app/test-shop.service.ts @@ -4,7 +4,7 @@ import { TranslocoService } from '@ngneat/transloco'; import { Subject } from 'rxjs'; import { filter, first, switchMap, switchMapTo } from 'rxjs/operators'; -import { CAPIClaimsService, createTestShopClaimChangeset, ShopService } from './api'; +import { ApiShopsService, CAPIClaimsService, createTestShopClaimChangeset } from './api'; @Injectable() export class TestShopService { @@ -12,7 +12,7 @@ export class TestShopService { constructor( private capiClaimsService: CAPIClaimsService, - private shopService: ShopService, + private shopService: ApiShopsService, private snackBar: MatSnackBar, private transloco: TranslocoService ) { diff --git a/src/components/charts/bar-chart/bar-chart.component.ts b/src/components/charts/bar-chart/bar-chart.component.ts index 53f1e06a..5fe1ab13 100644 --- a/src/components/charts/bar-chart/bar-chart.component.ts +++ b/src/components/charts/bar-chart/bar-chart.component.ts @@ -6,7 +6,7 @@ import { DEFAULT_CONFIG } from './default-config'; @Component({ selector: 'dsh-bar-chart', - templateUrl: './bar-chart.component.html', + templateUrl: 'bar-chart.component.html', styleUrls: ['bar-chart.component.scss'], }) export class BarChartComponent implements OnChanges { diff --git a/src/components/charts/donut-chart/donut-chart.component.ts b/src/components/charts/donut-chart/donut-chart.component.ts index 53c987fd..d6b3b35e 100644 --- a/src/components/charts/donut-chart/donut-chart.component.ts +++ b/src/components/charts/donut-chart/donut-chart.component.ts @@ -6,7 +6,7 @@ import { DEFAULT_CONFIG } from './default-config'; @Component({ selector: 'dsh-donut-chart', - templateUrl: './donut-chart.component.html', + templateUrl: 'donut-chart.component.html', styleUrls: ['donut-chart.component.scss'], }) export class DonutChartComponent implements OnInit { diff --git a/src/components/filters/multi-value-filter/multi-value-filter.component.ts b/src/components/filters/multi-value-filter/multi-value-filter.component.ts index 627d3b56..c1f2191c 100644 --- a/src/components/filters/multi-value-filter/multi-value-filter.component.ts +++ b/src/components/filters/multi-value-filter/multi-value-filter.component.ts @@ -28,10 +28,10 @@ export class MultiValueFilterComponent implements OnChanges { private savedValue$ = new ReplaySubject(); form = new FormArray([]); - active$ = this.savedValue$.pipe(startWith(undefined), map(negate(isEmpty)), shareReplay(1)); + active$ = this.savedValue$.pipe(startWith(undefined), map(negate(isEmpty)), shareReplay(1)); label$ = this.savedValue$.pipe( - startWith(undefined), - map((v) => { + startWith(undefined), + map((v: string[]) => { if (isEmpty(v)) { return this.label; } diff --git a/src/components/filters/radio-group-filter/radio-group-filter.component.ts b/src/components/filters/radio-group-filter/radio-group-filter.component.ts index cf7bdee9..9f1a947b 100644 --- a/src/components/filters/radio-group-filter/radio-group-filter.component.ts +++ b/src/components/filters/radio-group-filter/radio-group-filter.component.ts @@ -54,7 +54,7 @@ export class RadioGroupFilterComponent implements OnInit, OnChanges, Af this.options$, ]).pipe( map(([selected]) => this.mapInputValueToOption(selected)), - startWith(null), + startWith, null>(null), shareReplay(1) ); diff --git a/src/components/filters/value-filter/value-filter.component.ts b/src/components/filters/value-filter/value-filter.component.ts index 17626fa9..c6438396 100644 --- a/src/components/filters/value-filter/value-filter.component.ts +++ b/src/components/filters/value-filter/value-filter.component.ts @@ -23,7 +23,7 @@ export class ValueFilterComponent implements OnChanges { control = new FormControl(); label$ = this.savedValue$.pipe( - startWith(undefined), + startWith(undefined), map((v) => { if (!v) { return this.label; diff --git a/src/type-utils/dict.ts b/src/type-utils/dict.ts new file mode 100644 index 00000000..5ec24031 --- /dev/null +++ b/src/type-utils/dict.ts @@ -0,0 +1,3 @@ +export interface Dict { + [key: string]: T; +} diff --git a/src/type-utils/index.ts b/src/type-utils/index.ts index 12024f13..2b651be0 100644 --- a/src/type-utils/index.ts +++ b/src/type-utils/index.ts @@ -2,3 +2,4 @@ export * from './replace'; export * from './mapping'; export * from './map-tuple'; export * from './component-changes'; +export * from './dict'; diff --git a/tsconfig.json b/tsconfig.json index ae599b42..d3bfc921 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -20,7 +20,7 @@ "paths": { "@dsh/components/*": ["src/components/*"], "@dsh/pipes/*": ["src/pipes/*"], - "@dsh/app/shared/*": ["src/app/shared"] + "@dsh/app/shared/*": ["src/app/shared/*"] } }, "angularCompilerOptions": { diff --git a/tslint.json b/tslint.json index c7c49c07..fc520eec 100644 --- a/tslint.json +++ b/tslint.json @@ -1,17 +1,31 @@ { "extends": ["./tslint.angular.json", "tslint-config-prettier"], "rules": { + "ban": [ + true, + "eval", + "debugger", + { + "name": "fdescribe", + "message": "Do not focus tests." + }, + { + "name": "fit", + "message": "Do not focus tests." + }, + { + "name": "xdescribe", + "message": "Do not exclude tests." + }, + { + "name": "xit", + "message": "Do not exclude tests." + } + ], "directive-selector": [true, ["attribute", "element"], "dsh", ["camelCase", "kebab-case"]], "component-selector": [true, ["attribute", "element"], "dsh", "kebab-case"], "template-no-negated-async": false, - "import-blacklist": [ - true, - "rxjs/Rx", - "lodash", - "lodash-es", - ".", - [".*\\./components/.*", ".*\\./pipes/.*", "src/.+"] - ], + "import-blacklist": [true, "rxjs/Rx", "lodash", "lodash-es", ".", [".*\\./pipes/.*", "src/.+"]], "no-unused-variable": [true, { "ignore-pattern": "^_" }], "variable-name": { "options": ["allow-leading-underscore", "ban-keywords", "check-format", "allow-pascal-case"]