From 846825db9c49f4e6ed37dd844e247a83946e8d71 Mon Sep 17 00:00:00 2001 From: bharateshwq Date: Mon, 7 Oct 2024 23:10:18 +0530 Subject: [PATCH 1/7] Setup React query --- src/QueryCover.jsx | 11 ++++ src/hooks/useMetadata.js | 34 +++++++++++ src/hooks/usePolicy.js | 98 ++++++++++++++++++++++++++++++++ src/hooks/useUserProfile.js | 66 +++++++++++++++++++++ src/index.js | 5 +- src/pages/policy/output/utils.js | 21 +++++++ 6 files changed, 234 insertions(+), 1 deletion(-) create mode 100644 src/QueryCover.jsx create mode 100644 src/hooks/useMetadata.js create mode 100644 src/hooks/usePolicy.js create mode 100644 src/hooks/useUserProfile.js diff --git a/src/QueryCover.jsx b/src/QueryCover.jsx new file mode 100644 index 000000000..d007f6ec4 --- /dev/null +++ b/src/QueryCover.jsx @@ -0,0 +1,11 @@ +import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; +import React from "react"; + +const QueryCover = ({ children }) => { + const queryClient = new QueryClient(); + return ( + {children} + ); +}; + +export default QueryCover; diff --git a/src/hooks/useMetadata.js b/src/hooks/useMetadata.js new file mode 100644 index 000000000..e69bf449a --- /dev/null +++ b/src/hooks/useMetadata.js @@ -0,0 +1,34 @@ +import { useQuery } from "@tanstack/react-query"; +import { updateMetadata } from "../api/call"; +import { extractCountryId } from "../pages/policy/output/utils"; + +const useMetadata = () => { + const countryId = extractCountryId(); + + // Update the metadata state when something happens to + // the countryId (e.g. the user changes the country). + + // If we're accessing the page without a country ID, + // our router will handle redirecting to a country ID; + // this process is guaranteed, thus we will just not fetch + // in this situation + const queryResult = useQuery({ + queryKey: ["metadata", countryId], + queryFn: () => updateMetadata(countryId), + onError: (e) => { + console.error(e); + }, + enabled: !!countryId, + }); + + // Create a new object and return it + return { + isMetadataLoading: queryResult.isPending, + metadata: queryResult.data, + isMetadataError: queryResult.isError, + metadataError: queryResult.error, + isMetadataSuccess: queryResult.isSuccess, + }; +}; + +export default useMetadata; diff --git a/src/hooks/usePolicy.js b/src/hooks/usePolicy.js new file mode 100644 index 000000000..99f7f362b --- /dev/null +++ b/src/hooks/usePolicy.js @@ -0,0 +1,98 @@ +import { useQuery, useQueryClient } from "@tanstack/react-query"; +import { copySearchParams, countryApiCall } from "../api/call"; +import { COUNTRY_BASELINE_POLICIES, COUNTRY_CODES } from "../data/countries"; +import { useSearchParams } from "react-router-dom"; +import useMetadata from "./useMetadata"; +import { extractCountryId } from "../pages/policy/output/utils"; +async function getPolicy({ queryKey }) { + const [, countryId, policyId] = queryKey; + try { + const response = await countryApiCall(countryId, `/policy/${policyId}`); + const dataHolder = await response.json(); + + if (dataHolder.result.label === "None") { + dataHolder.result.label = null; + } + + return { + data: dataHolder.result.policy_json, + label: dataHolder.result.label, + id: policyId, + }; + } catch (error) { + console.error("Error fetching policy:", error); + throw error; // Rethrow to allow react-query to handle it + } +} +const usePolicy = () => { + const countryId = extractCountryId(); + const [searchParams, setSearchParams] = useSearchParams(); + const queryClient = useQueryClient(); + const { isMetadataSuccess } = useMetadata(); + + const defaultBaselinePolicy = COUNTRY_CODES.includes(countryId) + ? COUNTRY_BASELINE_POLICIES[countryId] + : 1; + const reformPolicyId = searchParams.get("reform") || defaultBaselinePolicy; + const baselinePolicyId = + searchParams.get("baseline") || defaultBaselinePolicy; + + const { + isPending: isBaselinePolicyLoading, + data: baselinePolicy, + isError: isBaselineError, + error: baseLineError, + } = useQuery({ + queryKey: ["policy", countryId, baselinePolicyId], + queryFn: getPolicy, + onSuccess: (baselinePolicy) => { + policy.baseline = baselinePolicy; + }, + enabled: isMetadataSuccess, + }); + const { + isPending: isReformPolicyLoading, + data: reformPolicy, + isError: isReformError, + error: reformError, + refetch, + } = useQuery({ + queryKey: ["policy", countryId, reformPolicyId], + queryFn: getPolicy, + onSuccess: (reformPolicy) => { + policy.reform = reformPolicy; + }, + enabled: isMetadataSuccess, + }); + // Check for the "renamed" search parameter + const isRenamed = searchParams.get("renamed"); + + //TODO call refetch instead of this logic + // Invalidate and refetch when "renamed" is found + if (isRenamed) { + console.log("renamed query"); + + queryClient.invalidateQueries(["policy", countryId, reformPolicyId]); + // Optionally, you can remove the "renamed" parameter here if desired + let newSearch = copySearchParams(searchParams); + newSearch.delete("renamed"); + setSearchParams(newSearch); + } + const policy = { + baseline: baselinePolicy || { + id: baselinePolicyId, + label: null, + data: null, + }, + reform: reformPolicy || { id: reformPolicyId, label: null, data: null }, + }; + return { + isPolicyLoading: isBaselinePolicyLoading || isReformPolicyLoading, + isPolicyError: isBaselineError || isReformError, + error: baseLineError || reformError, + policy, + refetchReformPolicy: refetch, + }; +}; + +export default usePolicy; diff --git a/src/hooks/useUserProfile.js b/src/hooks/useUserProfile.js new file mode 100644 index 000000000..d5c49cc00 --- /dev/null +++ b/src/hooks/useUserProfile.js @@ -0,0 +1,66 @@ +import { useQuery } from "@tanstack/react-query"; +import { apiCall } from "../api/call"; +import { useAuth0 } from "@auth0/auth0-react"; +import { extractCountryId } from "../pages/policy/output/utils"; + +const fetchUserProfile = async (countryId, isAuthenticated, userSub) => { + const USER_PROFILE_PATH = `/${countryId}/user_profile`; + + try { + const resGet = await apiCall(USER_PROFILE_PATH + `?auth0_id=${userSub}`); + const resGetJson = await resGet.json(); + + if (resGet.status === 200) { + return resGetJson.result; + } else if (resGet.status === 404 && resGetJson.status === "ok") { + // If not, create user first, then fetch user + const body = { + auth0_id: userSub, + primary_country: countryId, + user_since: Date.now(), + }; + const resPost = await apiCall(USER_PROFILE_PATH, body, "POST"); + const resPostJson = await resPost.json(); + if (resPost.status !== 201) { + throw new Error( + `Error while trying to create new user with auth0_id ${userSub} : ${resPostJson}`, + ); + } else { + return resPostJson.result; + } + } else { + throw new Error( + `Error while attempting to fetch user profile for user ${userSub} : ${resGetJson}`, + ); + } + } catch (error) { + console.log(error); + throw new Error( + `Connection error while attempting to fetch user profile for user ${userSub}: ${error}`, + ); + } +}; + +const useUserProfile = () => { + const { isAuthenticated, user } = useAuth0(); + const countryId = extractCountryId(); + + const { data, isPending, isError, refetch, error } = useQuery({ + queryKey: ["userProfile", countryId, user?.sub, isAuthenticated], + queryFn: () => fetchUserProfile(countryId, isAuthenticated, user?.sub), + enabled: isAuthenticated && !!user?.sub, + onError: (error) => { + console.error("Error fetching user profile:", error); + }, + }); + + return { + userProfile: data, + isUserProfileLoading: isPending, + isUserProfileError: isError, + userProfileError: error, + userProfileRefetch: refetch, + }; +}; + +export default useUserProfile; diff --git a/src/index.js b/src/index.js index 01320b41f..9033d729d 100644 --- a/src/index.js +++ b/src/index.js @@ -8,6 +8,7 @@ import { BrowserRouter as Router } from "react-router-dom"; import loc_en_gb from "./lang/plotly_locales/locale-en-gb.js"; import loc_en_us from "./lang/plotly_locales/locale-en-us.js"; import Auth0ProviderWithNavigate from "./auth/Auth0ProviderWithNavigate.jsx"; +import QueryCover from "./QueryCover.jsx"; var Plotly = require("plotly.js/dist/plotly.js"); Plotly.register(loc_en_gb); @@ -17,7 +18,9 @@ const root = ReactDOM.createRoot(document.getElementById("root")); root.render( - + + + , ); diff --git a/src/pages/policy/output/utils.js b/src/pages/policy/output/utils.js index a093bc898..2c31ce53c 100644 --- a/src/pages/policy/output/utils.js +++ b/src/pages/policy/output/utils.js @@ -1,6 +1,7 @@ import html2canvas from "html2canvas"; import { saveAs } from "file-saver"; import { message } from "antd"; +import { COUNTRY_CODES } from "../../../data/countries"; const avgChangeDirection = (change) => change >= 0 ? "would increase" : "would decrease"; @@ -56,6 +57,25 @@ function copyLink() { navigator.clipboard.writeText(window.location.href); message.info("Link copied to clipboard"); } +function extractCountryId() { + const path = window.location.pathname; + const pathParts = path.split("/").filter((item) => item.length > 0); + + // If valid, return the normal country ID + if (pathParts.length > 0 && COUNTRY_CODES.includes(pathParts[0])) { + return pathParts[0]; + } + // If we have an invalid ID (e.g., "undefined" or "garbage"), + // the router will redirect to "us", so return that as country ID + else if (pathParts.length > 0) { + return "us"; + } + // Otherwise, we're on the standard page; return null and allow + // router to redirect + else { + return null; + } +} export { avgChangeDirection, @@ -63,4 +83,5 @@ export { downloadPng, downloadCsv, copyLink, + extractCountryId, }; From 277c50d4bb05d731d9b3d400fdc79d3180ba8448 Mon Sep 17 00:00:00 2001 From: bharateshwq Date: Mon, 7 Oct 2024 23:12:19 +0530 Subject: [PATCH 2/7] installed react query and query lint --- package-lock.json | 194 ++++++++++++++++++++++++++++++++++++++++------ package.json | 2 + 2 files changed, 171 insertions(+), 25 deletions(-) diff --git a/package-lock.json b/package-lock.json index 84061ff4b..ca6d1ea54 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "@auth0/auth0-react": "^2.2.4", "@babel/preset-react": "^7.24.7", "@n8tb1t/use-scroll-position": "^2.0.3", + "@tanstack/react-query": "^5.59.0", "@uiw/codemirror-extensions-langs": "^4.23.0", "@uiw/codemirror-theme-github": "^4.23.0", "@uiw/react-codemirror": "^4.23.0", @@ -64,6 +65,7 @@ "devDependencies": { "@babel/plugin-proposal-private-property-in-object": "^7.21.11", "@babel/preset-env": "^7.25.4", + "@tanstack/eslint-plugin-query": "^5.59.1", "@testing-library/jest-dom": "^6.5.0", "@testing-library/react": "^15.0.7", "@testing-library/user-event": "^14.5.2", @@ -5391,6 +5393,167 @@ "tslib": "^2.4.0" } }, + "node_modules/@tanstack/eslint-plugin-query": { + "version": "5.59.1", + "resolved": "https://registry.npmjs.org/@tanstack/eslint-plugin-query/-/eslint-plugin-query-5.59.1.tgz", + "integrity": "sha512-Dn4Acfy8yXL2qdEDVutgNI4tpW3iNjKbAnCbL9sZ19nnx1/xlTcxT5gXYBN0yrLTxibu7PTqg9pMPJEWKMnRJg==", + "dev": true, + "dependencies": { + "@typescript-eslint/utils": "^8.3.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0" + } + }, + "node_modules/@tanstack/eslint-plugin-query/node_modules/@typescript-eslint/scope-manager": { + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.8.0.tgz", + "integrity": "sha512-EL8eaGC6gx3jDd8GwEFEV091210U97J0jeEHrAYvIYosmEGet4wJ+g0SYmLu+oRiAwbSA5AVrt6DxLHfdd+bUg==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "8.8.0", + "@typescript-eslint/visitor-keys": "8.8.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@tanstack/eslint-plugin-query/node_modules/@typescript-eslint/types": { + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.8.0.tgz", + "integrity": "sha512-QJwc50hRCgBd/k12sTykOJbESe1RrzmX6COk8Y525C9l7oweZ+1lw9JiU56im7Amm8swlz00DRIlxMYLizr2Vw==", + "dev": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@tanstack/eslint-plugin-query/node_modules/@typescript-eslint/typescript-estree": { + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.8.0.tgz", + "integrity": "sha512-ZaMJwc/0ckLz5DaAZ+pNLmHv8AMVGtfWxZe/x2JVEkD5LnmhWiQMMcYT7IY7gkdJuzJ9P14fRy28lUrlDSWYdw==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "8.8.0", + "@typescript-eslint/visitor-keys": "8.8.0", + "debug": "^4.3.4", + "fast-glob": "^3.3.2", + "is-glob": "^4.0.3", + "minimatch": "^9.0.4", + "semver": "^7.6.0", + "ts-api-utils": "^1.3.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@tanstack/eslint-plugin-query/node_modules/@typescript-eslint/utils": { + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.8.0.tgz", + "integrity": "sha512-QE2MgfOTem00qrlPgyByaCHay9yb1+9BjnMFnSFkUKQfu7adBXDTnCAivURnuPPAG/qiB+kzKkZKmKfaMT0zVg==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "@typescript-eslint/scope-manager": "8.8.0", + "@typescript-eslint/types": "8.8.0", + "@typescript-eslint/typescript-estree": "8.8.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0" + } + }, + "node_modules/@tanstack/eslint-plugin-query/node_modules/@typescript-eslint/visitor-keys": { + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.8.0.tgz", + "integrity": "sha512-8mq51Lx6Hpmd7HnA2fcHQo3YgfX1qbccxQOgZcb4tvasu//zXRaA1j5ZRFeCw/VRAdFi4mRM9DnZw0Nu0Q2d1g==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "8.8.0", + "eslint-visitor-keys": "^3.4.3" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@tanstack/eslint-plugin-query/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@tanstack/eslint-plugin-query/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@tanstack/query-core": { + "version": "5.59.0", + "resolved": "https://registry.npmjs.org/@tanstack/query-core/-/query-core-5.59.0.tgz", + "integrity": "sha512-WGD8uIhX6/deH/tkZqPNcRyAhDUqs729bWKoByYHSogcshXfFbppOdTER5+qY7mFvu8KEFJwT0nxr8RfPTVh0Q==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + } + }, + "node_modules/@tanstack/react-query": { + "version": "5.59.0", + "resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.59.0.tgz", + "integrity": "sha512-YDXp3OORbYR+8HNQx+lf4F73NoiCmCcSvZvgxE29OifmQFk0sBlO26NWLHpcNERo92tVk3w+JQ53/vkcRUY1hA==", + "dependencies": { + "@tanstack/query-core": "5.59.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + }, + "peerDependencies": { + "react": "^18 || ^19" + } + }, "node_modules/@testing-library/dom": { "version": "10.1.0", "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.1.0.tgz", @@ -11264,9 +11427,9 @@ "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" }, "node_modules/fast-glob": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.1.tgz", - "integrity": "sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", + "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", "dependencies": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", @@ -24482,12 +24645,9 @@ } }, "node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", - "dependencies": { - "lru-cache": "^6.0.0" - }, + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", "bin": { "semver": "bin/semver.js" }, @@ -24495,22 +24655,6 @@ "node": ">=10" } }, - "node_modules/semver/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/semver/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" - }, "node_modules/send": { "version": "0.18.0", "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", diff --git a/package.json b/package.json index ff8d461e6..d53cf5a37 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "@auth0/auth0-react": "^2.2.4", "@babel/preset-react": "^7.24.7", "@n8tb1t/use-scroll-position": "^2.0.3", + "@tanstack/react-query": "^5.59.0", "@uiw/codemirror-extensions-langs": "^4.23.0", "@uiw/codemirror-theme-github": "^4.23.0", "@uiw/react-codemirror": "^4.23.0", @@ -88,6 +89,7 @@ "devDependencies": { "@babel/plugin-proposal-private-property-in-object": "^7.21.11", "@babel/preset-env": "^7.25.4", + "@tanstack/eslint-plugin-query": "^5.59.1", "@testing-library/jest-dom": "^6.5.0", "@testing-library/react": "^15.0.7", "@testing-library/user-event": "^14.5.2", From fc978cb7333dc4ebc8f183846ca77d1205da5d35 Mon Sep 17 00:00:00 2001 From: bharateshwq Date: Tue, 8 Oct 2024 00:09:31 +0530 Subject: [PATCH 3/7] implementation of query --- .eslintrc.json | 20 ++- src/Routes.jsx | 170 ++++++++++++++++++ src/pages/APIDocumentationPage.jsx | 10 +- src/pages/HouseholdPage.jsx | 6 + src/pages/PolicyPage.jsx | 1 + src/pages/UserProfilePage.jsx | 13 +- src/pages/policy/PolicyRightSidebar.jsx | 5 +- .../policy/output/FetchAndDisplayImpact.jsx | 1 + 8 files changed, 214 insertions(+), 12 deletions(-) create mode 100644 src/Routes.jsx diff --git a/.eslintrc.json b/.eslintrc.json index 92088976a..b88b2e231 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -9,7 +9,8 @@ "eslint:recommended", "plugin:react/recommended", "react-app", - "plugin:jsx-a11y/recommended" + "plugin:jsx-a11y/recommended", + "plugin:@tanstack/query/recommended" // Extend the recommended rules from the Query plugin ], "globals": { "process": true @@ -30,22 +31,23 @@ "ecmaVersion": "latest", "sourceType": "module" }, - "plugins": ["react", "react-hooks", "jest", "jsx-a11y"], + "plugins": ["react", "react-hooks", "jest", "jsx-a11y", "@tanstack/query"], "rules": { // suppress errors for missing 'import React' in files "react/react-in-jsx-scope": "off", "react/prop-types": "off", "jsx-a11y/no-autofocus": "off", + "jsx-a11y/click-events-have-key-events": "off", "jsx-a11y/mouse-events-have-key-events": "off", "jsx-a11y/no-noninteractive-element-interactions": "off", - "jsx-a11y/no-static-element-interactions": "off", - "no-console": [ - "error", - { - "allow": ["error", "warn", "info", "table"] - } - ] + "jsx-a11y/no-static-element-interactions": "off" + // "no-console": [ + // "error", + // { + // "allow": ["error", "warn", "info", "table"] + // } + // ] }, "ignorePatterns": ["**/*.css", "**/*.scss"], "settings": { diff --git a/src/Routes.jsx b/src/Routes.jsx new file mode 100644 index 000000000..b3b6556df --- /dev/null +++ b/src/Routes.jsx @@ -0,0 +1,170 @@ +import React, { lazy, Suspense } from "react"; +import { Navigate, Route, useParams } from "react-router-dom"; +import RedirectToCountry from "./routing/RedirectToCountry"; +import AuthCallback from "./layout/AuthCallback"; +import CountryIdLayout from "./routing/CountryIdLayout"; +import Home from "./pages/Home"; +import About from "./pages/About"; +import Jobs from "./pages/Jobs"; +import Testimonials from "./pages/Testimonials"; +import CalculatorInterstitial from "./pages/CalculatorInterstitial"; +import SimulationsPage from "./pages/Simulations"; +import Research from "./pages/Research"; +import BlogPage from "./pages/BlogPage"; +import Donate from "./pages/Donate"; +import PrivacyPage from "./pages/PrivacyPage"; +import TACPage from "./pages/TermsAndConditions"; +import RedirectBlogPost from "./routing/RedirectBlogPost"; +import CitizensEconomicCouncil from "./applets/CitizensEconomicCouncil"; +import ManifestosComparison from "./applets/ManifestosComparison"; +import { StatusPage } from "./pages/StatusPage"; +import TrafwaCalculator from "./applets/TrafwaCalculator"; +import StateEitcsCtcs from "./applets/StateEitcsCtcs"; +import CTCComparison from "./applets/CTCComparison"; + +import Header from "./layout/Header"; +import LoadingCentered from "./layout/LoadingCentered"; +import ErrorPage from "./layout/ErrorPage"; +import APIDocumentationPage from "./pages/APIDocumentationPage"; +import UserProfilePage from "./pages/UserProfilePage"; +import useMetadata from "./hooks/useMetadata"; +import usePolicy from "./hooks/usePolicy"; +import { extractCountryId } from "./pages/policy/output/utils"; +import useUserProfile from "./hooks/useUserProfile"; + +const PolicyPage = lazy(() => import("./pages/PolicyPage")); +const HouseholdPage = lazy(() => import("./pages/HouseholdPage")); + +const Routes = () => { + const countryId = extractCountryId(); + + + + return ( + + {/* Redirect from / to /[countryId] */} + } /> + } /> + }> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + + } /> + } /> + + } /> + + } /> + {/* redirect from /countryId/blog/slug to /countryId/research/slug */} + } /> + + } /> + } /> + } /> + } /> + } /> + } + /> + + {/* Redirect for unrecognized paths */} + } /> + + ); +}; + +export default Routes; + +export const LoadingPage = () => ( + <> +
+ + +); + +const HouseholdPageLayout = () => { + const { + metadata, + isMetadataLoading, + metadataError, + isMetadataError, + isMetadataSuccess, + } = useMetadata(); + const { policy } = usePolicy(); + if (isMetadataLoading) { + return ; + } + if (isMetadataError) { + return ; + } + + return ( + + + + ); +}; + +const PolicyPageLayout = () => { + const { + metadata, + isMetadataLoading, + metadataError, + isMetadataError, + isMetadataSuccess, + } = useMetadata(); + const { policy } = usePolicy(isMetadataSuccess); + if (isMetadataLoading) { + return ; + } + if (isMetadataError) { + return ; + } + return ( + + + + ); +}; + +const SuspenseLayout = ({ children }) => { + return ( + }> +
+ {children} + + ); +}; + +const UserProfileRoute = () => { + const { user_id, countryId } = useParams(); + // const countryId = extractCountryId(); + const { userProfile, isUserProfileLoading, isUserProfileError } = + useUserProfile(); + + // If userProfile doesn't exist, render ErrorPage + if (isUserProfileError) { + return ; + } + if (isUserProfileLoading) { + return ; + } + + // If user_id matches the authed user profile, render UserProfilePage + if (userProfile && user_id === userProfile.user_id) { + return ; + } + + // Otherwise, redirect to the correct profile path + return ; +}; diff --git a/src/pages/APIDocumentationPage.jsx b/src/pages/APIDocumentationPage.jsx index 84ac829ca..a4e909d30 100644 --- a/src/pages/APIDocumentationPage.jsx +++ b/src/pages/APIDocumentationPage.jsx @@ -11,6 +11,7 @@ import { Input, Card, Divider, Tag, Drawer } from "antd"; import { Helmet } from "react-helmet"; import { defaultYear } from "data/constants"; import useDisplayCategory from "../hooks/useDisplayCategory"; +import useMetadata from "../hooks/useMetadata"; export const exampleInputs = { us: { @@ -319,9 +320,16 @@ function CardDrawer(props) { ); } -export default function APIDocumentationPage({ metadata }) { +export default function APIDocumentationPage() { const countryId = useCountryId(); const displayCategory = useDisplayCategory(); + const { + metadata, + isMetadataLoading, + metadataError, + isMetadataError, + isMetadataSuccess, + } = useMetadata(); return ( <> diff --git a/src/pages/HouseholdPage.jsx b/src/pages/HouseholdPage.jsx index c9cafdd64..904c81b33 100644 --- a/src/pages/HouseholdPage.jsx +++ b/src/pages/HouseholdPage.jsx @@ -47,6 +47,12 @@ export default function HouseholdPage(props) { const [autoCompute, setAutoCompute] = useState(false); const [isRHPOpen, setIsRHPOpen] = useState(false); const [year, setYear] = useState(defaultYear); + const { + isMetadataLoading, + metadataError, + isMetadataError, + isMetadataSuccess, + } = useMetadata(); let middle; const focus = searchParams.get("focus") || ""; diff --git a/src/pages/PolicyPage.jsx b/src/pages/PolicyPage.jsx index 9f24aa178..157dc6337 100644 --- a/src/pages/PolicyPage.jsx +++ b/src/pages/PolicyPage.jsx @@ -85,6 +85,7 @@ export default function PolicyPage(props) { const { metadata, policy, userProfile, setPolicy } = props; const mobile = useMobile(); + const [searchParams, setSearchParams] = useSearchParams(); const focus = searchParams.get("focus") || ""; diff --git a/src/pages/UserProfilePage.jsx b/src/pages/UserProfilePage.jsx index aad174706..a1517c6e1 100644 --- a/src/pages/UserProfilePage.jsx +++ b/src/pages/UserProfilePage.jsx @@ -26,6 +26,8 @@ import { COUNTRY_NAMES } from "../data/countries"; import moment from "moment"; import { formatCurrencyAbbr } from "../lang/format"; import ErrorPage from "../layout/ErrorPage"; +import useMetadata from "../hooks/useMetadata"; +import usePolicy from "../hooks/usePolicy"; const STATES = { EMPTY: "empty", @@ -55,7 +57,16 @@ export default function UserProfilePage(props) { // visiting. authedUserProfile is shared via props, as the entire // app has access to this info, while accessedUserProfile requires a fetch - const { metadata, authedUserProfile, metadataError } = props; + const { authedUserProfile } = props; + const { + metadata, + isMetadataLoading, + metadataError, + isMetadataError, + isMetadataSuccess, + } = useMetadata(); + + let params = useParams(); const accessedUserId = params.user_id; const isOwnProfile = diff --git a/src/pages/policy/PolicyRightSidebar.jsx b/src/pages/policy/PolicyRightSidebar.jsx index 9fe872f14..c14f06215 100644 --- a/src/pages/policy/PolicyRightSidebar.jsx +++ b/src/pages/policy/PolicyRightSidebar.jsx @@ -19,6 +19,7 @@ import useDisplayCategory from "../../hooks/useDisplayCategory"; import { defaultForeverYear } from "../../data/constants"; import Collapsible from "../../layout/Collapsible"; import { formatFullDate } from "../../lang/format"; +import usePolicy from "../../hooks/usePolicy"; function RegionSelector(props) { const { metadata } = props; @@ -255,7 +256,7 @@ function PolicyNamer(props) { const [searchParams, setSearchParams] = useSearchParams(); const label = policy.reform.label || `Policy #${searchParams.get("reform")}`; const [error, setError] = useState(null); - + const {refetchReformPolicy} = usePolicy() function handleSubmit(name) { if (!validateSubmit(name)) { setError("Error: Policy name invalid"); @@ -266,6 +267,8 @@ function PolicyNamer(props) { (data) => { let newSearch = copySearchParams(searchParams); newSearch.set("renamed", true); + //TODO delte above 2 lines + refetchReformPolicy() if (data.status === "ok") { newSearch.set("reform", data.policy_id); } diff --git a/src/pages/policy/output/FetchAndDisplayImpact.jsx b/src/pages/policy/output/FetchAndDisplayImpact.jsx index df266a1e5..e0635f7e4 100644 --- a/src/pages/policy/output/FetchAndDisplayImpact.jsx +++ b/src/pages/policy/output/FetchAndDisplayImpact.jsx @@ -75,6 +75,7 @@ export function FetchAndDisplayImpact(props) { policyRef.current?.baseline?.data, ) && renamed + //TODO use of query refetch instrad of renamed ) { return; } From 754b095891a426f740823b21370182e85c657e2a Mon Sep 17 00:00:00 2001 From: bharateshwq Date: Tue, 8 Oct 2024 00:10:13 +0530 Subject: [PATCH 4/7] implemetation of routes with query --- package-lock.json | 26 ++++ package.json | 1 + src/QueryCover.jsx | 16 ++- src/Routes.jsx | 175 ++++++++++++++++-------- src/index.js | 3 +- src/pages/HouseholdPage.jsx | 1 + src/pages/policy/PolicyRightSidebar.jsx | 4 +- 7 files changed, 162 insertions(+), 64 deletions(-) diff --git a/package-lock.json b/package-lock.json index ca6d1ea54..0fd4b969b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,7 @@ "@babel/preset-react": "^7.24.7", "@n8tb1t/use-scroll-position": "^2.0.3", "@tanstack/react-query": "^5.59.0", + "@tanstack/react-query-devtools": "^5.59.0", "@uiw/codemirror-extensions-langs": "^4.23.0", "@uiw/codemirror-theme-github": "^4.23.0", "@uiw/react-codemirror": "^4.23.0", @@ -5539,6 +5540,15 @@ "url": "https://github.com/sponsors/tannerlinsley" } }, + "node_modules/@tanstack/query-devtools": { + "version": "5.58.0", + "resolved": "https://registry.npmjs.org/@tanstack/query-devtools/-/query-devtools-5.58.0.tgz", + "integrity": "sha512-iFdQEFXaYYxqgrv63ots+65FGI+tNp5ZS5PdMU1DWisxk3fez5HG3FyVlbUva+RdYS5hSLbxZ9aw3yEs97GNTw==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + } + }, "node_modules/@tanstack/react-query": { "version": "5.59.0", "resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.59.0.tgz", @@ -5554,6 +5564,22 @@ "react": "^18 || ^19" } }, + "node_modules/@tanstack/react-query-devtools": { + "version": "5.59.0", + "resolved": "https://registry.npmjs.org/@tanstack/react-query-devtools/-/react-query-devtools-5.59.0.tgz", + "integrity": "sha512-Kz7577FQGU8qmJxROIT/aOwmkTcxfBqgTP6r1AIvuJxVMVHPkp8eQxWQ7BnfBsy/KTJHiV9vMtRVo1+R1tB3vg==", + "dependencies": { + "@tanstack/query-devtools": "5.58.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + }, + "peerDependencies": { + "@tanstack/react-query": "^5.59.0", + "react": "^18 || ^19" + } + }, "node_modules/@testing-library/dom": { "version": "10.1.0", "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.1.0.tgz", diff --git a/package.json b/package.json index d53cf5a37..8631c1399 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "@babel/preset-react": "^7.24.7", "@n8tb1t/use-scroll-position": "^2.0.3", "@tanstack/react-query": "^5.59.0", + "@tanstack/react-query-devtools": "^5.59.0", "@uiw/codemirror-extensions-langs": "^4.23.0", "@uiw/codemirror-theme-github": "^4.23.0", "@uiw/react-codemirror": "^4.23.0", diff --git a/src/QueryCover.jsx b/src/QueryCover.jsx index d007f6ec4..99e347bf9 100644 --- a/src/QueryCover.jsx +++ b/src/QueryCover.jsx @@ -1,10 +1,20 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import React from "react"; - +import { ReactQueryDevtools } from "@tanstack/react-query-devtools"; const QueryCover = ({ children }) => { - const queryClient = new QueryClient(); + const queryClient = new QueryClient({ + defaultOptions: { + queries: { + //cache stays fresh for 3min + staleTime: 180000, + }, + }, + }); return ( - {children} + + {children} + + ); }; diff --git a/src/Routes.jsx b/src/Routes.jsx index b3b6556df..0fa0752cb 100644 --- a/src/Routes.jsx +++ b/src/Routes.jsx @@ -1,5 +1,11 @@ -import React, { lazy, Suspense } from "react"; -import { Navigate, Route, useParams } from "react-router-dom"; +import React, { lazy, Profiler, Suspense, useEffect } from "react"; +import { + Navigate, + Route, + Routes, + useLocation, + useParams, +} from "react-router-dom"; import RedirectToCountry from "./routing/RedirectToCountry"; import AuthCallback from "./layout/AuthCallback"; import CountryIdLayout from "./routing/CountryIdLayout"; @@ -31,59 +37,110 @@ import useMetadata from "./hooks/useMetadata"; import usePolicy from "./hooks/usePolicy"; import { extractCountryId } from "./pages/policy/output/utils"; import useUserProfile from "./hooks/useUserProfile"; +import { ConfigProvider } from "antd"; +import style from "./style"; +import CookieConsent from "./modals/CookieConsent"; const PolicyPage = lazy(() => import("./pages/PolicyPage")); const HouseholdPage = lazy(() => import("./pages/HouseholdPage")); -const Routes = () => { - const countryId = extractCountryId(); +function ScrollToTop() { + const { pathname } = useLocation(); - + useEffect(() => { + window.scrollTo(0, 0); + }, [pathname]); - return ( - - {/* Redirect from / to /[countryId] */} - } /> - } /> - }> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - - } /> - } /> - - } /> - - } /> - {/* redirect from /countryId/blog/slug to /countryId/research/slug */} - } /> - - } /> - } /> - } /> - } /> - } /> - } - /> + return null; +} + +const PolicyEngineRoutes = () => { + const countryId = extractCountryId(); + const onRender = ( + id, + phase, + actualDuration, + baseDuration, + startTime, + commitTime, + ) => { + console.log({ + id, + phase, + actualDuration, + baseDuration, + startTime, + commitTime, + }); + }; - {/* Redirect for unrecognized paths */} - } /> - + return ( + + {/* //TODO temporary will be shifting back to policy engine */} + + + + {/* till here */} + + + {/* Redirect from / to /[countryId] */} + } /> + } /> + }> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + + } /> + } /> + + } /> + } /> + } /> + {/* redirect from /countryId/blog/slug to /countryId/research/slug */} + } /> + + } /> + } + /> + } /> + } + /> + } /> + } + /> + + {/* Redirect for unrecognized paths */} + } /> + + + ); }; -export default Routes; +export default PolicyEngineRoutes; export const LoadingPage = () => ( <> @@ -100,11 +157,11 @@ const HouseholdPageLayout = () => { isMetadataError, isMetadataSuccess, } = useMetadata(); - const { policy } = usePolicy(); - if (isMetadataLoading) { + const { policy, isPolicyLoading, isPolicyError } = usePolicy(); + if (isMetadataLoading || isPolicyLoading) { return ; } - if (isMetadataError) { + if (isMetadataError || isPolicyError) { return ; } @@ -123,16 +180,22 @@ const PolicyPageLayout = () => { isMetadataError, isMetadataSuccess, } = useMetadata(); - const { policy } = usePolicy(isMetadataSuccess); - if (isMetadataLoading) { + const { policy, isPolicyError, isPolicyLoading } = usePolicy(); + const { userProfile, isUserProfileLoading, isUserProfileError } = + useUserProfile(); + if (isMetadataLoading || isPolicyLoading || isUserProfileLoading) { return ; } - if (isMetadataError) { + if (isMetadataError || isUserProfileError || isPolicyError) { return ; } return ( - + ); }; @@ -160,11 +223,7 @@ const UserProfileRoute = () => { return ; } - // If user_id matches the authed user profile, render UserProfilePage - if (userProfile && user_id === userProfile.user_id) { - return ; + if (!isUserProfileError) { + return ; } - - // Otherwise, redirect to the correct profile path - return ; }; diff --git a/src/index.js b/src/index.js index 9033d729d..8450fa5e2 100644 --- a/src/index.js +++ b/src/index.js @@ -9,6 +9,7 @@ import loc_en_gb from "./lang/plotly_locales/locale-en-gb.js"; import loc_en_us from "./lang/plotly_locales/locale-en-us.js"; import Auth0ProviderWithNavigate from "./auth/Auth0ProviderWithNavigate.jsx"; import QueryCover from "./QueryCover.jsx"; +import PolicyEngineRoutes from "./Routes.jsx"; var Plotly = require("plotly.js/dist/plotly.js"); Plotly.register(loc_en_gb); @@ -19,7 +20,7 @@ root.render( - + , diff --git a/src/pages/HouseholdPage.jsx b/src/pages/HouseholdPage.jsx index 904c81b33..c5c490921 100644 --- a/src/pages/HouseholdPage.jsx +++ b/src/pages/HouseholdPage.jsx @@ -27,6 +27,7 @@ import MobileCalculatorPage from "../layout/MobileCalculatorPage.jsx"; import RecreateHouseholdPopup from "./household/output/RecreateHouseholdPopup.jsx"; import TaxYear from "./household/input/TaxYear"; import { Helmet } from "react-helmet"; +import useMetadata from "../hooks/useMetadata.js"; export default function HouseholdPage(props) { const { diff --git a/src/pages/policy/PolicyRightSidebar.jsx b/src/pages/policy/PolicyRightSidebar.jsx index c14f06215..c3972e434 100644 --- a/src/pages/policy/PolicyRightSidebar.jsx +++ b/src/pages/policy/PolicyRightSidebar.jsx @@ -256,7 +256,7 @@ function PolicyNamer(props) { const [searchParams, setSearchParams] = useSearchParams(); const label = policy.reform.label || `Policy #${searchParams.get("reform")}`; const [error, setError] = useState(null); - const {refetchReformPolicy} = usePolicy() + const { refetchReformPolicy } = usePolicy(); function handleSubmit(name) { if (!validateSubmit(name)) { setError("Error: Policy name invalid"); @@ -268,7 +268,7 @@ function PolicyNamer(props) { let newSearch = copySearchParams(searchParams); newSearch.set("renamed", true); //TODO delte above 2 lines - refetchReformPolicy() + refetchReformPolicy(); if (data.status === "ok") { newSearch.set("reform", data.policy_id); } From 40d0cd51415aca033abfcd65a7d9a2c750a45483 Mon Sep 17 00:00:00 2001 From: bharateshwq Date: Tue, 22 Oct 2024 07:58:57 +0530 Subject: [PATCH 5/7] removed unused variables --- src/QueryCover.jsx | 7 +++++-- src/Routes.jsx | 6 +----- src/index.js | 2 +- src/pages/APIDocumentationPage.jsx | 8 ++++---- src/pages/HouseholdPage.jsx | 8 +------- src/pages/UserProfilePage.jsx | 5 +---- 6 files changed, 13 insertions(+), 23 deletions(-) diff --git a/src/QueryCover.jsx b/src/QueryCover.jsx index 99e347bf9..47174ef1a 100644 --- a/src/QueryCover.jsx +++ b/src/QueryCover.jsx @@ -1,6 +1,8 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import React from "react"; -import { ReactQueryDevtools } from "@tanstack/react-query-devtools"; + {/* uncomment below line during development */} + +// import { ReactQueryDevtools } from "@tanstack/react-query-devtools"; const QueryCover = ({ children }) => { const queryClient = new QueryClient({ defaultOptions: { @@ -13,7 +15,8 @@ const QueryCover = ({ children }) => { return ( {children} - + {/* uncomment below line during development */} + {/* */} ); }; diff --git a/src/Routes.jsx b/src/Routes.jsx index 0fa0752cb..b25df54c5 100644 --- a/src/Routes.jsx +++ b/src/Routes.jsx @@ -153,9 +153,7 @@ const HouseholdPageLayout = () => { const { metadata, isMetadataLoading, - metadataError, isMetadataError, - isMetadataSuccess, } = useMetadata(); const { policy, isPolicyLoading, isPolicyError } = usePolicy(); if (isMetadataLoading || isPolicyLoading) { @@ -176,9 +174,7 @@ const PolicyPageLayout = () => { const { metadata, isMetadataLoading, - metadataError, isMetadataError, - isMetadataSuccess, } = useMetadata(); const { policy, isPolicyError, isPolicyLoading } = usePolicy(); const { userProfile, isUserProfileLoading, isUserProfileError } = @@ -210,7 +206,7 @@ const SuspenseLayout = ({ children }) => { }; const UserProfileRoute = () => { - const { user_id, countryId } = useParams(); + const { countryId } = useParams(); // const countryId = extractCountryId(); const { userProfile, isUserProfileLoading, isUserProfileError } = useUserProfile(); diff --git a/src/index.js b/src/index.js index 8450fa5e2..f3d927cc7 100644 --- a/src/index.js +++ b/src/index.js @@ -2,7 +2,7 @@ import React from "react"; import ReactDOM from "react-dom/client"; import "bootstrap/dist/css/bootstrap.min.css"; import "./style/App.css"; -import PolicyEngine from "./PolicyEngine.jsx"; +// import PolicyEngine from "./PolicyEngine.jsx"; import * as serviceWorkerRegistration from "./serviceWorkerRegistration.js"; import { BrowserRouter as Router } from "react-router-dom"; import loc_en_gb from "./lang/plotly_locales/locale-en-gb.js"; diff --git a/src/pages/APIDocumentationPage.jsx b/src/pages/APIDocumentationPage.jsx index a4e909d30..dc8f7868a 100644 --- a/src/pages/APIDocumentationPage.jsx +++ b/src/pages/APIDocumentationPage.jsx @@ -325,10 +325,10 @@ export default function APIDocumentationPage() { const displayCategory = useDisplayCategory(); const { metadata, - isMetadataLoading, - metadataError, - isMetadataError, - isMetadataSuccess, + // isMetadataLoading, + // metadataError, + // isMetadataError, + // isMetadataSuccess, } = useMetadata(); return ( diff --git a/src/pages/HouseholdPage.jsx b/src/pages/HouseholdPage.jsx index c5c490921..85cf5bc8b 100644 --- a/src/pages/HouseholdPage.jsx +++ b/src/pages/HouseholdPage.jsx @@ -27,7 +27,6 @@ import MobileCalculatorPage from "../layout/MobileCalculatorPage.jsx"; import RecreateHouseholdPopup from "./household/output/RecreateHouseholdPopup.jsx"; import TaxYear from "./household/input/TaxYear"; import { Helmet } from "react-helmet"; -import useMetadata from "../hooks/useMetadata.js"; export default function HouseholdPage(props) { const { @@ -48,12 +47,7 @@ export default function HouseholdPage(props) { const [autoCompute, setAutoCompute] = useState(false); const [isRHPOpen, setIsRHPOpen] = useState(false); const [year, setYear] = useState(defaultYear); - const { - isMetadataLoading, - metadataError, - isMetadataError, - isMetadataSuccess, - } = useMetadata(); + let middle; const focus = searchParams.get("focus") || ""; diff --git a/src/pages/UserProfilePage.jsx b/src/pages/UserProfilePage.jsx index a1517c6e1..aab6b462f 100644 --- a/src/pages/UserProfilePage.jsx +++ b/src/pages/UserProfilePage.jsx @@ -27,7 +27,6 @@ import moment from "moment"; import { formatCurrencyAbbr } from "../lang/format"; import ErrorPage from "../layout/ErrorPage"; import useMetadata from "../hooks/useMetadata"; -import usePolicy from "../hooks/usePolicy"; const STATES = { EMPTY: "empty", @@ -60,10 +59,8 @@ export default function UserProfilePage(props) { const { authedUserProfile } = props; const { metadata, - isMetadataLoading, metadataError, - isMetadataError, - isMetadataSuccess, + } = useMetadata(); From 78da731af386819a0baf1f835ef29a1f328ae46b Mon Sep 17 00:00:00 2001 From: bharateshwq Date: Fri, 1 Nov 2024 18:12:13 +0530 Subject: [PATCH 6/7] fixed issues, lifted props --- package-lock.json | 390 +++++++++--------- src/QueryCover.jsx | 3 +- src/Routes.jsx | 166 ++++---- src/hooks/useUserProfile.js | 3 +- src/modals/PoliciesModelledPopup.jsx | 4 +- src/pages/HouseholdPage.jsx | 6 +- src/pages/UserProfilePage.jsx | 4 +- .../household/output/HouseholdOutput.jsx | 6 +- 8 files changed, 294 insertions(+), 288 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0fd4b969b..b414b00b1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5581,10 +5581,9 @@ } }, "node_modules/@testing-library/dom": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.1.0.tgz", - "integrity": "sha512-wdsYKy5zupPyLCW2Je5DLHSxSfbIp6h80WoHOQc+RPtmPGA52O9x5MJEkv92Sjonpq+poOAtUKhh1kBGAXBrNA==", - "dev": true, + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.4.0.tgz", + "integrity": "sha512-pemlzrSESWbdAloYml3bAJMEfNh1Z7EduzqPKprCH5S341frlpYnUEW0H72dLxa6IsYr+mPno20GiSm+h9dEdQ==", "dependencies": { "@babel/code-frame": "^7.10.4", "@babel/runtime": "^7.12.5", @@ -5852,19 +5851,10 @@ "@types/json-schema": "*" } }, - "node_modules/@types/eslint-scope": { - "version": "3.7.6", - "resolved": "https://registry.npmjs.org/@types/eslint-scope/-/eslint-scope-3.7.6.tgz", - "integrity": "sha512-zfM4ipmxVKWdxtDaJ3MP3pBurDXOCoyjvlpE3u6Qzrmw4BPbfm4/ambIeTk/r/J0iq/+2/xp0Fmt+gFvXJY2PQ==", - "dependencies": { - "@types/eslint": "*", - "@types/estree": "*" - } - }, "node_modules/@types/estree": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.3.tgz", - "integrity": "sha512-CS2rOaoQ/eAgAfcTfq6amKG7bsN+EMcgGY4FAFQdvSj2y1ixvOZTUA9mOtCai7E1SYu283XNw7urKK30nP3wkQ==" + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz", + "integrity": "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==" }, "node_modules/@types/estree-jsx": { "version": "1.0.5", @@ -6620,9 +6610,9 @@ "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==" }, "node_modules/@webassemblyjs/ast": { - "version": "1.11.6", - "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.6.tgz", - "integrity": "sha512-IN1xI7PwOvLPgjcf180gC1bqn3q/QaOCwYUahIOhbYUu8KA/3tw2RT/T0Gidi1l7Hhj5D/INhJxiICObqpMu4Q==", + "version": "1.12.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.12.1.tgz", + "integrity": "sha512-EKfMUOPRRUTy5UII4qJDGPpqfwjOmZ5jeGFwid9mnoqIFK+e0vqoi1qH56JpmZSzEL53jKnNzScdmftJyG5xWg==", "dependencies": { "@webassemblyjs/helper-numbers": "1.11.6", "@webassemblyjs/helper-wasm-bytecode": "1.11.6" @@ -6639,9 +6629,9 @@ "integrity": "sha512-o0YkoP4pVu4rN8aTJgAyj9hC2Sv5UlkzCHhxqWj8butaLvnpdc2jOwh4ewE6CX0txSfLn/UYaV/pheS2Txg//Q==" }, "node_modules/@webassemblyjs/helper-buffer": { - "version": "1.11.6", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-buffer/-/helper-buffer-1.11.6.tgz", - "integrity": "sha512-z3nFzdcp1mb8nEOFFk8DrYLpHvhKC3grJD2ardfKOzmbmJvEf/tPIqCY+sNcwZIY8ZD7IkB2l7/pqhUhqm7hLA==" + "version": "1.12.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-buffer/-/helper-buffer-1.12.1.tgz", + "integrity": "sha512-nzJwQw99DNDKr9BVCOZcLuJJUlqkJh+kVzVl6Fmq/tI5ZtEyWT1KZMyOXltXLZJmDtvLCDgwsyrkohEtopTXCw==" }, "node_modules/@webassemblyjs/helper-numbers": { "version": "1.11.6", @@ -6659,14 +6649,14 @@ "integrity": "sha512-sFFHKwcmBprO9e7Icf0+gddyWYDViL8bpPjJJl0WHxCdETktXdmtWLGVzoHbqUcY4Be1LkNfwTmXOJUFZYSJdA==" }, "node_modules/@webassemblyjs/helper-wasm-section": { - "version": "1.11.6", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.11.6.tgz", - "integrity": "sha512-LPpZbSOwTpEC2cgn4hTydySy1Ke+XEu+ETXuoyvuyezHO3Kjdu90KK95Sh9xTbmjrCsUwvWwCOQQNta37VrS9g==", + "version": "1.12.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.12.1.tgz", + "integrity": "sha512-Jif4vfB6FJlUlSbgEMHUyk1j234GTNG9dBJ4XJdOySoj518Xj0oGsNi59cUQF4RRMS9ouBUxDDdyBVfPTypa5g==", "dependencies": { - "@webassemblyjs/ast": "1.11.6", - "@webassemblyjs/helper-buffer": "1.11.6", + "@webassemblyjs/ast": "1.12.1", + "@webassemblyjs/helper-buffer": "1.12.1", "@webassemblyjs/helper-wasm-bytecode": "1.11.6", - "@webassemblyjs/wasm-gen": "1.11.6" + "@webassemblyjs/wasm-gen": "1.12.1" } }, "node_modules/@webassemblyjs/ieee754": { @@ -6691,26 +6681,26 @@ "integrity": "sha512-vtXf2wTQ3+up9Zsg8sa2yWiQpzSsMyXj0qViVP6xKGCUT8p8YJ6HqI7l5eCnWx1T/FYdsv07HQs2wTFbbof/RA==" }, "node_modules/@webassemblyjs/wasm-edit": { - "version": "1.11.6", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-edit/-/wasm-edit-1.11.6.tgz", - "integrity": "sha512-Ybn2I6fnfIGuCR+Faaz7YcvtBKxvoLV3Lebn1tM4o/IAJzmi9AWYIPWpyBfU8cC+JxAO57bk4+zdsTjJR+VTOw==", + "version": "1.12.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-edit/-/wasm-edit-1.12.1.tgz", + "integrity": "sha512-1DuwbVvADvS5mGnXbE+c9NfA8QRcZ6iKquqjjmR10k6o+zzsRVesil54DKexiowcFCPdr/Q0qaMgB01+SQ1u6g==", "dependencies": { - "@webassemblyjs/ast": "1.11.6", - "@webassemblyjs/helper-buffer": "1.11.6", + "@webassemblyjs/ast": "1.12.1", + "@webassemblyjs/helper-buffer": "1.12.1", "@webassemblyjs/helper-wasm-bytecode": "1.11.6", - "@webassemblyjs/helper-wasm-section": "1.11.6", - "@webassemblyjs/wasm-gen": "1.11.6", - "@webassemblyjs/wasm-opt": "1.11.6", - "@webassemblyjs/wasm-parser": "1.11.6", - "@webassemblyjs/wast-printer": "1.11.6" + "@webassemblyjs/helper-wasm-section": "1.12.1", + "@webassemblyjs/wasm-gen": "1.12.1", + "@webassemblyjs/wasm-opt": "1.12.1", + "@webassemblyjs/wasm-parser": "1.12.1", + "@webassemblyjs/wast-printer": "1.12.1" } }, "node_modules/@webassemblyjs/wasm-gen": { - "version": "1.11.6", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-gen/-/wasm-gen-1.11.6.tgz", - "integrity": "sha512-3XOqkZP/y6B4F0PBAXvI1/bky7GryoogUtfwExeP/v7Nzwo1QLcq5oQmpKlftZLbT+ERUOAZVQjuNVak6UXjPA==", + "version": "1.12.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-gen/-/wasm-gen-1.12.1.tgz", + "integrity": "sha512-TDq4Ojh9fcohAw6OIMXqiIcTq5KUXTGRkVxbSo1hQnSy6lAM5GSdfwWeSxpAo0YzgsgF182E/U0mDNhuA0tW7w==", "dependencies": { - "@webassemblyjs/ast": "1.11.6", + "@webassemblyjs/ast": "1.12.1", "@webassemblyjs/helper-wasm-bytecode": "1.11.6", "@webassemblyjs/ieee754": "1.11.6", "@webassemblyjs/leb128": "1.11.6", @@ -6718,22 +6708,22 @@ } }, "node_modules/@webassemblyjs/wasm-opt": { - "version": "1.11.6", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-opt/-/wasm-opt-1.11.6.tgz", - "integrity": "sha512-cOrKuLRE7PCe6AsOVl7WasYf3wbSo4CeOk6PkrjS7g57MFfVUF9u6ysQBBODX0LdgSvQqRiGz3CXvIDKcPNy4g==", + "version": "1.12.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-opt/-/wasm-opt-1.12.1.tgz", + "integrity": "sha512-Jg99j/2gG2iaz3hijw857AVYekZe2SAskcqlWIZXjji5WStnOpVoat3gQfT/Q5tb2djnCjBtMocY/Su1GfxPBg==", "dependencies": { - "@webassemblyjs/ast": "1.11.6", - "@webassemblyjs/helper-buffer": "1.11.6", - "@webassemblyjs/wasm-gen": "1.11.6", - "@webassemblyjs/wasm-parser": "1.11.6" + "@webassemblyjs/ast": "1.12.1", + "@webassemblyjs/helper-buffer": "1.12.1", + "@webassemblyjs/wasm-gen": "1.12.1", + "@webassemblyjs/wasm-parser": "1.12.1" } }, "node_modules/@webassemblyjs/wasm-parser": { - "version": "1.11.6", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-parser/-/wasm-parser-1.11.6.tgz", - "integrity": "sha512-6ZwPeGzMJM3Dqp3hCsLgESxBGtT/OeCvCZ4TA1JUPYgmhAx38tTPR9JaKy0S5H3evQpO/h2uWs2j6Yc/fjkpTQ==", + "version": "1.12.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-parser/-/wasm-parser-1.12.1.tgz", + "integrity": "sha512-xikIi7c2FHXysxXe3COrVUPSheuBtpcfhbpFj4gmu7KRLYOzANztwUU0IbsqvMqzuNK2+glRGWCEqZo1WCLyAQ==", "dependencies": { - "@webassemblyjs/ast": "1.11.6", + "@webassemblyjs/ast": "1.12.1", "@webassemblyjs/helper-api-error": "1.11.6", "@webassemblyjs/helper-wasm-bytecode": "1.11.6", "@webassemblyjs/ieee754": "1.11.6", @@ -6742,11 +6732,11 @@ } }, "node_modules/@webassemblyjs/wast-printer": { - "version": "1.11.6", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wast-printer/-/wast-printer-1.11.6.tgz", - "integrity": "sha512-JM7AhRcE+yW2GWYaKeHL5vt4xqee5N2WcezptmgyhNS+ScggqcT1OtXykhAb13Sn5Yas0j2uv9tHgrjwvzAP4A==", + "version": "1.12.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wast-printer/-/wast-printer-1.12.1.tgz", + "integrity": "sha512-+X4WAlOisVWQMikjbcvY2e0rwPsKQ9F688lksZhBcPycBBuii3O7m8FACbDMWDojpAqvjIncrG8J0XHKyQfVeA==", "dependencies": { - "@webassemblyjs/ast": "1.11.6", + "@webassemblyjs/ast": "1.12.1", "@xtuc/long": "4.2.2" } }, @@ -6794,9 +6784,9 @@ } }, "node_modules/acorn": { - "version": "8.10.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", - "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==", + "version": "8.14.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.0.tgz", + "integrity": "sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==", "bin": { "acorn": "bin/acorn" }, @@ -6814,14 +6804,6 @@ "acorn-walk": "^8.0.2" } }, - "node_modules/acorn-import-assertions": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/acorn-import-assertions/-/acorn-import-assertions-1.9.0.tgz", - "integrity": "sha512-cmMwop9x+8KFhxvKrKfPYmN6/pKTYYHBqLa0DfvVZcKMJWNyWLnaqND7dx/qn66R7ewM1UX5XMaDVP5wlVTaVA==", - "peerDependencies": { - "acorn": "^8" - } - }, "node_modules/acorn-jsx": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", @@ -7978,20 +7960,20 @@ "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==" }, "node_modules/body-parser": { - "version": "1.20.1", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", - "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", + "version": "1.20.3", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz", + "integrity": "sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g==", "dependencies": { "bytes": "3.1.2", - "content-type": "~1.0.4", + "content-type": "~1.0.5", "debug": "2.6.9", "depd": "2.0.0", "destroy": "1.2.0", "http-errors": "2.0.0", "iconv-lite": "0.4.24", "on-finished": "2.4.1", - "qs": "6.11.0", - "raw-body": "2.5.1", + "qs": "6.13.0", + "raw-body": "2.5.2", "type-is": "~1.6.18", "unpipe": "1.0.0" }, @@ -8081,9 +8063,9 @@ "integrity": "sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow==" }, "node_modules/browserslist": { - "version": "4.23.3", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.23.3.tgz", - "integrity": "sha512-btwCFJVjI4YWDNfau8RhZ+B1Q/VLoUITrm3RlP6y1tYGWIOa+InuYiRGXUBXo8nA1qKmHMyLB/iVQg5TT4eFoA==", + "version": "4.24.2", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.24.2.tgz", + "integrity": "sha512-ZIc+Q62revdMcqC6aChtW4jz3My3klmCO1fEmINZY/8J3EpBg5/A/D0AKmBveUh6pgoeycoMkVMko84tuYS+Gg==", "funding": [ { "type": "opencollective", @@ -8099,10 +8081,10 @@ } ], "dependencies": { - "caniuse-lite": "^1.0.30001646", - "electron-to-chromium": "^1.5.4", + "caniuse-lite": "^1.0.30001669", + "electron-to-chromium": "^1.5.41", "node-releases": "^2.0.18", - "update-browserslist-db": "^1.1.0" + "update-browserslist-db": "^1.1.1" }, "bin": { "browserslist": "cli.js" @@ -8223,9 +8205,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001666", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001666.tgz", - "integrity": "sha512-gD14ICmoV5ZZM1OdzPWmpx+q4GyefaK06zi8hmfHV5xe4/2nOQX3+Dw5o+fSqOws2xVwL9j+anOPFwHzdEdV4g==", + "version": "1.0.30001676", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001676.tgz", + "integrity": "sha512-Qz6zwGCiPghQXGJvgQAem79esjitvJ+CxSbSQkW9H/UX5hg8XM88d4lp2W+MEQ81j+Hip58Il+jGVdazk1z9cw==", "funding": [ { "type": "opencollective", @@ -8857,9 +8839,9 @@ "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==" }, "node_modules/cookie": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", - "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.1.tgz", + "integrity": "sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==", "engines": { "node": ">= 0.6" } @@ -10133,9 +10115,9 @@ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, "node_modules/ejs": { - "version": "3.1.9", - "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.9.tgz", - "integrity": "sha512-rC+QVNMJWv+MtPgkt0y+0rVEIdbtxVADApW9JXrUVlzHetgcyczP/E7DJmWJ4fJCZF2cPcBk0laWO9ZHMG3DmQ==", + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.10.tgz", + "integrity": "sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA==", "dependencies": { "jake": "^10.8.5" }, @@ -10147,9 +10129,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.13", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.13.tgz", - "integrity": "sha512-lbBcvtIJ4J6sS4tb5TLp1b4LyfCdMkwStzXPyAgVgTRAsep4bvrAGaBOP7ZJtQMNJpSQ9SqG4brWOroNaQtm7Q==" + "version": "1.5.50", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.50.tgz", + "integrity": "sha512-eMVObiUQ2LdgeO1F/ySTXsvqvxb6ZH2zPGaMYsWzRDdOddUa77tdmI0ltg+L16UpbWdhPmuF3wIQYyQq65WfZw==" }, "node_modules/element-size": { "version": "1.1.1", @@ -10190,9 +10172,9 @@ } }, "node_modules/encodeurl": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", - "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", "engines": { "node": ">= 0.8" } @@ -10206,9 +10188,9 @@ } }, "node_modules/enhanced-resolve": { - "version": "5.15.0", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.15.0.tgz", - "integrity": "sha512-LXYT42KJ7lpIKECr2mAXIaMldcNCh/7E0KBKOu4KSfkHmP+mZmSs+8V5gBAqisWBy0OO4W5Oyys0GO1Y8KtdKg==", + "version": "5.17.1", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.17.1.tgz", + "integrity": "sha512-LMHl3dXhTcfv8gM4kEzIUeTQ+7fpdA0l2tUf34BddXPkz2A5xJ5L/Pchd5BL6rdccM9QGvu0sWZzK1Z1t4wwyg==", "dependencies": { "graceful-fs": "^4.2.4", "tapable": "^2.2.0" @@ -10417,13 +10399,14 @@ } }, "node_modules/es5-ext": { - "version": "0.10.62", - "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.62.tgz", - "integrity": "sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA==", + "version": "0.10.64", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.64.tgz", + "integrity": "sha512-p2snDhiLaXe6dahss1LddxqEm+SkuDvV8dnIQG0MWjyHpcMNfXKPE+/Cc0y+PhxJX3A4xGNeFCj5oc0BUh6deg==", "hasInstallScript": true, "dependencies": { "es6-iterator": "^2.0.3", "es6-symbol": "^3.1.3", + "esniff": "^2.0.1", "next-tick": "^1.1.0" }, "engines": { @@ -11128,6 +11111,25 @@ "url": "https://github.com/chalk/supports-color?sponsor=1" } }, + "node_modules/esniff": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/esniff/-/esniff-2.0.1.tgz", + "integrity": "sha512-kTUIGKQ/mDPFoJ0oVfcmyJn4iBDRptjNVIzwIFR7tqWXdVI9xfA2RMwY/gbSpJG3lkdWNEjLap/NqVHZiJsdfg==", + "dependencies": { + "d": "^1.0.1", + "es5-ext": "^0.10.62", + "event-emitter": "^0.3.5", + "type": "^2.7.2" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/esniff/node_modules/type": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/type/-/type-2.7.3.tgz", + "integrity": "sha512-8j+1QmAbPvLZow5Qpi6NCaN8FB60p/6x8/vfNqOk/hC+HuvFZhL4+WfekuhQLiqFZXOgQdrs3B+XxEmCc6b3FQ==" + }, "node_modules/espree": { "version": "9.6.1", "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", @@ -11216,6 +11218,15 @@ "node": ">= 0.6" } }, + "node_modules/event-emitter": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz", + "integrity": "sha512-D9rRn9y7kLPnJ+hMq7S/nhvoKwwvVJahBi2BPmx3bvbsEdK3W9ii8cBSGjP+72/LnM4n6fo3+dkCX5FeTQruXA==", + "dependencies": { + "d": "1", + "es5-ext": "~0.10.14" + } + }, "node_modules/event-target-shim": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", @@ -11337,36 +11348,36 @@ } }, "node_modules/express": { - "version": "4.18.2", - "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz", - "integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==", + "version": "4.21.1", + "resolved": "https://registry.npmjs.org/express/-/express-4.21.1.tgz", + "integrity": "sha512-YSFlK1Ee0/GC8QaO91tHcDxJiE/X4FbpAyQWkxAvG6AXCuR65YzK8ua6D9hvi/TzUfZMpc+BwuM1IPw8fmQBiQ==", "dependencies": { "accepts": "~1.3.8", "array-flatten": "1.1.1", - "body-parser": "1.20.1", + "body-parser": "1.20.3", "content-disposition": "0.5.4", "content-type": "~1.0.4", - "cookie": "0.5.0", + "cookie": "0.7.1", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "2.0.0", - "encodeurl": "~1.0.2", + "encodeurl": "~2.0.0", "escape-html": "~1.0.3", "etag": "~1.8.1", - "finalhandler": "1.2.0", + "finalhandler": "1.3.1", "fresh": "0.5.2", "http-errors": "2.0.0", - "merge-descriptors": "1.0.1", + "merge-descriptors": "1.0.3", "methods": "~1.1.2", "on-finished": "2.4.1", "parseurl": "~1.3.3", - "path-to-regexp": "0.1.7", + "path-to-regexp": "0.1.10", "proxy-addr": "~2.0.7", - "qs": "6.11.0", + "qs": "6.13.0", "range-parser": "~1.2.1", "safe-buffer": "5.2.1", - "send": "0.18.0", - "serve-static": "1.15.0", + "send": "0.19.0", + "serve-static": "1.16.2", "setprototypeof": "1.2.0", "statuses": "2.0.1", "type-is": "~1.6.18", @@ -11628,12 +11639,12 @@ } }, "node_modules/finalhandler": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", - "integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.1.tgz", + "integrity": "sha512-6BN9trH7bp3qvnrRyzsBz+g3lZxTNZTbVO2EV1CS0WIcDbawYVdYvGflME/9QP0h0pYlCDBCTjYa9nZzMDpyxQ==", "dependencies": { "debug": "2.6.9", - "encodeurl": "~1.0.2", + "encodeurl": "~2.0.0", "escape-html": "~1.0.3", "on-finished": "2.4.1", "parseurl": "~1.3.3", @@ -13112,9 +13123,9 @@ } }, "node_modules/http-proxy-middleware": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-2.0.6.tgz", - "integrity": "sha512-ya/UeJ6HVBYxrgYotAZo1KvPWlgB48kUJLDePFeneHsVujFaW5WNj2NgWCAE//B1Dl02BIfYlpNgBy8Kf8Rjmw==", + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-2.0.7.tgz", + "integrity": "sha512-fgVY8AV7qU7z/MmXJ/rxwbrtQH4jBQ9m7kp3llF0liB7glmFeVZFBepQb32T3y8n8k2+AEYuMPCpinYW+/CuRA==", "dependencies": { "@types/http-proxy": "^1.17.8", "http-proxy": "^1.18.1", @@ -18211,9 +18222,12 @@ } }, "node_modules/merge-descriptors": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", - "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==" + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz", + "integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==", + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } }, "node_modules/merge-stream": { "version": "2.0.0", @@ -19695,9 +19709,9 @@ "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==" }, "node_modules/path-to-regexp": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", - "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==" + "version": "0.1.10", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.10.tgz", + "integrity": "sha512-7lf7qcQidTku0Gu3YDPc8DJ1q7OOucfa/BSsIwjuh56VU7katFvuM8hULfkwB3Fns/rsVF7PwPKVw1sl5KQS9w==" }, "node_modules/path-type": { "version": "4.0.0", @@ -21373,11 +21387,11 @@ } }, "node_modules/qs": { - "version": "6.11.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", - "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz", + "integrity": "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==", "dependencies": { - "side-channel": "^1.0.4" + "side-channel": "^1.0.6" }, "engines": { "node": ">=0.6" @@ -21440,9 +21454,9 @@ } }, "node_modules/raw-body": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", - "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz", + "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==", "dependencies": { "bytes": "3.1.2", "http-errors": "2.0.0", @@ -23402,9 +23416,9 @@ } }, "node_modules/react-scripts/node_modules/ws": { - "version": "7.5.9", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", - "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", + "version": "7.5.10", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz", + "integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==", "engines": { "node": ">=8.3.0" }, @@ -24424,9 +24438,9 @@ } }, "node_modules/rollup": { - "version": "2.79.1", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.79.1.tgz", - "integrity": "sha512-uKxbd0IhMZOhjAiD5oAFp7BqvkA4Dv47qpOCtaNvng4HBwdbWtdOh8f5nZNuk2rp51PMGk3bzfWu5oayNEuYnw==", + "version": "2.79.2", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.79.2.tgz", + "integrity": "sha512-fS6iqSPZDs3dr/y7Od6y5nha8dW1YnbgtsyotCVvoFGKbERG++CVRFv1meyGDE1SNItQA8BrnCw7ScdAhRJ3XQ==", "bin": { "rollup": "dist/bin/rollup" }, @@ -24682,9 +24696,9 @@ } }, "node_modules/send": { - "version": "0.18.0", - "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", - "integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==", + "version": "0.19.0", + "resolved": "https://registry.npmjs.org/send/-/send-0.19.0.tgz", + "integrity": "sha512-dW41u5VfLXu8SJh5bwRmyYUbAoSB3c9uQh6L8h/KtsFREPWpbX1lrljJo186Jc4nmci/sGUZ9a0a0J2zgfq2hw==", "dependencies": { "debug": "2.6.9", "depd": "2.0.0", @@ -24717,6 +24731,14 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" }, + "node_modules/send/node_modules/encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/send/node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", @@ -24801,14 +24823,14 @@ } }, "node_modules/serve-static": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz", - "integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==", + "version": "1.16.2", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.2.tgz", + "integrity": "sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw==", "dependencies": { - "encodeurl": "~1.0.2", + "encodeurl": "~2.0.0", "escape-html": "~1.0.3", "parseurl": "~1.3.3", - "send": "0.18.0" + "send": "0.19.0" }, "engines": { "node": ">= 0.8.0" @@ -26066,9 +26088,9 @@ } }, "node_modules/terser": { - "version": "5.22.0", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.22.0.tgz", - "integrity": "sha512-hHZVLgRA2z4NWcN6aS5rQDc+7Dcy58HOf2zbYwmFcQ+ua3h6eEFf5lIDKTzbWwlazPyOZsFQO8V80/IjVNExEw==", + "version": "5.36.0", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.36.0.tgz", + "integrity": "sha512-IYV9eNMuFAV4THUspIRXkLakHnV6XO7FEdtKjf/mDyrnqUg9LnlOn6/RwRvM9SZjR4GUq8Nk8zj67FzVARr74w==", "dependencies": { "@jridgewell/source-map": "^0.3.3", "acorn": "^8.8.2", @@ -26083,15 +26105,15 @@ } }, "node_modules/terser-webpack-plugin": { - "version": "5.3.9", - "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.3.9.tgz", - "integrity": "sha512-ZuXsqE07EcggTWQjXUj+Aot/OMcD0bMKGgF63f7UxYcu5/AJF53aIpK1YoP5xR9l6s/Hy2b+t1AM0bLNPRuhwA==", + "version": "5.3.10", + "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.3.10.tgz", + "integrity": "sha512-BKFPWlPDndPs+NGGCr1U59t0XScL5317Y0UReNrHaw9/FwhPENlq6bfgs+4yPfyP51vqC1bQ4rp1EfXW5ZSH9w==", "dependencies": { - "@jridgewell/trace-mapping": "^0.3.17", + "@jridgewell/trace-mapping": "^0.3.20", "jest-worker": "^27.4.5", "schema-utils": "^3.1.1", "serialize-javascript": "^6.0.1", - "terser": "^5.16.8" + "terser": "^5.26.0" }, "engines": { "node": ">= 10.13.0" @@ -26847,9 +26869,9 @@ } }, "node_modules/update-browserslist-db": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.0.tgz", - "integrity": "sha512-EdRAaAyk2cUE1wOf2DkEhzxqOQvFOoRJFNS6NeyJ01Gp2beMRpBAINjM2iDXE3KCuKhwnvHIQCJm6ThL2Z+HzQ==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.1.tgz", + "integrity": "sha512-R8UzCaa9Az+38REPiJ1tXlImTJXlVfgHZsglwBD/k6nj76ctsH1E3q4doGrukiLQd3sGQYu56r5+lo5r94l29A==", "funding": [ { "type": "opencollective", @@ -26865,8 +26887,8 @@ } ], "dependencies": { - "escalade": "^3.1.2", - "picocolors": "^1.0.1" + "escalade": "^3.2.0", + "picocolors": "^1.1.0" }, "bin": { "update-browserslist-db": "cli.js" @@ -27079,9 +27101,9 @@ } }, "node_modules/watchpack": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.0.tgz", - "integrity": "sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg==", + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.2.tgz", + "integrity": "sha512-TnbFSbcOCcDgjZ4piURLCbJ3nJhznVh9kw6F6iokjiFPl8ONxe9A6nMDVXDiNbrSfLILs6vB07F7wLBrwPYzJw==", "dependencies": { "glob-to-regexp": "^0.4.1", "graceful-fs": "^4.1.2" @@ -27139,33 +27161,31 @@ } }, "node_modules/webpack": { - "version": "5.89.0", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.89.0.tgz", - "integrity": "sha512-qyfIC10pOr70V+jkmud8tMfajraGCZMBWJtrmuBymQKCrLTRejBI8STDp1MCyZu/QTdZSeacCQYpYNQVOzX5kw==", - "dependencies": { - "@types/eslint-scope": "^3.7.3", - "@types/estree": "^1.0.0", - "@webassemblyjs/ast": "^1.11.5", - "@webassemblyjs/wasm-edit": "^1.11.5", - "@webassemblyjs/wasm-parser": "^1.11.5", - "acorn": "^8.7.1", - "acorn-import-assertions": "^1.9.0", - "browserslist": "^4.14.5", + "version": "5.96.0", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.96.0.tgz", + "integrity": "sha512-gvn84AfQ4f6vUeNWmFuRp3vGERyxK4epADKTaAo60K0EQbY/YBNQbXH3Ji/ZRK5M25O/XneAOuChF4xQZjQ4xA==", + "dependencies": { + "@types/estree": "^1.0.6", + "@webassemblyjs/ast": "^1.12.1", + "@webassemblyjs/wasm-edit": "^1.12.1", + "@webassemblyjs/wasm-parser": "^1.12.1", + "acorn": "^8.14.0", + "browserslist": "^4.24.0", "chrome-trace-event": "^1.0.2", - "enhanced-resolve": "^5.15.0", + "enhanced-resolve": "^5.17.1", "es-module-lexer": "^1.2.1", "eslint-scope": "5.1.1", "events": "^3.2.0", "glob-to-regexp": "^0.4.1", - "graceful-fs": "^4.2.9", + "graceful-fs": "^4.2.11", "json-parse-even-better-errors": "^2.3.1", "loader-runner": "^4.2.0", "mime-types": "^2.1.27", "neo-async": "^2.6.2", "schema-utils": "^3.2.0", "tapable": "^2.1.1", - "terser-webpack-plugin": "^5.3.7", - "watchpack": "^2.4.0", + "terser-webpack-plugin": "^5.3.10", + "watchpack": "^2.4.1", "webpack-sources": "^3.2.3" }, "bin": { @@ -27185,9 +27205,9 @@ } }, "node_modules/webpack-dev-middleware": { - "version": "5.3.3", - "resolved": "https://registry.npmjs.org/webpack-dev-middleware/-/webpack-dev-middleware-5.3.3.tgz", - "integrity": "sha512-hj5CYrY0bZLB+eTO+x/j67Pkrquiy7kWepMHmUMoPsmcUaeEnQJqFzHJOyxgWlq746/wUuA64p9ta34Kyb01pA==", + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/webpack-dev-middleware/-/webpack-dev-middleware-5.3.4.tgz", + "integrity": "sha512-BVdTqhhs+0IfoeAf7EoH5WE+exCmqGerHfDM0IL096Px60Tq2Mn9MAbnaGUe6HiMa41KMCYF19gyzZmBcq/o4Q==", "dependencies": { "colorette": "^2.0.10", "memfs": "^3.4.3", @@ -28101,9 +28121,9 @@ } }, "node_modules/ws": { - "version": "8.14.2", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.14.2.tgz", - "integrity": "sha512-wEBG1ftX4jcglPxgFCMJmZ2PLtSbJ2Peg6TmpJFTbe9GZYOQCDPdMYu/Tm0/bGZkw8paZnJY45J4K2PZrLYq8g==", + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz", + "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==", "engines": { "node": ">=10.0.0" }, diff --git a/src/QueryCover.jsx b/src/QueryCover.jsx index 47174ef1a..0ed6ae137 100644 --- a/src/QueryCover.jsx +++ b/src/QueryCover.jsx @@ -1,7 +1,6 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import React from "react"; - {/* uncomment below line during development */} - + // {/* uncomment below line during development */} // import { ReactQueryDevtools } from "@tanstack/react-query-devtools"; const QueryCover = ({ children }) => { const queryClient = new QueryClient({ diff --git a/src/Routes.jsx b/src/Routes.jsx index b25df54c5..6f70832cb 100644 --- a/src/Routes.jsx +++ b/src/Routes.jsx @@ -1,4 +1,4 @@ -import React, { lazy, Profiler, Suspense, useEffect } from "react"; +import React, { lazy, Suspense, useEffect, useState } from "react"; import { Navigate, Route, @@ -40,6 +40,9 @@ import useUserProfile from "./hooks/useUserProfile"; import { ConfigProvider } from "antd"; import style from "./style"; import CookieConsent from "./modals/CookieConsent"; +import DeveloperLayout from "./pages/DeveloperLayout"; +import DeveloperHome from "./pages/DeveloperHome"; +import US2024ElectionCalculator from "./applets/US2024ElectionCalculator"; const PolicyPage = lazy(() => import("./pages/PolicyPage")); const HouseholdPage = lazy(() => import("./pages/HouseholdPage")); @@ -56,87 +59,80 @@ function ScrollToTop() { const PolicyEngineRoutes = () => { const countryId = extractCountryId(); - const onRender = ( - id, - phase, - actualDuration, - baseDuration, - startTime, - commitTime, - ) => { - console.log({ - id, - phase, - actualDuration, - baseDuration, - startTime, - commitTime, - }); - }; + // If the path is /, redirect to /[countryId] + // If the path is /[countryId], render the homepage + // If the path is /[countryId]/about, render the about page + // If the path is /[countryId]/jobs, render the jobs page + // If the path is /[countryId]/research, render the research page + // If the path is not recognized, redirect to /[countryId] return ( - - {/* //TODO temporary will be shifting back to policy engine */} - - - - {/* till here */} - - - {/* Redirect from / to /[countryId] */} - } /> - } /> - }> - } /> - } /> - } /> - } /> - } /> + //TODO temporary will be shifting back to policy engine + + + + {/* till here */} + + + {/* Redirect from / to /[countryId] */} + } /> + } /> + }> + } /> + } /> + } /> + } /> + } /> + } /> + }> + } /> } /> - } /> - } /> - } /> - } /> - } /> - - } /> - } /> - - } /> - } /> - } /> - {/* redirect from /countryId/blog/slug to /countryId/research/slug */} - } /> + } /> - } /> - } - /> - } /> - } - /> - } /> - } - /> - - {/* Redirect for unrecognized paths */} - } /> - - - + } /> + } /> + } /> + } /> + } /> + + } /> + } /> + + } /> + } /> + } /> + {/* redirect from /countryId/blog/slug to /countryId/research/slug */} + } /> + + } /> + } /> + } /> + } + /> + } /> + } + /> + } + /> + + {/* Redirect for unrecognized paths */} + } /> + + ); }; @@ -150,11 +146,7 @@ export const LoadingPage = () => ( ); const HouseholdPageLayout = () => { - const { - metadata, - isMetadataLoading, - isMetadataError, - } = useMetadata(); + const { metadata, isMetadataLoading, isMetadataError } = useMetadata(); const { policy, isPolicyLoading, isPolicyError } = usePolicy(); if (isMetadataLoading || isPolicyLoading) { return ; @@ -171,11 +163,7 @@ const HouseholdPageLayout = () => { }; const PolicyPageLayout = () => { - const { - metadata, - isMetadataLoading, - isMetadataError, - } = useMetadata(); + const { metadata, isMetadataLoading, isMetadataError } = useMetadata(); const { policy, isPolicyError, isPolicyLoading } = usePolicy(); const { userProfile, isUserProfileLoading, isUserProfileError } = useUserProfile(); @@ -206,7 +194,7 @@ const SuspenseLayout = ({ children }) => { }; const UserProfileRoute = () => { - const { countryId } = useParams(); + const { countryId } = useParams(); // const countryId = extractCountryId(); const { userProfile, isUserProfileLoading, isUserProfileError } = useUserProfile(); diff --git a/src/hooks/useUserProfile.js b/src/hooks/useUserProfile.js index d5c49cc00..36a16c353 100644 --- a/src/hooks/useUserProfile.js +++ b/src/hooks/useUserProfile.js @@ -46,7 +46,8 @@ const useUserProfile = () => { const countryId = extractCountryId(); const { data, isPending, isError, refetch, error } = useQuery({ - queryKey: ["userProfile", countryId, user?.sub, isAuthenticated], + // eslint-disable-next-line @tanstack/query/exhaustive-deps + queryKey: ["userProfile", user?.sub], queryFn: () => fetchUserProfile(countryId, isAuthenticated, user?.sub), enabled: isAuthenticated && !!user?.sub, onError: (error) => { diff --git a/src/modals/PoliciesModelledPopup.jsx b/src/modals/PoliciesModelledPopup.jsx index 946b17ccf..20994b24e 100644 --- a/src/modals/PoliciesModelledPopup.jsx +++ b/src/modals/PoliciesModelledPopup.jsx @@ -81,11 +81,11 @@ function PoliciesModelledChecklist(props) { export default function PoliciesModelledPopup(props) { const [needToOpenModal, setNeedToOpenModal] = useState(true); + const [hasShownHouseholdPopup, setHasShownHouseholdPopup] = useState(false); const { metadata, householdInput, - hasShownHouseholdPopup, - setHasShownHouseholdPopup, + year, } = props; useEffect(() => { diff --git a/src/pages/HouseholdPage.jsx b/src/pages/HouseholdPage.jsx index 85cf5bc8b..4a19df8b3 100644 --- a/src/pages/HouseholdPage.jsx +++ b/src/pages/HouseholdPage.jsx @@ -33,8 +33,7 @@ export default function HouseholdPage(props) { metadata, householdId, policy, - hasShownHouseholdPopup, - setHasShownHouseholdPopup, + } = props; const countryId = metadata.countryId; const [searchParams, setSearchParams] = useSearchParams(); @@ -326,8 +325,7 @@ export default function HouseholdPage(props) { householdInput={householdInput} policy={policy} loading={loading} - hasShownHouseholdPopup={hasShownHouseholdPopup} - setHasShownHouseholdPopup={setHasShownHouseholdPopup} + year={year} /> diff --git a/src/pages/UserProfilePage.jsx b/src/pages/UserProfilePage.jsx index aab6b462f..e18097590 100644 --- a/src/pages/UserProfilePage.jsx +++ b/src/pages/UserProfilePage.jsx @@ -27,6 +27,7 @@ import moment from "moment"; import { formatCurrencyAbbr } from "../lang/format"; import ErrorPage from "../layout/ErrorPage"; import useMetadata from "../hooks/useMetadata"; +import useUserProfile from "../hooks/useUserProfile"; const STATES = { EMPTY: "empty", @@ -56,12 +57,13 @@ export default function UserProfilePage(props) { // visiting. authedUserProfile is shared via props, as the entire // app has access to this info, while accessedUserProfile requires a fetch - const { authedUserProfile } = props; const { metadata, metadataError, } = useMetadata(); + const { userProfile:authedUserProfile} = + useUserProfile(); let params = useParams(); diff --git a/src/pages/household/output/HouseholdOutput.jsx b/src/pages/household/output/HouseholdOutput.jsx index 8f9956edc..b5957cc61 100644 --- a/src/pages/household/output/HouseholdOutput.jsx +++ b/src/pages/household/output/HouseholdOutput.jsx @@ -23,8 +23,7 @@ export default function HouseholdOutput(props) { householdBaseline, householdReform, loading, - hasShownHouseholdPopup, - setHasShownHouseholdPopup, + year, } = props; const mobile = useMobile(); @@ -50,8 +49,7 @@ export default function HouseholdOutput(props) { )} From 1906cf82255055222e3e4c3ac03f8f6cf16cb698 Mon Sep 17 00:00:00 2001 From: bharateshwq Date: Fri, 1 Nov 2024 18:18:02 +0530 Subject: [PATCH 7/7] merge issues --- package-lock.json | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/package-lock.json b/package-lock.json index c1d65475c..a1f7a63ac 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,9 +14,6 @@ "@n8tb1t/use-scroll-position": "^2.0.3", "@tanstack/react-query": "^5.59.0", "@tanstack/react-query-devtools": "^5.59.0", - "@uiw/codemirror-extensions-langs": "^4.23.0", - "@uiw/codemirror-theme-github": "^4.23.0", - "@uiw/react-codemirror": "^4.23.0", "@testing-library/dom": "^10.4.0", "@uiw/codemirror-extensions-langs": "^4.23.3", "@uiw/codemirror-theme-github": "^4.23.3", @@ -5584,10 +5581,6 @@ "react": "^18 || ^19" } }, - "node_modules/@testing-library/dom": { - "version": "10.4.0", - "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.4.0.tgz", - "integrity": "sha512-pemlzrSESWbdAloYml3bAJMEfNh1Z7EduzqPKprCH5S341frlpYnUEW0H72dLxa6IsYr+mPno20GiSm+h9dEdQ==", "node_modules/@testing-library/dom": { "version": "10.4.0", "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.4.0.tgz", @@ -12020,19 +12013,6 @@ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" }, - "node_modules/fsevents": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", - "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", - "hasInstallScript": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, "node_modules/function-bind": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",