diff --git a/.depcheckrc b/.depcheckrc index a8f326f0..642efeac 100644 --- a/.depcheckrc +++ b/.depcheckrc @@ -1 +1 @@ -ignores: [ "@graphql-codegen/client-preset", "@graphql-typed-document-node/core", "@ianvs/prettier-plugin-sort-imports", "jest-environment-jsdom", "react-dom", "terraso-client-shared", "terraso-backend" ] +ignores: [ "@graphql-codegen/cli", "@graphql-codegen/client-preset", "@graphql-typed-document-node/core", "@ianvs/prettier-plugin-sort-imports", "jest-environment-jsdom", "react-dom", "terraso-client-shared", "terraso-backend" ] diff --git a/package-lock.json b/package-lock.json index 8f20a564..7f9962ac 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,12 +8,12 @@ "name": "terraso-client-shared", "version": "0.1.0", "dependencies": { - "@reduxjs/toolkit": "^1.9.5", + "@reduxjs/toolkit": "^1.9.6", "jwt-decode": "^3.1.2", "lodash": "^4.17.21", "react": "^18.2.0", "react-redux": "^8.1.2", - "terraso-backend": "github:techmatters/terraso-backend#4170565", + "terraso-backend": "github:techmatters/terraso-backend#4929e5f", "uuid": "^9.0.0" }, "devDependencies": { @@ -24,14 +24,14 @@ "@graphql-codegen/cli": "^5.0.0", "@graphql-codegen/client-preset": "^4.1.0", "@ianvs/prettier-plugin-sort-imports": "^4.1.0", - "@testing-library/jest-dom": "^6.1.2", + "@testing-library/jest-dom": "^6.1.3", "@testing-library/react": "^14.0.0", - "@types/jest-axe": "^3.5.5", + "@types/jest-axe": "^3.5.6", "@types/lodash": "^4.14.197", "@types/uuid": "^9.0.2", "@typescript-eslint/parser": "^6.5.0", "babel-plugin-root-import": "^6.6.0", - "depcheck": "^1.4.3", + "depcheck": "^1.4.6", "eslint-config-prettier": "^9.0.0", "eslint-config-react-app": "^7.0.1", "eslint-plugin-lodash-fp": "^2.2.0-a1", @@ -41,7 +41,7 @@ "jest-environment-jsdom": "^29.6.4", "prettier": "^3.0.3", "ts-jest": "^29.1.1", - "typescript": "^5.1.6", + "typescript": "^5.2.2", "whatwg-fetch": "^3.6.19" } }, @@ -4285,9 +4285,9 @@ "dev": true }, "node_modules/@reduxjs/toolkit": { - "version": "1.9.5", - "resolved": "https://registry.npmjs.org/@reduxjs/toolkit/-/toolkit-1.9.5.tgz", - "integrity": "sha512-Rt97jHmfTeaxL4swLRNPD/zV4OxTes4la07Xc4hetpUW/vc75t5m1ANyxG6ymnEQ2FsLQsoMlYB2vV1sO3m8tQ==", + "version": "1.9.6", + "resolved": "https://registry.npmjs.org/@reduxjs/toolkit/-/toolkit-1.9.6.tgz", + "integrity": "sha512-Gc4ikl90ORF4viIdAkY06JNUnODjKfGxZRwATM30EdHq8hLSVoSrwXne5dd739yenP5bJxAX7tLuOWK5RPGtrw==", "dependencies": { "immer": "^9.0.21", "redux": "^4.2.1", @@ -4363,9 +4363,9 @@ } }, "node_modules/@testing-library/jest-dom": { - "version": "6.1.2", - "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-6.1.2.tgz", - "integrity": "sha512-NP9jl1Q2qDDtx+cqogowtQtmgD2OVs37iMSIsTv5eN5ETRkf26Kj6ugVwA93/gZzzFWQAsgkKkcftDe91BJCkQ==", + "version": "6.1.3", + "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-6.1.3.tgz", + "integrity": "sha512-YzpjRHoCBWPzpPNtg6gnhasqtE/5O4qz8WCwDEaxtfnPO6gkaLrnuXusrGSPyhIGPezr1HM7ZH0CFaUTY9PJEQ==", "dev": true, "dependencies": { "@adobe/css-tools": "^4.3.0", @@ -4543,9 +4543,9 @@ } }, "node_modules/@types/jest-axe": { - "version": "3.5.5", - "resolved": "https://registry.npmjs.org/@types/jest-axe/-/jest-axe-3.5.5.tgz", - "integrity": "sha512-b8WDIdoeKtr/JDJ2+QjFXMuS8UhfdMA6+15Z5KjjIie3jQrSXD9KZWMSQxc0nPtx7L9rIFKdiDpQk+m7s4a/8w==", + "version": "3.5.6", + "resolved": "https://registry.npmjs.org/@types/jest-axe/-/jest-axe-3.5.6.tgz", + "integrity": "sha512-dQyD3XWfB+wUqVqWwGDyW4j7NmLyWWOdFeNIGXl01HR8/n8LeP3BtQTFdygHtInDm/EYKizaNprhgjSr8sPxHA==", "dev": true, "dependencies": { "@types/jest": "*", @@ -5819,6 +5819,7 @@ "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", "dev": true, + "optional": true, "engines": { "node": ">=8" } @@ -6005,6 +6006,15 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/callsite": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/callsite/-/callsite-1.0.0.tgz", + "integrity": "sha512-0vdNRFXn5q+dtOqjfFtmtlI9N2eVZ7LMyEV2iKC5mEEFvSg/69Ml6b/WU2qF8W1nLRa0wiSrDT3Y5jOHZCwKPQ==", + "dev": true, + "engines": { + "node": "*" + } + }, "node_modules/callsites": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", @@ -6144,6 +6154,7 @@ "url": "https://paulmillr.com/funding/" } ], + "optional": true, "dependencies": { "anymatch": "~3.1.2", "braces": "~3.0.2", @@ -6165,6 +6176,7 @@ "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", "dev": true, + "optional": true, "dependencies": { "is-glob": "^4.0.1" }, @@ -6793,18 +6805,20 @@ } }, "node_modules/depcheck": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/depcheck/-/depcheck-1.4.3.tgz", - "integrity": "sha512-vy8xe1tlLFu7t4jFyoirMmOR7x7N601ubU9Gkifyr9z8rjBFtEdWHDBMqXyk6OkK+94NXutzddVXJuo0JlUQKQ==", + "version": "1.4.6", + "resolved": "https://registry.npmjs.org/depcheck/-/depcheck-1.4.6.tgz", + "integrity": "sha512-Jxy9+u1DE+Svj2N0V/ueEQiOgH2X3KRPAsBfM0m/vCtuiG5QSC//b1mt0rbN/u3BFFEzXqpHzYiwDjmvAydEsw==", "dev": true, "dependencies": { - "@babel/parser": "7.16.4", - "@babel/traverse": "^7.12.5", + "@babel/parser": "7.22.5", + "@babel/traverse": "7.22.5", "@vue/compiler-sfc": "^3.0.5", + "callsite": "^1.0.0", "camelcase": "^6.2.0", "cosmiconfig": "^7.0.0", "debug": "^4.2.0", "deps-regex": "^0.1.4", + "findup-sync": "^5.0.0", "ignore": "^5.1.8", "is-core-module": "^2.4.0", "js-yaml": "^3.14.0", @@ -6813,12 +6827,10 @@ "minimatch": "^3.0.4", "multimatch": "^5.0.0", "please-upgrade-node": "^3.2.0", - "query-ast": "^1.0.3", "readdirp": "^3.5.0", "require-package-name": "^2.0.1", "resolve": "^1.18.1", - "sass": "^1.29.0", - "scss-parser": "^1.0.4", + "resolve-from": "^5.0.0", "semver": "^7.3.2", "yargs": "^16.1.0" }, @@ -6830,9 +6842,9 @@ } }, "node_modules/depcheck/node_modules/@babel/parser": { - "version": "7.16.4", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.16.4.tgz", - "integrity": "sha512-6V0qdPUaiVHH3RtZeLIsc+6pDhbYzHR8ogA8w+f+Wc77DuXto19g2QUwveINoS34Uw+W8/hQDGJCx+i4n7xcng==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.22.5.tgz", + "integrity": "sha512-DFZMC9LJUG9PLOclRC32G63UXwzqS2koQC8dkx+PLdmt1xSePYpbT/NbsrJy8Q/muXz7o/h/d4A7Fuyixm559Q==", "dev": true, "bin": { "parser": "bin/babel-parser.js" @@ -6841,6 +6853,27 @@ "node": ">=6.0.0" } }, + "node_modules/depcheck/node_modules/@babel/traverse": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.22.5.tgz", + "integrity": "sha512-7DuIjPgERaNo6r+PZwItpjCZEa5vyw4eJGufeLxrPdBXBoLcCJCIasvK6pK/9DVNrLZTLFhUGqaC6X/PA007TQ==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.22.5", + "@babel/generator": "^7.22.5", + "@babel/helper-environment-visitor": "^7.22.5", + "@babel/helper-function-name": "^7.22.5", + "@babel/helper-hoist-variables": "^7.22.5", + "@babel/helper-split-export-declaration": "^7.22.5", + "@babel/parser": "^7.22.5", + "@babel/types": "^7.22.5", + "debug": "^4.1.0", + "globals": "^11.1.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, "node_modules/depcheck/node_modules/argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", @@ -6961,6 +6994,15 @@ "node": ">=6" } }, + "node_modules/detect-file": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/detect-file/-/detect-file-1.0.0.tgz", + "integrity": "sha512-DtCOLG98P007x7wiiOmfI0fi3eIKyWiLTGJ2MDnVi/E04lWGbf+JzrRHMm0rgIIZJGtHpKpbVgLWHrv8xXpc3Q==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/detect-indent": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-6.1.0.tgz", @@ -8004,6 +8046,18 @@ "node": ">= 0.8.0" } }, + "node_modules/expand-tilde": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-2.0.2.tgz", + "integrity": "sha512-A5EmesHW6rfnZ9ysHQjPdJRni0SRar0tjtG5MNtm9n5TUvsYU8oozprtRD4AqHxcZWWlVuAmQo2nWKfN9oyjTw==", + "dev": true, + "dependencies": { + "homedir-polyfill": "^1.0.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/expect": { "version": "29.6.4", "resolved": "https://registry.npmjs.org/expect/-/expect-29.6.4.tgz", @@ -8240,6 +8294,21 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/findup-sync": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-5.0.0.tgz", + "integrity": "sha512-MzwXju70AuyflbgeOhzvQWAvvQdo1XL0A9bVvlXsYcFEBM87WR4OakL4OfZq+QRmr+duJubio+UtNQCPsVESzQ==", + "dev": true, + "dependencies": { + "detect-file": "^1.0.0", + "is-glob": "^4.0.3", + "micromatch": "^4.0.4", + "resolve-dir": "^1.0.1" + }, + "engines": { + "node": ">= 10.13.0" + } + }, "node_modules/flat-cache": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz", @@ -8446,6 +8515,48 @@ "node": ">=10.13.0" } }, + "node_modules/global-modules": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-1.0.0.tgz", + "integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==", + "dev": true, + "dependencies": { + "global-prefix": "^1.0.1", + "is-windows": "^1.0.1", + "resolve-dir": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/global-prefix": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-1.0.2.tgz", + "integrity": "sha512-5lsx1NUDHtSjfg0eHlmYvZKv8/nVqX4ckFbM+FrGcQ+04KWcWFo9P5MxPZYSzUvyzmdTbI7Eix8Q4IbELDqzKg==", + "dev": true, + "dependencies": { + "expand-tilde": "^2.0.2", + "homedir-polyfill": "^1.0.1", + "ini": "^1.3.4", + "is-windows": "^1.0.1", + "which": "^1.2.14" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/global-prefix/node_modules/which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "which": "bin/which" + } + }, "node_modules/globals": { "version": "11.12.0", "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", @@ -8729,6 +8840,18 @@ "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" }, + "node_modules/homedir-polyfill": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz", + "integrity": "sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA==", + "dev": true, + "dependencies": { + "parse-passwd": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/html-encoding-sniffer": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-3.0.0.tgz", @@ -8931,6 +9054,12 @@ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "dev": true }, + "node_modules/ini": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", + "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==", + "dev": true + }, "node_modules/inquirer": { "version": "8.2.5", "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-8.2.5.tgz", @@ -9030,6 +9159,7 @@ "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", "dev": true, + "optional": true, "dependencies": { "binary-extensions": "^2.0.0" }, @@ -11623,6 +11753,15 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/parse-passwd": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", + "integrity": "sha512-1Y1A//QUXEZK7YKz+rD9WydcE1+EuPr6ZBgKecAB8tmoW6UFv0NREVJe1p+jRxtThkcbbKkfwIbWJe/IeE6m2Q==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/parse5": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.1.2.tgz", @@ -11828,9 +11967,9 @@ } }, "node_modules/postcss": { - "version": "8.4.27", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.27.tgz", - "integrity": "sha512-gY/ACJtJPSmUFPDCHtX78+01fHa64FaU4zaaWfuh1MhGJISufJAH4cun6k/8fwsHYeK4UQmENQK+tRLCFJE8JQ==", + "version": "8.4.31", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz", + "integrity": "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==", "dev": true, "funding": [ { @@ -12003,16 +12142,6 @@ "node": ">=6.0.0" } }, - "node_modules/query-ast": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/query-ast/-/query-ast-1.0.5.tgz", - "integrity": "sha512-JK+1ma4YDuLjvKKcz9JZ70G+CM9qEOs/l1cZzstMMfwKUabTJ9sud5jvDGrUNuv03yKUgs82bLkHXJkDyhRmBw==", - "dev": true, - "dependencies": { - "invariant": "2.2.4", - "lodash": "^4.17.21" - } - }, "node_modules/querystringify": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz", @@ -12343,6 +12472,19 @@ "node": ">=8" } }, + "node_modules/resolve-dir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/resolve-dir/-/resolve-dir-1.0.1.tgz", + "integrity": "sha512-R7uiTjECzvOsWSfdM0QKFNBVFcK27aHOUwdvK53BcW8zqnGdYp0Fbj82cy54+2A4P2tFM22J5kRfe1R+lM/1yg==", + "dev": true, + "dependencies": { + "expand-tilde": "^2.0.0", + "global-modules": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/resolve-from": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", @@ -12502,29 +12644,6 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "dev": true }, - "node_modules/sass": { - "version": "1.64.1", - "resolved": "https://registry.npmjs.org/sass/-/sass-1.64.1.tgz", - "integrity": "sha512-16rRACSOFEE8VN7SCgBu1MpYCyN7urj9At898tyzdXFhC+a+yOX5dXwAR7L8/IdPJ1NB8OYoXmD55DM30B2kEQ==", - "dev": true, - "dependencies": { - "chokidar": ">=3.0.0 <4.0.0", - "immutable": "^4.0.0", - "source-map-js": ">=0.6.2 <2.0.0" - }, - "bin": { - "sass": "sass.js" - }, - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/sass/node_modules/immutable": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/immutable/-/immutable-4.3.1.tgz", - "integrity": "sha512-lj9cnmB/kVS0QHsJnYKD1uo3o39nrbKxszjnqS9Fr6NB7bZzW45U6WSGBPKXDL/CvDKqDNPA4r3DoDQ8GTxo2A==", - "dev": true - }, "node_modules/saxes": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/saxes/-/saxes-6.0.0.tgz", @@ -12547,19 +12666,6 @@ "loose-envify": "^1.1.0" } }, - "node_modules/scss-parser": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/scss-parser/-/scss-parser-1.0.6.tgz", - "integrity": "sha512-SH3TaoaJFzfAtqs3eG1j5IuHJkeEW5rKUPIjIN+ZorLAyJLHItQGnsgwHk76v25GtLtpT9IqfAcqK4vFWdiw+w==", - "dev": true, - "dependencies": { - "invariant": "2.2.4", - "lodash": "4.17.21" - }, - "engines": { - "node": ">=6.0.0" - } - }, "node_modules/scuid": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/scuid/-/scuid-1.1.0.tgz", @@ -12995,7 +13101,7 @@ }, "node_modules/terraso-backend": { "version": "0.1.0", - "resolved": "git+ssh://git@github.com/techmatters/terraso-backend.git#4170565525a1b85462685d4e2c861a3cfeec7fba" + "resolved": "git+ssh://git@github.com/techmatters/terraso-backend.git#4929e5f4599cebc2f107873dd0075885c4df5e46" }, "node_modules/test-exclude": { "version": "6.0.0", @@ -13326,9 +13432,9 @@ } }, "node_modules/typescript": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.6.tgz", - "integrity": "sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==", + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", + "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", "dev": true, "bin": { "tsc": "bin/tsc", diff --git a/package.json b/package.json index 735ff04c..57e1ae84 100644 --- a/package.json +++ b/package.json @@ -6,12 +6,12 @@ "src/tests/config.ts" ], "dependencies": { - "@reduxjs/toolkit": "^1.9.5", + "@reduxjs/toolkit": "^1.9.6", "jwt-decode": "^3.1.2", "lodash": "^4.17.21", "react": "^18.2.0", "react-redux": "^8.1.2", - "terraso-backend": "github:techmatters/terraso-backend#4170565", + "terraso-backend": "github:techmatters/terraso-backend#4929e5f", "uuid": "^9.0.0" }, "scripts": { @@ -42,14 +42,14 @@ "@graphql-codegen/cli": "^5.0.0", "@graphql-codegen/client-preset": "^4.1.0", "@ianvs/prettier-plugin-sort-imports": "^4.1.0", - "@testing-library/jest-dom": "^6.1.2", + "@testing-library/jest-dom": "^6.1.3", "@testing-library/react": "^14.0.0", - "@types/jest-axe": "^3.5.5", + "@types/jest-axe": "^3.5.6", "@types/lodash": "^4.14.197", "@types/uuid": "^9.0.2", "@typescript-eslint/parser": "^6.5.0", "babel-plugin-root-import": "^6.6.0", - "depcheck": "^1.4.3", + "depcheck": "^1.4.6", "eslint-config-prettier": "^9.0.0", "eslint-config-react-app": "^7.0.1", "eslint-plugin-lodash-fp": "^2.2.0-a1", @@ -59,7 +59,7 @@ "jest-environment-jsdom": "^29.6.4", "prettier": "^3.0.3", "ts-jest": "^29.1.1", - "typescript": "^5.1.6", + "typescript": "^5.2.2", "whatwg-fetch": "^3.6.19" }, "jest": { diff --git a/src/account/accountSlice.ts b/src/account/accountSlice.ts index 439eaeda..cf24b752 100644 --- a/src/account/accountSlice.ts +++ b/src/account/accountSlice.ts @@ -114,6 +114,10 @@ export const userSlice = createSlice({ setUsers: (state, { payload: users }) => { Object.assign(state.users, users); }, + + addUser: (state, { payload: user }) => { + state.users[user.id] = user; + }, }, extraReducers: builder => { @@ -265,7 +269,7 @@ export const userSlice = createSlice({ }, }); -export const { setUser, setHasToken } = userSlice.actions; +export const { setUser, setHasToken, addUser } = userSlice.actions; export default userSlice.reducer; diff --git a/src/project/projectService.ts b/src/project/projectService.ts index e59bc794..91a3dd5f 100644 --- a/src/project/projectService.ts +++ b/src/project/projectService.ts @@ -19,6 +19,7 @@ import type { User } from 'terraso-client-shared/account/accountSlice'; import { graphql } from 'terraso-client-shared/graphqlSchema'; import type { ProjectAddMutationInput, + ProjectAddUserMutationInput, ProjectArchiveMutationInput, ProjectDataFragment, ProjectDeleteMutationInput, @@ -201,3 +202,22 @@ export const archiveProject = (project: ProjectArchiveMutationInput) => { }) .then(_ => project.archived); }; + +export const addUserToProject = (input: ProjectAddUserMutationInput) => { + const command = graphql(` + mutation addUserToProject($input: ProjectAddUserMutationInput!) { + addUserToProject(input: $input) { + errors + project { + id + } + membership { + ...projectMembershipFields + } + } + } + `); + return terrasoApi + .requestGraphQL(command, { input }) + .then(output => output.addUserToProject); +}; diff --git a/src/project/projectSlice.ts b/src/project/projectSlice.ts index 48c73cfa..a3d439f1 100644 --- a/src/project/projectSlice.ts +++ b/src/project/projectSlice.ts @@ -16,8 +16,15 @@ */ import { createAction, createSlice } from '@reduxjs/toolkit'; -import { setUsers, User } from 'terraso-client-shared/account/accountSlice'; -import { UserRole } from 'terraso-client-shared/graphqlSchema/graphql'; +import { + addUser, + setUsers, + User, +} from 'terraso-client-shared/account/accountSlice'; +import { + ProjectAddUserMutationInput, + UserRole, +} from 'terraso-client-shared/graphqlSchema/graphql'; import * as projectService from 'terraso-client-shared/project/projectService'; import { setSites, Site } from 'terraso-client-shared/site/siteSlice'; import { @@ -122,6 +129,24 @@ export const archiveProject = createAsyncThunk( projectService.archiveProject, ); +export const addUserToProject = createAsyncThunk< + ProjectMembership, + ProjectAddUserMutationInput +>('project/addUser', async (input, _, { dispatch }) => { + const res = await projectService.addUserToProject(input); + // TODO: Should make user required in future! + // https://github.com/techmatters/terraso-backend/issues/859 + if (res.membership.user === undefined || res.membership.user === null) { + throw Error(`Membership ${res.membership.id} created without user!`); + } + dispatch(addUser(res.membership.user)); + return { + userId: res.membership.user.id, + userRole: res.membership.userRole, + id: res.membership.id, + }; +}); + const projectSlice = createSlice({ name: 'project', initialState, @@ -189,6 +214,17 @@ const projectSlice = createSlice({ state.projects[meta.arg.id].archived = archived; }, ); + + builder.addCase( + addUserToProject.fulfilled, + (state, { meta, payload: { id: membershipId, userRole, userId } }) => { + state.projects[meta.arg.projectId].memberships[membershipId] = { + id: membershipId, + userRole, + userId, + }; + }, + ); }, }); diff --git a/tsconfig.json b/tsconfig.json index 98c7dcdb..0f625637 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,7 +4,7 @@ "compilerOptions": { "lib": ["dom", "dom.iterable", "esnext"], - "module": "esnext", + "module": "node16", "target": "es2015", "allowJs": false,