diff --git a/docker-compose.yaml b/docker-compose.yaml index 8189fcc0..7203b420 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -12,5 +12,3 @@ services: - .env ports: - ${NEXT_PORT}:3000 - volumes: - - ./next:/app diff --git a/next/Dockerfile b/next/Dockerfile index 8f2e7404..5b4c8378 100644 --- a/next/Dockerfile +++ b/next/Dockerfile @@ -36,6 +36,7 @@ FROM node:18.17.0-alpine AS runner WORKDIR /app ENV NODE_ENV production +ENV NODE_OPTIONS '-r next-logger' # Uncomment the following line in case you want to disable telemetry during runtime. # ENV NEXT_TELEMETRY_DISABLED 1 @@ -58,4 +59,4 @@ EXPOSE 3000 ENV PORT 3000 -CMD ["node", "server.js"] +CMD ["server.js"] diff --git a/next/components/atoms/ControlledInput.js b/next/components/atoms/ControlledInput.js index 0b129ea2..6718f979 100644 --- a/next/components/atoms/ControlledInput.js +++ b/next/components/atoms/ControlledInput.js @@ -73,12 +73,16 @@ export function DebouncedControlledInput({ inputElementStyle, ...props }) { + const [skipFirstDebounced, setSkipFirstDebounced] = useState(true) const [_value, _setValue] = useState(value); const [_timeout, _setTimeout] = useState(null); useEffect(() => { clearTimeout(_timeout); - _setTimeout(setTimeout(() => onChange(_value), 1000)); + _setTimeout(setTimeout(() => { + if(!skipFirstDebounced) onChange(_value) + setSkipFirstDebounced(false) + }, 1000)); }, [_value]); useEffect(() => { diff --git a/next/package-lock.json b/next/package-lock.json index 020b7afc..a17cef1c 100644 --- a/next/package-lock.json +++ b/next/package-lock.json @@ -20,6 +20,7 @@ "fuzzy-search": "^3.2.1", "js-cookie": "^3.0.5", "next": "^12.3.4", + "next-logger": "4.0.0", "react": "^17.0.2", "react-dom": "^17.0.2", "react-image-crop": "^11.0.4", @@ -33,7 +34,6 @@ "version": "7.23.5", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.23.5.tgz", "integrity": "sha512-CgH3s1a96LipHCmSUmYFPwY7MNx8C3avkq7i4Wl3cfa662ldtUe4VM1TPXX70pfmrlWTb6jLqTYrZyT2ZTJBgA==", - "peer": true, "dependencies": { "@babel/highlight": "^7.23.4", "chalk": "^2.4.2" @@ -67,7 +67,6 @@ "version": "7.22.20", "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz", "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==", - "peer": true, "engines": { "node": ">=6.9.0" } @@ -76,7 +75,6 @@ "version": "7.23.4", "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.23.4.tgz", "integrity": "sha512-acGdbYSfp2WheJoJm/EBBBLh/ID8KDc64ISZ9DYtBmC8/Q204PZJLHyzeB5qMzJ5trcOkybd78M4x2KWsUq++A==", - "peer": true, "dependencies": { "@babel/helper-validator-identifier": "^7.22.20", "chalk": "^2.4.2", @@ -1426,11 +1424,21 @@ "resolved": "https://registry.npmjs.org/@types/warning/-/warning-3.0.3.tgz", "integrity": "sha512-D1XC7WK8K+zZEveUPY+cf4+kgauk8N4eHr/XIHXGlGYkHLud6hK9lYfZk1ry1TNh798cZUCgb6MqGEG8DkJt6Q==" }, + "node_modules/abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "dependencies": { + "event-target-shim": "^5.0.0" + }, + "engines": { + "node": ">=6.5" + } + }, "node_modules/ansi-styles": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "peer": true, "dependencies": { "color-convert": "^1.9.0" }, @@ -1438,6 +1446,11 @@ "node": ">=4" } }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" + }, "node_modules/aria-hidden": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/aria-hidden/-/aria-hidden-1.2.3.tgz", @@ -1454,6 +1467,14 @@ "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" }, + "node_modules/atomic-sleep": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/atomic-sleep/-/atomic-sleep-1.0.0.tgz", + "integrity": "sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==", + "engines": { + "node": ">=8.0.0" + } + }, "node_modules/axios": { "version": "1.6.2", "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.2.tgz", @@ -1484,6 +1505,25 @@ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/big-integer": { "version": "1.6.52", "resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.52.tgz", @@ -1516,11 +1556,33 @@ "unload": "2.2.0" } }, + "node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, "node_modules/callsites": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", - "peer": true, "engines": { "node": ">=6" } @@ -1548,7 +1610,6 @@ "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "peer": true, "dependencies": { "ansi-styles": "^3.2.1", "escape-string-regexp": "^1.0.5", @@ -1562,7 +1623,6 @@ "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", - "peer": true, "engines": { "node": ">=0.8.0" } @@ -1571,7 +1631,6 @@ "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "peer": true, "dependencies": { "color-name": "1.1.3" } @@ -1579,8 +1638,7 @@ "node_modules/color-name": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", - "peer": true + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==" }, "node_modules/combined-stream": { "version": "1.0.8", @@ -1709,7 +1767,6 @@ "version": "1.3.2", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", - "peer": true, "dependencies": { "is-arrayish": "^0.2.1" } @@ -1726,6 +1783,30 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", + "engines": { + "node": ">=6" + } + }, + "node_modules/events": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", + "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", + "engines": { + "node": ">=0.8.x" + } + }, + "node_modules/fast-redact": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/fast-redact/-/fast-redact-3.5.0.tgz", + "integrity": "sha512-dwsoQlS7h9hMeYUq1W++23NDcBLV4KqONnITDV9DjfS3q1SgDGVrBdvvTLUotWtPSD7asWDV9/CmsZPy8Hf70A==", + "engines": { + "node": ">=6" + } + }, "node_modules/find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", @@ -1867,7 +1948,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", - "peer": true, "engines": { "node": ">=4" } @@ -1897,11 +1977,29 @@ "react-is": "^16.7.0" } }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/import-fresh": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", - "peer": true, "dependencies": { "parent-module": "^1.0.0", "resolve-from": "^4.0.0" @@ -1938,8 +2036,7 @@ "node_modules/is-arrayish": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", - "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==", - "peer": true + "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==" }, "node_modules/is-core-module": { "version": "2.13.1", @@ -1971,11 +2068,21 @@ "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" }, + "node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, "node_modules/json-parse-even-better-errors": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", - "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", - "peer": true + "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==" }, "node_modules/katex": { "version": "0.13.24", @@ -1995,8 +2102,7 @@ "node_modules/lines-and-columns": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", - "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", - "peer": true + "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==" }, "node_modules/lodash.mergewith": { "version": "4.6.2", @@ -2135,6 +2241,43 @@ } } }, + "node_modules/next-logger": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/next-logger/-/next-logger-4.0.0.tgz", + "integrity": "sha512-+mRXDxLMzbnt4xSNNiv3tDz82WuTj62KDZaMmYKNReRQ5s1C8eWsAlQXh2S+sCWS0OueUAMMLmwCgSRPakHpog==", + "dependencies": { + "cosmiconfig": "^8.1.3", + "pino": "^8.11.0" + }, + "peerDependencies": { + "next": ">=9.0.0" + } + }, + "node_modules/next-logger/node_modules/cosmiconfig": { + "version": "8.3.6", + "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-8.3.6.tgz", + "integrity": "sha512-kcZ6+W5QzcJ3P1Mt+83OUv/oHFqZHIx8DuxG6eZ5RGMERoLqp4BuGjhHLYGK+Kf5XVkQvqBSmAy/nGWN3qDgEA==", + "dependencies": { + "import-fresh": "^3.3.0", + "js-yaml": "^4.1.0", + "parse-json": "^5.2.0", + "path-type": "^4.0.0" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/d-fischer" + }, + "peerDependencies": { + "typescript": ">=4.9.5" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, "node_modules/object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", @@ -2148,6 +2291,14 @@ "resolved": "https://registry.npmjs.org/oblivious-set/-/oblivious-set-1.0.0.tgz", "integrity": "sha512-z+pI07qxo4c2CulUHCDf9lcqDlMSo72N/4rLUpRXf6fu+q8vjt8y0xS+Tlf8NTJDdTXHbdeO1n3MlbctwEoXZw==" }, + "node_modules/on-exit-leak-free": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/on-exit-leak-free/-/on-exit-leak-free-2.1.2.tgz", + "integrity": "sha512-0eJJY6hXLGf1udHwfNftBqH+g73EU4B504nZeKpz1sYRKafAghwxEJunB2O7rDZkL4PGfsMVnTXZ2EjibbqcsA==", + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -2160,7 +2311,6 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", - "peer": true, "dependencies": { "callsites": "^3.0.0" }, @@ -2172,7 +2322,6 @@ "version": "5.2.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", - "peer": true, "dependencies": { "@babel/code-frame": "^7.0.0", "error-ex": "^1.3.1", @@ -2204,7 +2353,6 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", - "peer": true, "engines": { "node": ">=8" } @@ -2214,6 +2362,41 @@ "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" }, + "node_modules/pino": { + "version": "8.21.0", + "resolved": "https://registry.npmjs.org/pino/-/pino-8.21.0.tgz", + "integrity": "sha512-ip4qdzjkAyDDZklUaZkcRFb2iA118H9SgRh8yzTkSQK8HilsOJF7rSY8HoW5+I0M46AZgX/pxbprf2vvzQCE0Q==", + "dependencies": { + "atomic-sleep": "^1.0.0", + "fast-redact": "^3.1.1", + "on-exit-leak-free": "^2.1.0", + "pino-abstract-transport": "^1.2.0", + "pino-std-serializers": "^6.0.0", + "process-warning": "^3.0.0", + "quick-format-unescaped": "^4.0.3", + "real-require": "^0.2.0", + "safe-stable-stringify": "^2.3.1", + "sonic-boom": "^3.7.0", + "thread-stream": "^2.6.0" + }, + "bin": { + "pino": "bin.js" + } + }, + "node_modules/pino-abstract-transport": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/pino-abstract-transport/-/pino-abstract-transport-1.2.0.tgz", + "integrity": "sha512-Guhh8EZfPCfH+PMXAb6rKOjGQEoy0xlAIn+irODG5kgfYV+BQ0rGYYWTIel3P5mmyXqkYkPmdIkywsn6QKUR1Q==", + "dependencies": { + "readable-stream": "^4.0.0", + "split2": "^4.0.0" + } + }, + "node_modules/pino-std-serializers": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/pino-std-serializers/-/pino-std-serializers-6.2.2.tgz", + "integrity": "sha512-cHjPPsE+vhj/tnhCy/wiMh3M3z3h/j15zHQX+S9GkTBgqJuTuJzYJ4gUyACLhDaJ7kk9ba9iRDmbH2tJU03OiA==" + }, "node_modules/popmotion": { "version": "9.3.6", "resolved": "https://registry.npmjs.org/popmotion/-/popmotion-9.3.6.tgz", @@ -2248,6 +2431,19 @@ "node": "^10 || ^12 || >=14" } }, + "node_modules/process": { + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", + "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==", + "engines": { + "node": ">= 0.6.0" + } + }, + "node_modules/process-warning": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/process-warning/-/process-warning-3.0.0.tgz", + "integrity": "sha512-mqn0kFRl0EoqhnL0GQ0veqFHyIN1yig9RHh/InzORTUiZHFRAur+aMtRkELNwGs9aNwKS6tg/An4NYBPGwvtzQ==" + }, "node_modules/prop-types": { "version": "15.8.1", "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", @@ -2263,6 +2459,11 @@ "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" }, + "node_modules/quick-format-unescaped": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/quick-format-unescaped/-/quick-format-unescaped-4.0.4.tgz", + "integrity": "sha512-tYC1Q1hgyRuHgloV/YXs2w15unPVh8qfu/qCTfhTYamaw7fyhumKa2yGpdSo87vY32rIclj+4fWYQXUMs9EHvg==" + }, "node_modules/react": { "version": "17.0.2", "resolved": "https://registry.npmjs.org/react/-/react-17.0.2.tgz", @@ -2458,6 +2659,29 @@ } } }, + "node_modules/readable-stream": { + "version": "4.5.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.5.2.tgz", + "integrity": "sha512-yjavECdqeZ3GLXNgRXgeQEdz9fvDDkNKyHnbHRFtOr7/LcfgBcmct7t/ET+HaCTqfh06OzoAxrkN/IfjJBVe+g==", + "dependencies": { + "abort-controller": "^3.0.0", + "buffer": "^6.0.3", + "events": "^3.3.0", + "process": "^0.11.10", + "string_decoder": "^1.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, + "node_modules/real-require": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/real-require/-/real-require-0.2.0.tgz", + "integrity": "sha512-57frrGM/OCTLqLOAh0mhVA9VBMHd+9U7Zb2THMGdBUoZVOtGbJzjxsYGDJ3A9AYYCP4hn6y1TVbaOfzWtm5GFg==", + "engines": { + "node": ">= 12.13.0" + } + }, "node_modules/regenerator-runtime": { "version": "0.14.0", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.0.tgz", @@ -2489,7 +2713,6 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", - "peer": true, "engines": { "node": ">=4" } @@ -2508,6 +2731,33 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/safe-stable-stringify": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.4.3.tgz", + "integrity": "sha512-e2bDA2WJT0wxseVd4lsDP4+3ONX6HpMXQa1ZhFQ7SU+GjvORCmShbCMltrtIDfkYhVHrOcPtj+KhmDBdPdZD1g==", + "engines": { + "node": ">=10" + } + }, "node_modules/scheduler": { "version": "0.20.2", "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.20.2.tgz", @@ -2517,6 +2767,14 @@ "object-assign": "^4.1.1" } }, + "node_modules/sonic-boom": { + "version": "3.8.1", + "resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-3.8.1.tgz", + "integrity": "sha512-y4Z8LCDBuum+PBP3lSV7RHrXscqksve/bi0as7mhwVnBW+/wUqKT/2Kb7um8yqcFy0duYbbPxzt89Zy2nOCaxg==", + "dependencies": { + "atomic-sleep": "^1.0.0" + } + }, "node_modules/source-map": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", @@ -2534,11 +2792,27 @@ "node": ">=0.10.0" } }, + "node_modules/split2": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz", + "integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==", + "engines": { + "node": ">= 10.x" + } + }, "node_modules/ssr-window": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/ssr-window/-/ssr-window-4.0.2.tgz", "integrity": "sha512-ISv/Ch+ig7SOtw7G2+qkwfVASzazUnvlDTwypdLoPoySv+6MqlOV10VwPSE6EWkGjhW50lUmghPmpYZXMu/+AQ==" }, + "node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, "node_modules/style-value-types": { "version": "4.1.4", "resolved": "https://registry.npmjs.org/style-value-types/-/style-value-types-4.1.4.tgz", @@ -2576,7 +2850,6 @@ "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "peer": true, "dependencies": { "has-flag": "^3.0.0" }, @@ -2619,6 +2892,14 @@ "node": ">= 4.7.0" } }, + "node_modules/thread-stream": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-2.7.0.tgz", + "integrity": "sha512-qQiRWsU/wvNolI6tbbCKd9iKaTnCXsTwVxhhKM6nctPdujTyztjlbUkUTUymidWcMnZ5pWR0ej4a0tjsW021vw==", + "dependencies": { + "real-require": "^0.2.0" + } + }, "node_modules/tiny-invariant": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.3.1.tgz", diff --git a/next/package.json b/next/package.json index 47c38c15..f534b172 100644 --- a/next/package.json +++ b/next/package.json @@ -8,7 +8,7 @@ "scripts": { "dev": "next dev", "build": "next build", - "start": "next start" + "start": "NODE_OPTIONS='-r next-logger' next start" }, "dependencies": { "@chakra-ui/icons": "^1.1.7", @@ -23,6 +23,7 @@ "fuzzy-search": "^3.2.1", "js-cookie": "^3.0.5", "next": "^12.3.4", + "next-logger": "4.0.0", "react": "^17.0.2", "react-dom": "^17.0.2", "react-image-crop": "^11.0.4", diff --git a/next/pages/api/user/getIdUser.js b/next/pages/api/user/getIdUser.js index 85ba94dc..ce46cfab 100644 --- a/next/pages/api/user/getIdUser.js +++ b/next/pages/api/user/getIdUser.js @@ -9,8 +9,8 @@ async function getIdUser(email) { data: { query: ` mutation { authToken (input: { email: "${process.env.BACKEND_AUTH_EMAIL.trim()}", password: "${process.env.BACKEND_AUTH_PASSWORD.trim()}" }) { token } }` } }) - if(token?.data.errors) return ({status: "err_getId_0"}) - if(token?.data?.data?.authToken === null) return ({status: "err_getId_1"}) + if(token?.data.errors) return ({status: "err_get_0", errors: token.data.errors[0].message}) + if(token?.data?.data?.authToken === null) return ({status: "err_get_1"}) try { const res = await axios({ @@ -20,10 +20,10 @@ async function getIdUser(email) { Authorization: `Bearer ${token.data.data.authToken.token}` }, data: { - query: `query { allAccount (email: "${email}") {edges{node{id}}} }` + query: `query { allAccount (email: "${email}") {edges{node{ id, isActive }}} }` } }) - if(res?.data?.errors) return {status: "err_getId_2"} + if(res?.data?.errors) return {status: "err_get_2", errors: res.data.errors[0].message} const data = res.data return data } catch (error) { @@ -35,9 +35,9 @@ async function getIdUser(email) { export default async function handler(req, res) { const result = await getIdUser(atob(req.query.p)) - if(result?.status === "err_getId_0") return res.status(500).json({error: true}) - if(result?.status === "err_getId_1") return res.status(500).json({error: true}) - if(result?.status === "err_getId_2") return res.status(500).json({error: true}) + if(result?.status === "err_get_0") return res.status(500).json({error: result.errors}) + if(result?.status === "err_get_1") return res.status(500).json({error: "Erro na geração do token"}) + if(result?.status === "err_get_2") return res.status(500).json({error: result.errors}) if(result.errors) return res.status(500).json({error: result.errors}) if(result === "err") return res.status(500).json({error: "err"}) diff --git a/next/pages/dataset/index.js b/next/pages/dataset/index.js index f98ae107..dd73803d 100644 --- a/next/pages/dataset/index.js +++ b/next/pages/dataset/index.js @@ -94,7 +94,43 @@ export default function SearchPage() { const [pageInfo, setPageInfo] = useState({page: 0, count: 0}) const [isLoading, setIsLoading] = useState(true) - // const [order, setOrder] = useState("score") + useEffect(() => { + if(fetchApi) clearTimeout(fetchApi) + setIsLoading(true) + setCount(0) + setShowEmptyState(false) + + const fetchFunc = setTimeout(() => { + getDatasets({ + q: query?.q === undefined ? "" : query?.q || "", + filters: fetchFilter(query), + page: query?.page || 1 + }) + }, 1000) + + setSelectedFilters(fetchFilter(query)) + setFetchApi(fetchFunc) + }, [query]) + + async function handleSearch (value) { + let newQuery = {...query} + if (value) value.replace(/\s+/g, ' ').trim() + if (newQuery.page) delete newQuery?.page + if (value === "") { + delete newQuery?.q + router.push({ + pathname: router.pathname, + query: {...newQuery} + }) + } else { + triggerGAEvent("search", value) + triggerGAEvent("search_dataset", value) + router.push({ + pathname: router.pathname, + query: {...newQuery, q: value } + }) + } + } async function getDatasets({q, filters, page}) { const res = await getSearchDatasets({q:q, filter: filters, page:page}) @@ -119,7 +155,7 @@ export default function SearchPage() { result.push(arr[i]) } } - + return result } @@ -136,24 +172,6 @@ export default function SearchPage() { return flattenArray(objQuery) } - useEffect(() => { - if(fetchApi) clearTimeout(fetchApi) - setIsLoading(true) - setCount(0) - setShowEmptyState(false) - - const fetchFunc = setTimeout(() => { - getDatasets({ - q: query?.q, - filters: fetchFilter(query), - page: query?.page || 1 - }) - }, 1000) - - setSelectedFilters(fetchFilter(query)) - setFetchApi(fetchFunc) - }, [query]) - const handleSelectFilter = (elm) => { const newArray = [...selectedFilters] const indice = newArray.findIndex(arr => arr[0] === elm[0] && arr[1] === elm[1]) @@ -193,8 +211,8 @@ export default function SearchPage() { router.push({ pathname: router.pathname, query: { - q: query.q, - ...queryParams || "", + ...(query.q ? { q: query.q } : {}), + ...(queryParams || {}), page: 1 } }) @@ -347,31 +365,6 @@ export default function SearchPage() { ) } - const SearchQuery = (value) => { - if(value) { - triggerGAEvent("search", value) - triggerGAEvent("search_dataset", value) - } - if(query.page && value === undefined || "") { - router.push({ - pathname: router.pathname, - query: {...query, page: value !== query.q ? 1 : query.page} - }) - } - if(value || value === "" && query.page === undefined) { - router.push({ - pathname: router.pathname, - query: {...query, q: value} - }) - } - if(value || value === "" && query.page) { - router.push({ - pathname: router.pathname, - query: {...query, q: value, page: value !== query.q ? 1 : query.page } - }) - } - } - const validateActiveFilterAccordin = (text) => { return selectedFilters.map((elm) => elm[0] === text).find(res => res === true) } @@ -474,8 +467,8 @@ export default function SearchPage() { { SearchQuery(value) }} + value={query?.q || ""} + onChange={(value) => handleSearch(value)} placeholder={isMobileMod() ? "Palavras-chave, instituições ou temas" :"Pesquise palavras-chave, instituições ou temas"} justifyContent="center" inputStyle={{ @@ -612,96 +605,6 @@ export default function SearchPage() { onChange={(value) => handleSelectFilter(["tag",`${value}`])} /> - {/* 0} - styleChildren={{ - marginLeft:"16px !important", - width:"95%" - }} - > - - 0} - choices={[...spatialCoverages.continent]} - values={paramFilters.spatial_coverage} - valueField="name" - displayField="displayName" - fieldName="Continente" - onChange={(values) => - setParamFilters({ ...paramFilters, spatial_coverage: values }) - } - /> - - 0} - choices={[...spatialCoverages.country]} - values={paramFilters.spatial_coverage} - valueField="name" - displayField="displayName" - fieldName="País" - onChange={(values) => - setParamFilters({ ...paramFilters, spatial_coverage: values }) - } - /> - - 0} - choices={[...spatialCoverages.admin1]} - values={paramFilters.spatial_coverage} - valueField="name" - displayField="displayName" - fieldName="UF" - onChange={(values) => - setParamFilters({ ...paramFilters, spatial_coverage: values }) - } - /> - - Filter null - 0} - choices={[...spatialCoverages.admin2]} - values={paramFilters.spatial_coverage} - valueField="name" - displayField="displayName" - fieldName="Município" - onChange={(values) => - setParamFilters({ ...paramFilters, spatial_coverage: values }) - } - /> - - - - 0} - fieldName="Cobertura temporal" - minValue={(paramFilters.temporal_coverage || [])[0]} - maxValue={ - (paramFilters.temporal_coverage || [])[ - (paramFilters.temporal_coverage || []).length - 1 - ] - } - onChange={(val) => { - if (val.min < 0 || !val.min || val.max < 0 || !val.max || val.min > val.max) - return; - - const start = parseInt(Math.max(val.min, 0)); - const range = - Math.max((val.max - val.min), 0) + 1; - - setParamFilters({ - ...paramFilters, - temporal_coverage: new Array(range) - .fill(0) - .map((_, i) => start + i), - }); - }} - /> */ - handleSelectFilter(["observation_level",`${value}`])} /> - - /* 0} - choices={updateFrequencies} - values={paramFilters.update_frequency} - valueField="name" - displayField="displayName" - fieldName="Frequência de atualização" - onChange={(values) => - setParamFilters({ ...paramFilters, update_frequency: values }) - } - /> - - 0} - choices={rawQualityTiers} - values={paramFilters.raw_quality_tier} - valueField="name" - displayField="displayName" - fieldName="Qualidade da fonte original" - onChange={(values) => - setParamFilters({ ...paramFilters, raw_quality_tier: values }) - } - /> */} {count ? - `${count} conjunto${count > 1 ? "s": ""} encontrado${count > 1 ? "s": ""} para ${query.q}` + `${count} conjunto${count > 1 ? "s": ""} encontrado${count > 1 ? "s": ""} ${!!query.q ? ` para ${query.q}` : ""}` : - encontrando conjuntos {query.q ? ` para ${query.q}` : ""} + encontrando conjuntos {!!query.q ? ` para ${query.q}` : ""} } } - {/* Tags container */} - {/* - {Object.entries(paramFilters) - .filter(([k, v]) => v.length > 0) - .map(([k, values]) => ( - - ))} - */} - - {/* Order container */} - {/* - - Ordenar: - - - */} - ); -} \ No newline at end of file +} + +/** + * Next-Logger Setup, + * a.k.a force dependency injection. + * Beware, as it works only with Next.js 12. + * - https://stackoverflow.com/questions/71422446 + * - https://github.com/sainsburys-tech/next-logger/issues/13 + */ +export const config = { + unstable_includeFiles: [ + // package + "next-logger", + // dependencies + "pino", + "cosmiconfig", + "path-type", + "parse-json", + "error-ex", + "is-arrayish", + "json-parse-even-better-errors", + "lines-and-columns", + "@babel/code-frame", + "@babel/highlight", + "js-tokens", + "@babel/helper-validator-identifier", + "chalk", + "ansi-styles", + "color-convert", + "color-name", + "supports-color", + "has-flag", + "pino-std-serializers", + "fast-redact", + "quick-format-unescaped", + "sonic-boom", + "atomic-sleep", + "on-exit-leak-free", + "thread-stream", + "safe-stable-stringify", + ].map( + (dep) => `node_modules/${dep}/**/*.+(js|json)` + ), +}; diff --git a/next/pages/user/login.js b/next/pages/user/login.js index 52669e79..73682555 100644 --- a/next/pages/user/login.js +++ b/next/pages/user/login.js @@ -5,6 +5,7 @@ import { FormLabel, FormErrorMessage, } from "@chakra-ui/react"; +import axios from "axios"; import { useState } from "react"; import { useRouter } from "next/router"; import cookies from 'js-cookie'; @@ -60,7 +61,19 @@ export default function Login() { async function fetchToken({ email, password }) { const result = await fetch(`/api/user/getToken?a=${btoa(email)}&q=${btoa(password)}`, {method: "GET"}) .then(res => res.json()) - if(result.error) return setErrors({login:"E-mail ou senha incorretos."}) + if(result.error) { + const hasActive = await fetch(`/api/user/getIdUser?p=${btoa(email)}`, {method: "GET"}) + .then(res => res.json()) + if(hasActive.isActive === false) { + const reg = new RegExp("(?<=:).*") + const [ id ] = reg.exec(hasActive.id) + + sessionStorage.setItem('registration_email_bd', `${email}`) + await axios.post(`${process.env.NEXT_PUBLIC_API_URL}/account/account_activate/${btoa(id)}/`) + return window.open("/user/check-email?e=1", "_self") + } + return setErrors({login:"E-mail ou senha incorretos."}) + } const userData = await fetch(`/api/user/getUser?p=${btoa(result.id)}`, {method: "GET"}) .then(res => res.json())