From a1eb27bafd9df62704a0ea3e40991414ee207717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo=20Nunes=20Soares?= Date: Tue, 31 Aug 2021 15:36:28 -0300 Subject: [PATCH] US-GraficoTotalAudienciasPeriodo (#192) * #191 - Adding total rooms chart for default period * #191 - Adding functions to get data for year and month period * #191 - Adding tests * #191 - Adding background functions to filter data * #191 - Adding filter of data and changing chart * #191 - Improving user experience with feedback message * #191 - Refactoring code to follow stylesheet * #191 - Fixing warnings * #191 - Updating messages --- package-lock.json | 396 ++++++++++-------- package.json | 4 +- .../ChartTotalRoomsWithFilter/auxfunctions.js | 47 +++ .../ChartTotalRoomsWithFilter/index.js | 229 ++++++++++ src/components/index.js | 3 +- .../__test__/computeTotalRooms.test.js | 64 +++ .../auxFunctions/computeTotalRooms.js | 77 ++++ src/containers/Audiencias/index.js | 82 +++- .../Audiencias/settings/chartsSettings.js | 21 + src/pages/_document.js | 1 + src/pages/audiencias.js | 4 +- src/pages/wikilegis.js | 14 +- src/settings/texts/AudienciasPage/index.js | 7 + 13 files changed, 757 insertions(+), 192 deletions(-) create mode 100644 src/components/ChartTotalRoomsWithFilter/auxfunctions.js create mode 100644 src/components/ChartTotalRoomsWithFilter/index.js create mode 100644 src/containers/Audiencias/auxFunctions/__test__/computeTotalRooms.test.js create mode 100644 src/containers/Audiencias/auxFunctions/computeTotalRooms.js diff --git a/package-lock.json b/package-lock.json index 09e290c5..1031975e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1247,11 +1247,6 @@ "to-fast-properties": "^2.0.0" } }, - "@brainhubeu/react-carousel": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@brainhubeu/react-carousel/-/react-carousel-2.0.3.tgz", - "integrity": "sha512-wwcAdWx5K6pPpVC4oZmXZeazCxFItfyizQoG1DI1QjlC2ragMEhexFSNGjB61q0foqCM3Vxim+mKHdbbmw52AQ==" - }, "@cnakazawa/watch": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/@cnakazawa/watch/-/watch-1.0.4.tgz", @@ -4535,9 +4530,9 @@ } }, "css-what": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/css-what/-/css-what-5.0.0.tgz", - "integrity": "sha512-qxyKHQvgKwzwDWC/rGbT821eJalfupxYW2qbSJSAtdSTimsr/MlaGONoNLllaUPZWf8QnbcKM/kPVYUQuEKAFA==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/css-what/-/css-what-5.0.1.tgz", + "integrity": "sha512-FYDTSHb/7KXsWICVsxdmiExPjCfRC4qRFBdVwv7Ax9hMnvMmEjP9RfxTEZ3qPZGmADDn2vAKSo9UcN1jKVYscg==", "dev": true }, "dom-serializer": { @@ -5913,6 +5908,14 @@ "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=" }, + "deepcopy": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/deepcopy/-/deepcopy-2.1.0.tgz", + "integrity": "sha512-8cZeTb1ZKC3bdSCP6XOM1IsTczIO73fdqtwa2B0N15eAz7gmyhQo+mc5gnFuulsgN3vIQYmTgbmQVKalH1dKvQ==", + "requires": { + "type-detect": "^4.0.8" + } + }, "deepmerge": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.2.2.tgz", @@ -6150,9 +6153,9 @@ "integrity": "sha1-s55/HabrCnW6nBcySzR1PEfgZU0=" }, "dns-packet": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/dns-packet/-/dns-packet-1.3.1.tgz", - "integrity": "sha512-0UxfQkMhYAUaZI+xrNZOz/as5KgDU0M/fQ9b6SpkyLbk3GEswDi6PADJVaYJradtRVsRIlF1zLyOodbcTCDzUg==", + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/dns-packet/-/dns-packet-1.3.4.tgz", + "integrity": "sha512-BQ6F4vycLXBvdrJZ6S3gZewt6rcrks9KBgM9vrhW+knGRqc8uEdT7fuCwloc7nny5xNoMJ17HGH0R/6fpo8ECA==", "requires": { "ip": "^1.1.0", "safe-buffer": "^5.0.1" @@ -8659,11 +8662,6 @@ "resolved": "https://registry.npmjs.org/hyphenate-style-name/-/hyphenate-style-name-1.0.4.tgz", "integrity": "sha512-ygGZLjmXfPHj+ZWh6LwbC37l43MhfztxetbFCoYTM2VjkIUpeHgSNn7QIyVFj7YQ1Wl9Cbw5sholVJPzWvC2MQ==" }, - "i": { - "version": "0.3.6", - "resolved": "https://registry.npmjs.org/i/-/i-0.3.6.tgz", - "integrity": "sha1-2WyScyB28HJxG2sQ/X1PZa2O4j0=" - }, "iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -8733,6 +8731,11 @@ "resolved": "https://registry.npmjs.org/immer/-/immer-1.10.0.tgz", "integrity": "sha512-O3sR1/opvCDGLEVcvrGTMtLac8GJ5IwZC4puPrLuRj3l7ICKvkmA0vGuU9OW8mV9WIBRnaxp5GJh9IEAaNOoYg==" }, + "immutability-helper": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/immutability-helper/-/immutability-helper-3.1.1.tgz", + "integrity": "sha512-Q0QaXjPjwIju/28TsugCHNEASwoCcJSyJV3uO1sOIQGI0jKgm9f41Lvz0DZj3n46cNCyAZTsEYoY4C2bVRUzyQ==" + }, "immutable": { "version": "3.7.6", "resolved": "https://registry.npmjs.org/immutable/-/immutable-3.7.6.tgz", @@ -9586,9 +9589,9 @@ "integrity": "sha512-fxNG2sQjHvlVAYmzBZS9YlDp6PTSSDwa98vkD4QgVDDCAo84z5X1t5XyJQ62ImdLXx5NdIIfihey6xpum9/gRQ==" }, "ws": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz", - "integrity": "sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA==", + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.2.tgz", + "integrity": "sha512-zmhltoSR8u1cnDsD43TX59mzoMZsLKqUweyYBAIvTngR3shc0W6aOZylZmq/7hqyVxPdi+5Ud2QInblgyE72fw==", "requires": { "async-limiter": "~1.0.0" } @@ -11453,45 +11456,46 @@ } }, "npm": { - "version": "7.12.1", - "resolved": "https://registry.npmjs.org/npm/-/npm-7.12.1.tgz", - "integrity": "sha512-vjIniB3kqujcDTgH+k90J2i5PPqYZyf1gi5Ni5fARK4WQr5FuVnTQlTXloyk15+qWUxwWHcy6U8YCWwh/TLzmA==", + "version": "7.21.0", + "resolved": "https://registry.npmjs.org/npm/-/npm-7.21.0.tgz", + "integrity": "sha512-OYSQykXItCDXYGb9U8o85Snhmbe0k/nwVK6CmUNmgtOcfPevVB5ZXwA44eWOCvM+WdWYQsJAJoA7eCHKImQt8g==", "requires": { - "@npmcli/arborist": "^2.4.4", + "@npmcli/arborist": "^2.8.2", "@npmcli/ci-detect": "^1.2.0", "@npmcli/config": "^2.2.0", - "@npmcli/run-script": "^1.8.5", + "@npmcli/map-workspaces": "^1.0.4", + "@npmcli/package-json": "^1.0.1", + "@npmcli/run-script": "^1.8.6", "abbrev": "~1.1.1", "ansicolors": "~0.3.2", "ansistyles": "~0.1.3", "archy": "~1.0.0", - "byte-size": "^7.0.1", - "cacache": "^15.0.6", - "chalk": "^4.1.0", + "cacache": "^15.2.0", + "chalk": "^4.1.2", "chownr": "^2.0.0", "cli-columns": "^3.1.2", "cli-table3": "^0.6.0", "columnify": "~1.5.4", + "fastest-levenshtein": "^1.0.12", "glob": "^7.1.7", - "graceful-fs": "^4.2.6", + "graceful-fs": "^4.2.8", "hosted-git-info": "^4.0.2", "ini": "^2.0.0", - "init-package-json": "^2.0.3", + "init-package-json": "^2.0.4", "is-cidr": "^4.0.2", "json-parse-even-better-errors": "^2.3.1", - "leven": "^3.1.0", "libnpmaccess": "^4.0.2", "libnpmdiff": "^2.0.4", - "libnpmexec": "^1.1.1", - "libnpmfund": "^1.0.2", + "libnpmexec": "^2.0.1", + "libnpmfund": "^1.1.0", "libnpmhook": "^6.0.2", "libnpmorg": "^2.0.2", "libnpmpack": "^2.0.1", "libnpmpublish": "^4.0.1", "libnpmsearch": "^3.1.1", "libnpmteam": "^2.0.3", - "libnpmversion": "^1.2.0", - "make-fetch-happen": "^8.0.14", + "libnpmversion": "^1.2.1", + "make-fetch-happen": "^9.0.5", "minipass": "^3.1.3", "minipass-pipeline": "^1.2.4", "mkdirp": "^1.0.4", @@ -11499,25 +11503,25 @@ "ms": "^2.1.2", "node-gyp": "^7.1.2", "nopt": "^5.0.0", - "npm-audit-report": "^2.1.4", - "npm-package-arg": "^8.1.2", + "npm-audit-report": "^2.1.5", + "npm-package-arg": "^8.1.5", "npm-pick-manifest": "^6.1.1", "npm-profile": "^5.0.3", - "npm-registry-fetch": "^10.1.1", + "npm-registry-fetch": "^11.0.0", "npm-user-validate": "^1.0.1", - "npmlog": "~4.1.2", + "npmlog": "^5.0.0", "opener": "^1.5.2", - "pacote": "^11.3.3", + "pacote": "^11.3.5", "parse-conflict-json": "^1.1.1", "qrcode-terminal": "^0.12.0", "read": "~1.0.7", - "read-package-json": "^3.0.1", - "read-package-json-fast": "^2.0.2", + "read-package-json": "^4.0.0", + "read-package-json-fast": "^2.0.3", "readdir-scoped-modules": "^1.1.0", "rimraf": "^3.0.2", "semver": "^7.3.5", "ssri": "^8.0.1", - "tar": "^6.1.0", + "tar": "^6.1.10", "text-table": "~0.2.0", "tiny-relative-date": "^1.3.0", "treeverse": "^1.0.4", @@ -11527,7 +11531,7 @@ }, "dependencies": { "@npmcli/arborist": { - "version": "2.4.4", + "version": "2.8.2", "bundled": true, "requires": { "@npmcli/installed-package-contents": "^1.0.7", @@ -11536,25 +11540,29 @@ "@npmcli/move-file": "^1.1.0", "@npmcli/name-from-folder": "^1.0.1", "@npmcli/node-gyp": "^1.0.1", + "@npmcli/package-json": "^1.0.1", "@npmcli/run-script": "^1.8.2", "bin-links": "^2.2.1", "cacache": "^15.0.3", "common-ancestor-path": "^1.0.1", "json-parse-even-better-errors": "^2.3.1", "json-stringify-nice": "^1.1.4", + "mkdirp": "^1.0.4", "mkdirp-infer-owner": "^2.0.0", "npm-install-checks": "^4.0.0", - "npm-package-arg": "^8.1.0", + "npm-package-arg": "^8.1.5", "npm-pick-manifest": "^6.1.0", - "npm-registry-fetch": "^10.0.0", - "pacote": "^11.2.6", + "npm-registry-fetch": "^11.0.0", + "pacote": "^11.3.5", "parse-conflict-json": "^1.1.1", + "proc-log": "^1.0.0", "promise-all-reject-late": "^1.0.0", "promise-call-limit": "^1.0.1", "read-package-json-fast": "^2.0.2", "readdir-scoped-modules": "^1.1.0", + "rimraf": "^3.0.2", "semver": "^7.3.5", - "tar": "^6.1.0", + "ssri": "^8.0.1", "treeverse": "^1.0.4", "walk-up-path": "^1.0.0" } @@ -11582,7 +11590,7 @@ } }, "@npmcli/git": { - "version": "2.0.9", + "version": "2.1.0", "bundled": true, "requires": { "@npmcli/promise-spawn": "^1.3.2", @@ -11604,7 +11612,7 @@ } }, "@npmcli/map-workspaces": { - "version": "1.0.3", + "version": "1.0.4", "bundled": true, "requires": { "@npmcli/name-from-folder": "^1.0.1", @@ -11638,6 +11646,13 @@ "version": "1.0.2", "bundled": true }, + "@npmcli/package-json": { + "version": "1.0.1", + "bundled": true, + "requires": { + "json-parse-even-better-errors": "^2.3.1" + } + }, "@npmcli/promise-spawn": { "version": "1.3.2", "bundled": true, @@ -11646,12 +11661,11 @@ } }, "@npmcli/run-script": { - "version": "1.8.5", + "version": "1.8.6", "bundled": true, "requires": { "@npmcli/node-gyp": "^1.0.2", "@npmcli/promise-spawn": "^1.3.2", - "infer-owner": "^1.0.4", "node-gyp": "^7.1.0", "read-package-json-fast": "^2.0.1" } @@ -11799,12 +11813,8 @@ "version": "1.0.3", "bundled": true }, - "byte-size": { - "version": "7.0.1", - "bundled": true - }, "cacache": { - "version": "15.0.6", + "version": "15.2.0", "bundled": true, "requires": { "@npmcli/move-file": "^1.0.1", @@ -11831,7 +11841,7 @@ "bundled": true }, "chalk": { - "version": "4.1.1", + "version": "4.1.2", "bundled": true, "requires": { "ansi-styles": "^4.1.0", @@ -11922,6 +11932,10 @@ "version": "1.1.4", "bundled": true }, + "color-support": { + "version": "1.1.3", + "bundled": true + }, "colors": { "version": "1.4.0", "bundled": true, @@ -11966,7 +11980,7 @@ } }, "debug": { - "version": "4.3.1", + "version": "4.3.2", "bundled": true, "requires": { "ms": "2.1.2" @@ -12057,19 +12071,14 @@ "version": "2.1.0", "bundled": true }, + "fastest-levenshtein": { + "version": "1.0.12", + "bundled": true + }, "forever-agent": { "version": "0.6.1", "bundled": true }, - "form-data": { - "version": "2.3.3", - "bundled": true, - "requires": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.6", - "mime-types": "^2.1.12" - } - }, "fs-minipass": { "version": "2.1.0", "bundled": true, @@ -12086,39 +12095,18 @@ "bundled": true }, "gauge": { - "version": "2.7.4", + "version": "3.0.1", "bundled": true, "requires": { - "aproba": "^1.0.3", + "aproba": "^1.0.3 || ^2.0.0", + "color-support": "^1.1.2", "console-control-strings": "^1.0.0", - "has-unicode": "^2.0.0", - "object-assign": "^4.1.0", + "has-unicode": "^2.0.1", + "object-assign": "^4.1.1", "signal-exit": "^3.0.0", - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1", - "wide-align": "^1.1.0" - }, - "dependencies": { - "aproba": { - "version": "1.2.0", - "bundled": true - }, - "is-fullwidth-code-point": { - "version": "1.0.0", - "bundled": true, - "requires": { - "number-is-nan": "^1.0.0" - } - }, - "string-width": { - "version": "1.0.2", - "bundled": true, - "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - } - } + "string-width": "^1.0.1 || ^2.0.0", + "strip-ansi": "^3.0.1 || ^4.0.0", + "wide-align": "^1.1.2" } }, "getpass": { @@ -12141,7 +12129,7 @@ } }, "graceful-fs": { - "version": "4.2.6", + "version": "4.2.8", "bundled": true }, "har-schema": { @@ -12216,7 +12204,7 @@ } }, "iconv-lite": { - "version": "0.6.2", + "version": "0.6.3", "bundled": true, "optional": true, "requires": { @@ -12259,14 +12247,14 @@ "bundled": true }, "init-package-json": { - "version": "2.0.3", + "version": "2.0.4", "bundled": true, "requires": { "glob": "^7.1.1", "npm-package-arg": "^8.1.2", "promzard": "^0.3.0", "read": "~1.0.1", - "read-package-json": "^3.0.1", + "read-package-json": "^4.0.0", "semver": "^7.3.5", "validate-npm-package-license": "^3.0.4", "validate-npm-package-name": "^3.0.0" @@ -12288,7 +12276,7 @@ } }, "is-core-module": { - "version": "2.2.0", + "version": "2.6.0", "bundled": true, "requires": { "has": "^1.0.3" @@ -12364,18 +12352,14 @@ "version": "3.0.0", "bundled": true }, - "leven": { - "version": "3.1.0", - "bundled": true - }, "libnpmaccess": { - "version": "4.0.2", + "version": "4.0.3", "bundled": true, "requires": { "aproba": "^2.0.0", "minipass": "^3.1.1", "npm-package-arg": "^8.1.2", - "npm-registry-fetch": "^10.0.0" + "npm-registry-fetch": "^11.0.0" } }, "libnpmdiff": { @@ -12387,13 +12371,13 @@ "binary-extensions": "^2.2.0", "diff": "^5.0.0", "minimatch": "^3.0.4", - "npm-package-arg": "^8.1.1", - "pacote": "^11.3.0", + "npm-package-arg": "^8.1.4", + "pacote": "^11.3.4", "tar": "^6.1.0" } }, "libnpmexec": { - "version": "1.1.1", + "version": "2.0.1", "bundled": true, "requires": { "@npmcli/arborist": "^2.3.0", @@ -12410,26 +12394,26 @@ } }, "libnpmfund": { - "version": "1.0.2", + "version": "1.1.0", "bundled": true, "requires": { - "@npmcli/arborist": "^2.0.0" + "@npmcli/arborist": "^2.5.0" } }, "libnpmhook": { - "version": "6.0.2", + "version": "6.0.3", "bundled": true, "requires": { "aproba": "^2.0.0", - "npm-registry-fetch": "^10.0.0" + "npm-registry-fetch": "^11.0.0" } }, "libnpmorg": { - "version": "2.0.2", + "version": "2.0.3", "bundled": true, "requires": { "aproba": "^2.0.0", - "npm-registry-fetch": "^10.0.0" + "npm-registry-fetch": "^11.0.0" } }, "libnpmpack": { @@ -12442,33 +12426,33 @@ } }, "libnpmpublish": { - "version": "4.0.1", + "version": "4.0.2", "bundled": true, "requires": { "normalize-package-data": "^3.0.2", "npm-package-arg": "^8.1.2", - "npm-registry-fetch": "^10.0.0", + "npm-registry-fetch": "^11.0.0", "semver": "^7.1.3", "ssri": "^8.0.1" } }, "libnpmsearch": { - "version": "3.1.1", + "version": "3.1.2", "bundled": true, "requires": { - "npm-registry-fetch": "^10.0.0" + "npm-registry-fetch": "^11.0.0" } }, "libnpmteam": { - "version": "2.0.3", + "version": "2.0.4", "bundled": true, "requires": { "aproba": "^2.0.0", - "npm-registry-fetch": "^10.0.0" + "npm-registry-fetch": "^11.0.0" } }, "libnpmversion": { - "version": "1.2.0", + "version": "1.2.1", "bundled": true, "requires": { "@npmcli/git": "^2.0.7", @@ -12486,11 +12470,11 @@ } }, "make-fetch-happen": { - "version": "8.0.14", + "version": "9.0.5", "bundled": true, "requires": { "agentkeepalive": "^4.1.3", - "cacache": "^15.0.5", + "cacache": "^15.2.0", "http-cache-semantics": "^4.1.0", "http-proxy-agent": "^4.0.1", "https-proxy-agent": "^5.0.0", @@ -12501,20 +12485,21 @@ "minipass-fetch": "^1.3.2", "minipass-flush": "^1.0.5", "minipass-pipeline": "^1.2.4", + "negotiator": "^0.6.2", "promise-retry": "^2.0.1", - "socks-proxy-agent": "^5.0.0", + "socks-proxy-agent": "^6.0.0", "ssri": "^8.0.0" } }, "mime-db": { - "version": "1.47.0", + "version": "1.49.0", "bundled": true }, "mime-types": { - "version": "2.1.30", + "version": "2.1.32", "bundled": true, "requires": { - "mime-db": "1.47.0" + "mime-db": "1.49.0" } }, "minimatch": { @@ -12539,7 +12524,7 @@ } }, "minipass-fetch": { - "version": "1.3.3", + "version": "1.3.4", "bundled": true, "requires": { "encoding": "^0.1.12", @@ -12606,6 +12591,10 @@ "version": "0.0.8", "bundled": true }, + "negotiator": { + "version": "0.6.2", + "bundled": true + }, "node-gyp": { "version": "7.1.2", "bundled": true, @@ -12620,6 +12609,52 @@ "semver": "^7.3.2", "tar": "^6.0.2", "which": "^2.0.2" + }, + "dependencies": { + "aproba": { + "version": "1.2.0", + "bundled": true + }, + "gauge": { + "version": "2.7.4", + "bundled": true, + "requires": { + "aproba": "^1.0.3", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.0", + "object-assign": "^4.1.0", + "signal-exit": "^3.0.0", + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wide-align": "^1.1.0" + } + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "bundled": true, + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "npmlog": { + "version": "4.1.2", + "bundled": true, + "requires": { + "are-we-there-yet": "~1.1.2", + "console-control-strings": "~1.1.0", + "gauge": "~2.7.3", + "set-blocking": "~2.0.0" + } + }, + "string-width": { + "version": "1.0.2", + "bundled": true, + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + } } }, "nopt": { @@ -12630,17 +12665,17 @@ } }, "normalize-package-data": { - "version": "3.0.2", + "version": "3.0.3", "bundled": true, "requires": { "hosted-git-info": "^4.0.1", - "resolve": "^1.20.0", + "is-core-module": "^2.5.0", "semver": "^7.3.4", "validate-npm-package-license": "^3.0.1" } }, "npm-audit-report": { - "version": "2.1.4", + "version": "2.1.5", "bundled": true, "requires": { "chalk": "^4.0.0" @@ -12665,7 +12700,7 @@ "bundled": true }, "npm-package-arg": { - "version": "8.1.2", + "version": "8.1.5", "bundled": true, "requires": { "hosted-git-info": "^4.0.1", @@ -12694,18 +12729,17 @@ } }, "npm-profile": { - "version": "5.0.3", + "version": "5.0.4", "bundled": true, "requires": { - "npm-registry-fetch": "^10.0.0" + "npm-registry-fetch": "^11.0.0" } }, "npm-registry-fetch": { - "version": "10.1.1", + "version": "11.0.0", "bundled": true, "requires": { - "lru-cache": "^6.0.0", - "make-fetch-happen": "^8.0.9", + "make-fetch-happen": "^9.0.1", "minipass": "^3.1.3", "minipass-fetch": "^1.3.0", "minipass-json-stream": "^1.0.1", @@ -12718,13 +12752,13 @@ "bundled": true }, "npmlog": { - "version": "4.1.2", + "version": "5.0.0", "bundled": true, "requires": { - "are-we-there-yet": "~1.1.2", - "console-control-strings": "~1.1.0", - "gauge": "~2.7.3", - "set-blocking": "~2.0.0" + "are-we-there-yet": "^1.1.5", + "console-control-strings": "^1.1.0", + "gauge": "^3.0.0", + "set-blocking": "^2.0.0" } }, "number-is-nan": { @@ -12758,10 +12792,10 @@ } }, "pacote": { - "version": "11.3.3", + "version": "11.3.5", "bundled": true, "requires": { - "@npmcli/git": "^2.0.1", + "@npmcli/git": "^2.1.0", "@npmcli/installed-package-contents": "^1.0.6", "@npmcli/promise-spawn": "^1.2.0", "@npmcli/run-script": "^1.8.2", @@ -12774,7 +12808,7 @@ "npm-package-arg": "^8.0.1", "npm-packlist": "^2.1.4", "npm-pick-manifest": "^6.0.0", - "npm-registry-fetch": "^10.0.0", + "npm-registry-fetch": "^11.0.0", "promise-retry": "^2.0.1", "read-package-json-fast": "^2.0.1", "rimraf": "^3.0.2", @@ -12795,10 +12829,6 @@ "version": "1.0.1", "bundled": true }, - "path-parse": { - "version": "1.0.6", - "bundled": true - }, "performance-now": { "version": "2.1.0", "bundled": true @@ -12866,7 +12896,7 @@ "bundled": true }, "read-package-json": { - "version": "3.0.1", + "version": "4.0.0", "bundled": true, "requires": { "glob": "^7.1.1", @@ -12876,7 +12906,7 @@ } }, "read-package-json-fast": { - "version": "2.0.2", + "version": "2.0.3", "bundled": true, "requires": { "json-parse-even-better-errors": "^2.3.0", @@ -12932,6 +12962,15 @@ "uuid": "^3.3.2" }, "dependencies": { + "form-data": { + "version": "2.3.3", + "bundled": true, + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" + } + }, "tough-cookie": { "version": "2.5.0", "bundled": true, @@ -12942,14 +12981,6 @@ } } }, - "resolve": { - "version": "1.20.0", - "bundled": true, - "requires": { - "is-core-module": "^2.2.0", - "path-parse": "^1.0.6" - } - }, "retry": { "version": "0.12.0", "bundled": true @@ -12985,7 +13016,7 @@ "bundled": true }, "smart-buffer": { - "version": "4.1.0", + "version": "4.2.0", "bundled": true }, "socks": { @@ -12997,12 +13028,12 @@ } }, "socks-proxy-agent": { - "version": "5.0.0", + "version": "6.0.0", "bundled": true, "requires": { - "agent-base": "6", - "debug": "4", - "socks": "^2.3.3" + "agent-base": "^6.0.2", + "debug": "^4.3.1", + "socks": "^2.6.1" } }, "spdx-correct": { @@ -13026,7 +13057,7 @@ } }, "spdx-license-ids": { - "version": "3.0.7", + "version": "3.0.10", "bundled": true }, "sshpk": { @@ -13098,7 +13129,7 @@ } }, "tar": { - "version": "6.1.0", + "version": "6.1.10", "bundled": true, "requires": { "chownr": "^2.0.0", @@ -13755,9 +13786,9 @@ "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=" }, "path-parse": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", - "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==" + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==" }, "path-to-regexp": { "version": "0.1.7", @@ -19060,9 +19091,9 @@ } }, "ssri": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/ssri/-/ssri-7.1.0.tgz", - "integrity": "sha512-77/WrDZUWocK0mvA5NTRQyveUf+wsrIc6vyrxpS8tVvYBcX215QbafrJR3KtkpskIzoFLqqNuuYQvxaMjXJ/0g==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/ssri/-/ssri-7.1.1.tgz", + "integrity": "sha512-w+daCzXN89PseTL99MkA+fxJEcU3wfaE/ah0i0lnOlpG1CYLJ2ZjzEry68YBKfLs4JfoTShrTEsJkAZuNZ/stw==", "requires": { "figgy-pudding": "^3.5.1", "minipass": "^3.1.1" @@ -19964,6 +19995,11 @@ "prelude-ls": "~1.1.2" } }, + "type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==" + }, "type-fest": { "version": "0.7.1", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.7.1.tgz", @@ -20161,9 +20197,9 @@ } }, "url-parse": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.1.tgz", - "integrity": "sha512-HOfCOUJt7iSYzEx/UqgtwKRMC6EU91NFhsCHMv9oM03VJcVo2Qrp8T8kI9D7amFf1cu+/3CEhgb3rF9zL7k85Q==", + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.3.tgz", + "integrity": "sha512-IIORyIQD9rvj0A4CLWsHkBBJuNqWpFQe224b6j9t/ABmquIS0qDU2pY6kl6AuOrL5OkCXHMCFNe1jBcuAggjvQ==", "requires": { "querystringify": "^2.1.1", "requires-port": "^1.0.0" @@ -21003,9 +21039,9 @@ } }, "ws": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz", - "integrity": "sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA==", + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.2.tgz", + "integrity": "sha512-zmhltoSR8u1cnDsD43TX59mzoMZsLKqUweyYBAIvTngR3shc0W6aOZylZmq/7hqyVxPdi+5Ud2QInblgyE72fw==", "requires": { "async-limiter": "~1.0.0" } diff --git a/package.json b/package.json index 249a4c46..3346a2aa 100644 --- a/package.json +++ b/package.json @@ -20,9 +20,11 @@ "axios": "^0.21.1", "babel-plugin-styled-components": "^1.12.0", "date-fns": "^2.21.2", + "deepcopy": "^2.1.0", + "immutability-helper": "^3.1.1", "next": "10.0.6", "next-images": "^1.7.0", - "npm": "^7.11.1", + "npm": "^7.21.0", "nprogress": "^0.2.0", "polished": "^4.1.2", "prop-types": "^15.7.2", diff --git a/src/components/ChartTotalRoomsWithFilter/auxfunctions.js b/src/components/ChartTotalRoomsWithFilter/auxfunctions.js new file mode 100644 index 00000000..dcdbf037 --- /dev/null +++ b/src/components/ChartTotalRoomsWithFilter/auxfunctions.js @@ -0,0 +1,47 @@ +const deepcopy = require('deepcopy'); + +/* eslint-disable import/prefer-default-export */ +async function removeColumnOfMatrix(matrix, indexToRemove) { + await matrix.forEach((column) => { + column.splice(indexToRemove, 1); + }); + + return matrix; +} + +async function removeColumnsOfMatrix(matrix, column) { + const columnsTitle = matrix[0]; + let i = 1; // Start in 1 because the 0 corresponds to the dates matrix index + let filteredMatrix = []; + + if (!columnsTitle) { + return matrix; + } + + while (i < columnsTitle.length) { + if (columnsTitle[i] === column) { + // eslint-disable-next-line no-await-in-loop + filteredMatrix = await removeColumnOfMatrix(matrix.slice(), i); + } + i += 1; + } + + return filteredMatrix; +} + +export async function filterDataOfTotalRoomsMatrix(matrix, colsToRemove) { + let i = 0; + let filteredMatrix = deepcopy(matrix); + + if (colsToRemove.length === 0) { + return filteredMatrix; + } + + while (i < colsToRemove.length) { + // eslint-disable-next-line no-await-in-loop + filteredMatrix = await removeColumnsOfMatrix(filteredMatrix, colsToRemove[i]); + i += 1; + } + + return filteredMatrix; +} diff --git a/src/components/ChartTotalRoomsWithFilter/index.js b/src/components/ChartTotalRoomsWithFilter/index.js new file mode 100644 index 00000000..8e93c9fd --- /dev/null +++ b/src/components/ChartTotalRoomsWithFilter/index.js @@ -0,0 +1,229 @@ +/* eslint-disable no-await-in-loop */ +/* eslint-disable react/require-default-props */ +import React, { useState } from 'react'; +import PropTypes from 'prop-types'; + +import { + Box, Radio, RadioGroup, FormControlLabel, FormControl, CircularProgress, + makeStyles, Typography, Checkbox, +} from '@material-ui/core'; + +import { withStyles } from '@material-ui/core/styles'; +import TableDarkTheme from '../TableDarkTheme/index'; +import ChartDataFrame from '../ChartDataFrame/index'; +import GoogleChart from '../Charts/GoogleChart'; +import convertArrayToJSON from '../../utils/format/convertArrayToJson/index'; +import { filterDataOfTotalRoomsMatrix } from './auxfunctions'; + +const useStyles = makeStyles(() => ({ + messageTypograph: { + fontFamily: 'Open Sans', + fontSize: '1.5rem', + fontWeight: 'bold', + paddingTop: '20px', + color: '#DA7F0B', + }, +})); + +const CustomRadio = withStyles({ + root: { + color: 'white', + borderColor: 'blue', + '&$checked': { + color: 'white', + }, + }, + checked: {}, +})((props) => ); + +const WhiteCheckbox = withStyles({ + root: { + color: 'white', + '&$checked': { + color: 'white', + }, + }, + checked: {}, +})((props) => ); + +function FormControlRadioOptions(props) { + const { handleChange, currentValue } = props; + + return ( + + + } + label="Ver como Gráfico" + /> + } + label="Ver como Tabela" + /> + + + ); +} + +function getColumns(data) { + return Object(data[0]).map((key) => ({ + name: key, + selector: key, + sortable: true, + center: true, + })); +} + +export default function ChartTotalRoomsWithFilter(props) { + const classes = useStyles(); + const { + isLoaded, title, data, chartType, chartOptions, exportData, + apiLastUpdate, tool, height, apiUrl, + } = props; + const defaultData = data; + const columns = getColumns(data); + const [wayOfVisualizeData, setWayOfVisualizeData] = useState('chart'); + const convertDataToJson = convertArrayToJSON(data); + const [columnsToNotShow, setColumnsToNotShow] = useState([]); + const [dataToShow, setDataToShow] = useState(data); + + async function handleShowColumsChange(event) { + let columnsToNotBeShow = []; + + if ((columnsToNotShow).includes(event.target.name)) { // Para passar a mostrar + // eslint-disable-next-line max-len + columnsToNotBeShow = columnsToNotBeShow.filter((column) => column === event.target.name); + setColumnsToNotShow(columnsToNotBeShow); + const tempDataToShow = await filterDataOfTotalRoomsMatrix(defaultData, columnsToNotBeShow); + setDataToShow(tempDataToShow); + } else { // Para passar a não mostrar + columnsToNotBeShow = ([...columnsToNotShow, event.target.name]); + setColumnsToNotShow(columnsToNotBeShow); + if (columnsToNotBeShow.length < 3) { + const tempDataToShow = await filterDataOfTotalRoomsMatrix(defaultData, columnsToNotBeShow); + setDataToShow(tempDataToShow); + } + } + } + + function handleWayOfVisualizeDataChange(e) { + if (e.target.value === 'table') { + setWayOfVisualizeData('table'); + } else { + setWayOfVisualizeData('chart'); + } + } + + return ( + +
+ {isLoaded ? ( + <> + + + + <> + {(wayOfVisualizeData === 'chart') ? ( + <> + + {(columnsToNotShow.length !== 3) ? ( + + ) : ( + + + Selecione uma ou mais das opções abaixo para visualizar o gráfico. + + + )} + + + + } + label="Canceladas" + /> + } + label="Realizadas" + /> + } + label="Total" + /> + + + ) : ( + + + + )} + + + ) : ( + + + + )} +
+
+ ); +} + +FormControlRadioOptions.propTypes = { + handleChange: PropTypes.func, + currentValue: PropTypes.string, +}; + +ChartTotalRoomsWithFilter.propTypes = { + isLoaded: PropTypes.bool, + title: PropTypes.string, + data: PropTypes.node, + chartType: PropTypes.string, + chartOptions: PropTypes.object, + exportData: PropTypes.array, + apiLastUpdate: PropTypes.string, + tool: PropTypes.string, + height: PropTypes.string, + apiUrl: PropTypes.string, +}; + +ChartTotalRoomsWithFilter.defaultProps = { + isLoaded: false, + title: 'Title', + data: {}, + chartType: '', + chartOptions: {}, + exportData: [], + apiLastUpdate: 'Carregando', + tool: '', + height: '35vh', + apiUrl: process.env.NEXT_PUBLIC_EDEMOCRACIA_SWAGGER_URL, +}; diff --git a/src/components/index.js b/src/components/index.js index fbe593e6..9d453104 100644 --- a/src/components/index.js +++ b/src/components/index.js @@ -1,6 +1,7 @@ import { AlertCachedData } from './Alert/index'; import ChartAndReport from './ChartAndReport/index'; import ChartDataFrame from './ChartDataFrame/index'; +import ChartTotalRoomsWithFilter from './ChartTotalRoomsWithFilter/index'; import GoogleChart from './Charts/GoogleChart'; import Footer from './Footer/index'; import Header from './Header/index'; @@ -17,5 +18,5 @@ export { AlertCachedData, ChartAndReport, ChartDataFrame, GoogleChart, Footer, Header, NoDataForSelectedPeriod, RankingTable, SectionHeader, SubSectionHeader, TableDarkTheme, ToolTip, TotalFrame, - AlertDataConsolidateInterval, + AlertDataConsolidateInterval, ChartTotalRoomsWithFilter, }; diff --git a/src/containers/Audiencias/auxFunctions/__test__/computeTotalRooms.test.js b/src/containers/Audiencias/auxFunctions/__test__/computeTotalRooms.test.js new file mode 100644 index 00000000..87dd5b8b --- /dev/null +++ b/src/containers/Audiencias/auxFunctions/__test__/computeTotalRooms.test.js @@ -0,0 +1,64 @@ +import { + getRoomTotalsChartDataByDay, getRoomTotalsChartDataByMonth, getRoomTotalsChartDataByYear, +} from '../computeTotalRooms'; + +import * as apisMock from '../../../../mocks/audiencias/index'; + +describe('Test getRoomTotalsChartDataByDay function', () => { + const testMonth = 4; + const testYear = 2021; + + test('getRoomTotalsChartDataByDay return data with 30 days(april)', async () => { + const resultArray = await getRoomTotalsChartDataByDay( + testMonth, testYear, apisMock.roomsApiMock.DAILY.results, + ); + expect(resultArray.length).toBe(30); + }); + + test('getRoomTotalsChartDataByDay return data with 31 days(may)', async () => { + const resultArray = await getRoomTotalsChartDataByDay( + (testMonth + 1), testYear, apisMock.roomsApiMock.DAILY.results, + ); + expect(resultArray.length).toBe(31); + }); +}); + +describe('Test getRoomTotalsChartDataByMonth function', () => { + const testYear = 2021; + + test('getRoomTotalsChartDataByMonth return data with 12 months', async () => { + const resultArray = await getRoomTotalsChartDataByMonth( + testYear, apisMock.roomsApiMock.MONTHLY.results, + ); + + expect(resultArray).not.toBe(null); + expect(resultArray.length).not.toBe(1); + expect(resultArray.length).toBe(12); + }); + + test('getRoomTotalsChartDataByMonth catch with undefined values', async () => { + const resultArray = await getRoomTotalsChartDataByMonth( + testYear, undefined, + ); + expect(resultArray.length).toBe(0); + }); +}); + +describe('Test getRoomTotalsChartDataByYear function', () => { + test('getRoomTotalsChartDataByYear return data with 6 years', async () => { + const resultArray = await getRoomTotalsChartDataByYear( + apisMock.roomsApiMock.YEARLY.results, + ); + expect(resultArray).not.toBe(null); + expect(resultArray.length).not.toBe(1); + expect(resultArray[0][0]).toBe('2016'); + expect(resultArray.length).toBe(6); + }); + + test('getRoomTotalsChartDataByYear catch with undefined values', async () => { + const resultArray = await getRoomTotalsChartDataByYear( + undefined, + ); + expect(resultArray.length).toBe(0); + }); +}); diff --git a/src/containers/Audiencias/auxFunctions/computeTotalRooms.js b/src/containers/Audiencias/auxFunctions/computeTotalRooms.js new file mode 100644 index 00000000..43873e8b --- /dev/null +++ b/src/containers/Audiencias/auxFunctions/computeTotalRooms.js @@ -0,0 +1,77 @@ +/* eslint-disable max-len */ +/* eslint-disable import/prefer-default-export */ +import { + MONTHS_ABBREVIATED_LIST, +} from '../../../utils/constants/index'; +import padNumberWithZeroOnLeft from '../../../utils/format/numbers/padNumberWithZeroOnLeft'; + +export async function getRoomTotalsChartDataByDay(month, year, roomsData) { + const totalOfDaysInMonth = await new Date(year, month, 0).getDate(); + const resultArray = []; + + try { + for (let i = 1; i <= totalOfDaysInMonth; i += 1) { + const roomsFiltered = roomsData.filter( + (room) => room.end_date === `${year}-${padNumberWithZeroOnLeft(month)}-${padNumberWithZeroOnLeft(i)}`, + ); + + resultArray.push( + [ + `${padNumberWithZeroOnLeft(i)}`, + (roomsFiltered.length > 0) ? roomsFiltered[0].finished_rooms : 0, + (roomsFiltered.length > 0) ? roomsFiltered[0].canceled_rooms : 0, + (roomsFiltered.length > 0) ? roomsFiltered[0].total_rooms : 0, + ], + ); + } + + return resultArray; + } catch (e) { + return []; + } +} + +export async function getRoomTotalsChartDataByMonth(year, roomsData) { + const resultArray = []; + try { + for (let i = 1; i <= 12; i += 1) { + const roomsFiltered = roomsData.filter( + (room) => room.start_date === `${year}-${padNumberWithZeroOnLeft(i)}-01`, + ); + + resultArray.push( + [ + `${MONTHS_ABBREVIATED_LIST[i - 1]}`, + (roomsFiltered.length > 0) ? roomsFiltered[0].canceled_rooms : 0, + (roomsFiltered.length > 0) ? roomsFiltered[0].finished_rooms : 0, + (roomsFiltered.length > 0) ? roomsFiltered[0].total_rooms : 0, + ], + ); + } + + return resultArray; + } catch (e) { + return resultArray; + } +} + +export async function getRoomTotalsChartDataByYear(roomsData) { + const resultArray = []; + + try { + for (let i = 0; i <= roomsData.length; i += 1) { + resultArray.push( + [ + (roomsData[i].year).toString(), + roomsData[i].canceled_rooms, + roomsData[i].finished_rooms, + roomsData[i].total_rooms, + ], + ); + } + + return resultArray; + } catch (e) { + return resultArray; + } +} diff --git a/src/containers/Audiencias/index.js b/src/containers/Audiencias/index.js index 5108fb28..9a63f570 100644 --- a/src/containers/Audiencias/index.js +++ b/src/containers/Audiencias/index.js @@ -10,7 +10,7 @@ import ptBR from 'date-fns/locale/pt-BR'; import { apiInstance } from '../../services/api/apiInstance'; import { AlertCachedData, ChartDataFrame, Header, RankingTable, TotalFrame, SectionHeader, SubSectionHeader, - NoDataForSelectedPeriod, ChartAndReport, AlertDataConsolidateInterval, + NoDataForSelectedPeriod, ChartAndReport, AlertDataConsolidateInterval, ChartTotalRoomsWithFilter, } from '../../components'; import { handleUpdatePeriodSearchQuery } from '../../services/functions/handlers/index'; import formatNumberWithDots from '../../utils/format/numbers/formatNumbersWithDots/formatNumberWithDots'; @@ -21,8 +21,11 @@ import * as APPLICATION_CONSTANTS from '../../utils/constants/index'; import { getParticipationChartDataByDay, getParticipationChartDataByMonth, getParticipationChartDataByYear, } from './auxFunctions/computeParticipation'; +import { + getRoomTotalsChartDataByDay, getRoomTotalsChartDataByMonth, getRoomTotalsChartDataByYear, +} from './auxFunctions/computeTotalRooms'; import filterRankingAudiencias from './auxFunctions/filterRanking'; -import { audiencesChartsUsersSettings, audiencesWithMoreParticipation } from './settings/chartsSettings'; +import { audiencesChartsUsersSettings, audiencesWithMoreParticipation, audiencesRoomsTotalsChart } from './settings/chartsSettings'; import { rankingAudienciasHeaders, rankingAudienciaColumns } from './settings/rankingSettings'; import { useStyles } from './style'; import customTheme from '../../styles/theme'; @@ -54,12 +57,15 @@ function Audiencias(props) { const [totalUsersChartData, setTotalUsersChartData] = useState([]); const [roomsRankingData, setRoomsRankingData] = useState(defaultApisData.audienciasRankingData); const [participantionChartData, setParticipantionChartData] = useState([]); + const [totalRoomsDefaultChartData, setTotalRoomsDefaultChartData] = useState([]); + const [totalRoomsChartData, setTotalRoomsChartData] = useState([]); // Error Status const [showCachedDataAlert, setShowCachedDataAlert] = useState(false); // Load Status const [totalsAreLoaded, setTotalsAreLoaded] = useState(false); const [newUsersChartDataLoaded, setNewUsersChartDataLoaded] = useState(false); const [totalUsersChartDataLoaded, setTotalUsersChartDataLoaded] = useState(false); + const [totalRoomsChartDataLoaded, setTotalRoomsChartDataLoaded] = useState(false); // Period Selected states const [selectedPeriod, setSelectedPeriod] = useState(defaultSelectedPeriodType); @@ -338,11 +344,50 @@ function Audiencias(props) { } } + async function updateTotalRoomsChartData(period, month, year) { + try { + const roomsData = apisDataObject.audiencesRoomsAPIData.results; + + let arrayData = []; + const collumPeriodTitle = ['Data', 'Canceladas', 'Realizadas', 'Total']; + + switch (period) { + case dailyKeyWord: + arrayData = await getRoomTotalsChartDataByDay( + month, year, roomsData, + ); + break; + case monthlyKeyWord: + arrayData = await getRoomTotalsChartDataByMonth( + year, roomsData, + ); + break; + default: // yearly -> Total period + arrayData = await getRoomTotalsChartDataByYear( + roomsData, + ); + break; + } + + if (arrayData.length > 0) { + setTotalRoomsDefaultChartData([collumPeriodTitle].concat(arrayData)); + setTotalRoomsChartData([collumPeriodTitle].concat(arrayData)); + } else { + setTotalRoomsChartData(arrayData); + setTotalRoomsDefaultChartData(arrayData); + } + } catch (e) { + console.log(e); + setTotalRoomsChartData([]); + } + } + async function updateAllPageInformations(period, month, year) { try { await updateTotalsData(); await filterAndSetRoomsRankingData(period, month, year); await updateParticipationChartData(period, month, year); + await updateTotalRoomsChartData(period, month, year); await updateNewUsersChartData(period); } catch (e) { console.log('Update all page informations'); @@ -472,6 +517,39 @@ function Audiencias(props) { /> + + + {(totalRoomsChartData !== undefined && totalRoomsChartData.length > 0) ? ( + + ) : ( + + )} + + {/* END GOOGLE ANALYTICS SCRIPTS */} +
diff --git a/src/pages/audiencias.js b/src/pages/audiencias.js index 0eb2c836..3508b3a3 100644 --- a/src/pages/audiencias.js +++ b/src/pages/audiencias.js @@ -24,13 +24,13 @@ function AudienciasPage({ function AudienciasHeader() { return ( - + {TEXTCONSTANTS.pageTitle}
- + {TEXTCONSTANTS.pageSubTitle} diff --git a/src/pages/wikilegis.js b/src/pages/wikilegis.js index 7c48aa6d..11d823ac 100644 --- a/src/pages/wikilegis.js +++ b/src/pages/wikilegis.js @@ -25,16 +25,18 @@ function WikilegisPage({ function WikilegisHeader() { return ( - + {TEXTCONSTANTS.pageTitle} - - - {TEXTCONSTANTS.pageSubTitle} - - +
+ + + {TEXTCONSTANTS.pageSubTitle} + + +
); } diff --git a/src/settings/texts/AudienciasPage/index.js b/src/settings/texts/AudienciasPage/index.js index 68a01683..9f9b4e2e 100644 --- a/src/settings/texts/AudienciasPage/index.js +++ b/src/settings/texts/AudienciasPage/index.js @@ -42,6 +42,13 @@ export const distributionOfParticipationSectionTexts = { toolTipAriaLabel: null, }; +// ==== Distribution of participation in the period chart section ==== +export const totalRoomsSectionTexts = { + title: 'Total de audiências no período', + toolTip: null, + toolTipAriaLabel: null, +}; + // ==== Ranking section ==== export const rankingSectionTexts = { title: 'Ranking das audiências',