diff --git a/newdle/client/package-lock.json b/newdle/client/package-lock.json index 7b34b763e..751114e39 100644 --- a/newdle/client/package-lock.json +++ b/newdle/client/package-lock.json @@ -26,8 +26,8 @@ "react-final-form": "^6.5.9", "react-redux": "^8.0.2", "react-responsive": "^9.0.0-beta.10", - "react-router": "^5.2.0", - "react-router-dom": "^5.2.0", + "react-router": "^6.3.0", + "react-router-dom": "^6.3.0", "react-scripts": "5.0.1", "redux": "^4.2.0", "redux-devtools-extension": "^2.13.9", @@ -10288,16 +10288,11 @@ } }, "node_modules/history": { - "version": "4.10.1", - "resolved": "https://registry.npmjs.org/history/-/history-4.10.1.tgz", - "integrity": "sha512-36nwAD620w12kuzPAsyINPWJqlNbij+hpK1k9XRloDtym8mxzGYl2c17LnV6IAGB2Dmg4tEa7G7DlawS0+qjew==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/history/-/history-5.3.0.tgz", + "integrity": "sha512-ZqaKwjjrAYUYfLG+htGaIIZ4nioX2L70ZUMIFysS3xvBsSG4x/n1V6TXV3N8ZYNuFGlDirFg32T7B6WOUPDYcQ==", "dependencies": { - "@babel/runtime": "^7.1.2", - "loose-envify": "^1.2.0", - "resolve-pathname": "^3.0.0", - "tiny-invariant": "^1.0.2", - "tiny-warning": "^1.0.0", - "value-equal": "^1.0.1" + "@babel/runtime": "^7.7.6" } }, "node_modules/hoist-non-react-statics": { @@ -11260,11 +11255,6 @@ "node": ">=8" } }, - "node_modules/isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==" - }, "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", @@ -15316,19 +15306,6 @@ "node": ">=4" } }, - "node_modules/mini-create-react-context": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/mini-create-react-context/-/mini-create-react-context-0.4.1.tgz", - "integrity": "sha512-YWCYEmd5CQeHGSAKrYvXgmzzkrvssZcuuQDDeqkT+PziKGMgE+0MCCtcKbROzocGBG1meBLl2FotlRwf4gAzbQ==", - "dependencies": { - "@babel/runtime": "^7.12.1", - "tiny-warning": "^1.0.3" - }, - "peerDependencies": { - "prop-types": "^15.0.0", - "react": "^0.14.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" - } - }, "node_modules/mini-css-extract-plugin": { "version": "2.6.1", "resolved": "https://registry.npmjs.org/mini-css-extract-plugin/-/mini-css-extract-plugin-2.6.1.tgz", @@ -16483,14 +16460,6 @@ "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==" }, - "node_modules/path-to-regexp": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.8.0.tgz", - "integrity": "sha512-n43JRhlUKUAlibEJhPeir1ncUID16QnEjNpwzNdO3Lm4ywrBpBZ5oLD0I6br9evr1Y9JTqwRtAh7JLoOzAQdVA==", - "dependencies": { - "isarray": "0.0.1" - } - }, "node_modules/path-type": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", @@ -18765,40 +18734,27 @@ } }, "node_modules/react-router": { - "version": "5.3.3", - "resolved": "https://registry.npmjs.org/react-router/-/react-router-5.3.3.tgz", - "integrity": "sha512-mzQGUvS3bM84TnbtMYR8ZjKnuPJ71IjSzR+DE6UkUqvN4czWIqEs17yLL8xkAycv4ev0AiN+IGrWu88vJs/p2w==", - "dependencies": { - "@babel/runtime": "^7.12.13", - "history": "^4.9.0", - "hoist-non-react-statics": "^3.1.0", - "loose-envify": "^1.3.1", - "mini-create-react-context": "^0.4.0", - "path-to-regexp": "^1.7.0", - "prop-types": "^15.6.2", - "react-is": "^16.6.0", - "tiny-invariant": "^1.0.2", - "tiny-warning": "^1.0.0" + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.3.0.tgz", + "integrity": "sha512-7Wh1DzVQ+tlFjkeo+ujvjSqSJmkt1+8JO+T5xklPlgrh70y7ogx75ODRW0ThWhY7S+6yEDks8TYrtQe/aoboBQ==", + "dependencies": { + "history": "^5.2.0" }, "peerDependencies": { - "react": ">=15" + "react": ">=16.8" } }, "node_modules/react-router-dom": { - "version": "5.3.3", - "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-5.3.3.tgz", - "integrity": "sha512-Ov0tGPMBgqmbu5CDmN++tv2HQ9HlWDuWIIqn4b88gjlAN5IHI+4ZUZRcpz9Hl0azFIwihbLDYw1OiHGRo7ZIng==", + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.3.0.tgz", + "integrity": "sha512-uaJj7LKytRxZNQV8+RbzJWnJ8K2nPsOOEuX7aQstlMZKQT0164C+X2w6bnkqU3sjtLvpd5ojrezAyfZ1+0sStw==", "dependencies": { - "@babel/runtime": "^7.12.13", - "history": "^4.9.0", - "loose-envify": "^1.3.1", - "prop-types": "^15.6.2", - "react-router": "5.3.3", - "tiny-invariant": "^1.0.2", - "tiny-warning": "^1.0.0" + "history": "^5.2.0", + "react-router": "6.3.0" }, "peerDependencies": { - "react": ">=15" + "react": ">=16.8", + "react-dom": ">=16.8" } }, "node_modules/react-scripts": { @@ -19555,11 +19511,6 @@ "node": ">=4" } }, - "node_modules/resolve-pathname": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/resolve-pathname/-/resolve-pathname-3.0.0.tgz", - "integrity": "sha512-C7rARubxI8bXFNB/hqcp/4iUeIXJhJZvFPFPiSPRnhU5UPxzMFIl+2E6yY6c4k9giDJAhtV+enfA+G89N6Csng==" - }, "node_modules/resolve-url-loader": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/resolve-url-loader/-/resolve-url-loader-4.0.0.tgz", @@ -21205,16 +21156,6 @@ "resolved": "https://registry.npmjs.org/thunky/-/thunky-1.1.0.tgz", "integrity": "sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA==" }, - "node_modules/tiny-invariant": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.2.0.tgz", - "integrity": "sha512-1Uhn/aqw5C6RI4KejVeTg6mIS7IqxnLJ8Mv2tV5rTc0qWobay7pDUz6Wi392Cnc8ak1H0F2cjoRzb2/AW4+Fvg==" - }, - "node_modules/tiny-warning": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/tiny-warning/-/tiny-warning-1.0.3.tgz", - "integrity": "sha512-lBN9zLN/oAf68o3zNXYrdCt1kP8WsiGW8Oo2ka41b2IM5JL/S1CTyX1rW0mb/zSuJun0ZUrDxx4sqvYS2FWzPA==" - }, "node_modules/tmp": { "version": "0.0.33", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", @@ -21701,11 +21642,6 @@ "spdx-expression-parse": "^3.0.0" } }, - "node_modules/value-equal": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/value-equal/-/value-equal-1.0.1.tgz", - "integrity": "sha512-NOJ6JZCAWr0zlxZt+xqCHNTEKOsrks2HQd4MqhP1qy4z1SkbEP467eNx6TgDKXMvUOb+OENfJCZwM+16n7fRfw==" - }, "node_modules/vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", @@ -30071,16 +30007,11 @@ "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==" }, "history": { - "version": "4.10.1", - "resolved": "https://registry.npmjs.org/history/-/history-4.10.1.tgz", - "integrity": "sha512-36nwAD620w12kuzPAsyINPWJqlNbij+hpK1k9XRloDtym8mxzGYl2c17LnV6IAGB2Dmg4tEa7G7DlawS0+qjew==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/history/-/history-5.3.0.tgz", + "integrity": "sha512-ZqaKwjjrAYUYfLG+htGaIIZ4nioX2L70ZUMIFysS3xvBsSG4x/n1V6TXV3N8ZYNuFGlDirFg32T7B6WOUPDYcQ==", "requires": { - "@babel/runtime": "^7.1.2", - "loose-envify": "^1.2.0", - "resolve-pathname": "^3.0.0", - "tiny-invariant": "^1.0.2", - "tiny-warning": "^1.0.0", - "value-equal": "^1.0.1" + "@babel/runtime": "^7.7.6" } }, "hoist-non-react-statics": { @@ -30764,11 +30695,6 @@ "is-docker": "^2.0.0" } }, - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==" - }, "isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", @@ -33822,15 +33748,6 @@ "integrity": "sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==", "devOptional": true }, - "mini-create-react-context": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/mini-create-react-context/-/mini-create-react-context-0.4.1.tgz", - "integrity": "sha512-YWCYEmd5CQeHGSAKrYvXgmzzkrvssZcuuQDDeqkT+PziKGMgE+0MCCtcKbROzocGBG1meBLl2FotlRwf4gAzbQ==", - "requires": { - "@babel/runtime": "^7.12.1", - "tiny-warning": "^1.0.3" - } - }, "mini-css-extract-plugin": { "version": "2.6.1", "resolved": "https://registry.npmjs.org/mini-css-extract-plugin/-/mini-css-extract-plugin-2.6.1.tgz", @@ -34677,14 +34594,6 @@ "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==" }, - "path-to-regexp": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.8.0.tgz", - "integrity": "sha512-n43JRhlUKUAlibEJhPeir1ncUID16QnEjNpwzNdO3Lm4ywrBpBZ5oLD0I6br9evr1Y9JTqwRtAh7JLoOzAQdVA==", - "requires": { - "isarray": "0.0.1" - } - }, "path-type": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", @@ -36153,34 +36062,20 @@ } }, "react-router": { - "version": "5.3.3", - "resolved": "https://registry.npmjs.org/react-router/-/react-router-5.3.3.tgz", - "integrity": "sha512-mzQGUvS3bM84TnbtMYR8ZjKnuPJ71IjSzR+DE6UkUqvN4czWIqEs17yLL8xkAycv4ev0AiN+IGrWu88vJs/p2w==", - "requires": { - "@babel/runtime": "^7.12.13", - "history": "^4.9.0", - "hoist-non-react-statics": "^3.1.0", - "loose-envify": "^1.3.1", - "mini-create-react-context": "^0.4.0", - "path-to-regexp": "^1.7.0", - "prop-types": "^15.6.2", - "react-is": "^16.6.0", - "tiny-invariant": "^1.0.2", - "tiny-warning": "^1.0.0" + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.3.0.tgz", + "integrity": "sha512-7Wh1DzVQ+tlFjkeo+ujvjSqSJmkt1+8JO+T5xklPlgrh70y7ogx75ODRW0ThWhY7S+6yEDks8TYrtQe/aoboBQ==", + "requires": { + "history": "^5.2.0" } }, "react-router-dom": { - "version": "5.3.3", - "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-5.3.3.tgz", - "integrity": "sha512-Ov0tGPMBgqmbu5CDmN++tv2HQ9HlWDuWIIqn4b88gjlAN5IHI+4ZUZRcpz9Hl0azFIwihbLDYw1OiHGRo7ZIng==", + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.3.0.tgz", + "integrity": "sha512-uaJj7LKytRxZNQV8+RbzJWnJ8K2nPsOOEuX7aQstlMZKQT0164C+X2w6bnkqU3sjtLvpd5ojrezAyfZ1+0sStw==", "requires": { - "@babel/runtime": "^7.12.13", - "history": "^4.9.0", - "loose-envify": "^1.3.1", - "prop-types": "^15.6.2", - "react-router": "5.3.3", - "tiny-invariant": "^1.0.2", - "tiny-warning": "^1.0.0" + "history": "^5.2.0", + "react-router": "6.3.0" } }, "react-scripts": { @@ -36765,11 +36660,6 @@ "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==" }, - "resolve-pathname": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/resolve-pathname/-/resolve-pathname-3.0.0.tgz", - "integrity": "sha512-C7rARubxI8bXFNB/hqcp/4iUeIXJhJZvFPFPiSPRnhU5UPxzMFIl+2E6yY6c4k9giDJAhtV+enfA+G89N6Csng==" - }, "resolve-url-loader": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/resolve-url-loader/-/resolve-url-loader-4.0.0.tgz", @@ -38015,16 +37905,6 @@ "resolved": "https://registry.npmjs.org/thunky/-/thunky-1.1.0.tgz", "integrity": "sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA==" }, - "tiny-invariant": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.2.0.tgz", - "integrity": "sha512-1Uhn/aqw5C6RI4KejVeTg6mIS7IqxnLJ8Mv2tV5rTc0qWobay7pDUz6Wi392Cnc8ak1H0F2cjoRzb2/AW4+Fvg==" - }, - "tiny-warning": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/tiny-warning/-/tiny-warning-1.0.3.tgz", - "integrity": "sha512-lBN9zLN/oAf68o3zNXYrdCt1kP8WsiGW8Oo2ka41b2IM5JL/S1CTyX1rW0mb/zSuJun0ZUrDxx4sqvYS2FWzPA==" - }, "tmp": { "version": "0.0.33", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", @@ -38387,11 +38267,6 @@ "spdx-expression-parse": "^3.0.0" } }, - "value-equal": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/value-equal/-/value-equal-1.0.1.tgz", - "integrity": "sha512-NOJ6JZCAWr0zlxZt+xqCHNTEKOsrks2HQd4MqhP1qy4z1SkbEP467eNx6TgDKXMvUOb+OENfJCZwM+16n7fRfw==" - }, "vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", diff --git a/newdle/client/package.json b/newdle/client/package.json index c2598d932..809c60a4c 100644 --- a/newdle/client/package.json +++ b/newdle/client/package.json @@ -21,8 +21,8 @@ "react-final-form": "^6.5.9", "react-redux": "^8.0.2", "react-responsive": "^9.0.0-beta.10", - "react-router": "^5.2.0", - "react-router-dom": "^5.2.0", + "react-router": "^6.3.0", + "react-router-dom": "^6.3.0", "react-scripts": "5.0.1", "redux": "^4.2.0", "redux-devtools-extension": "^2.13.9", diff --git a/newdle/client/src/components/App.js b/newdle/client/src/components/App.js index 5ec494c1a..f127fae73 100644 --- a/newdle/client/src/components/App.js +++ b/newdle/client/src/components/App.js @@ -1,6 +1,6 @@ import React from 'react'; import {useSelector} from 'react-redux'; -import {BrowserRouter as Router, Route, Switch} from 'react-router-dom'; +import {BrowserRouter as Router, Route, Routes} from 'react-router-dom'; import {i18n} from '@lingui/core'; import {I18nProvider} from '@lingui/react'; import {isLoginWindowOpen, getErrors} from '../selectors'; @@ -31,18 +31,19 @@ export default function App() { ))}
- - - - - - - - - - -
This page does not exist
} /> -
+ + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + This page does not exist} /> +
{loggingIn && } diff --git a/newdle/client/src/components/ErrorMessage.js b/newdle/client/src/components/ErrorMessage.js index 8f788f094..80f30d3a6 100644 --- a/newdle/client/src/components/ErrorMessage.js +++ b/newdle/client/src/components/ErrorMessage.js @@ -1,6 +1,6 @@ import React, {useEffect} from 'react'; import {useDispatch} from 'react-redux'; -import {useHistory} from 'react-router'; +import {useNavigate} from 'react-router'; import {t} from '@lingui/macro'; import PropTypes from 'prop-types'; import {Message, TransitionablePortal} from 'semantic-ui-react'; @@ -8,15 +8,16 @@ import {clearError, removeError} from '../actions'; import styles from './ErrorMessage.module.scss'; export default function ErrorMessage({id, error}) { - const history = useHistory(); + const navigate = useNavigate(); const dispatch = useDispatch(); - useEffect(() => { - // Remove the callback defined with `listen` once the component gets unmounted - return history.listen(() => { - dispatch(clearError()); - }); - }, [dispatch, history]); + // TODO - find out how to do this in react-router 6 + // useEffect(() => { + // // Remove the callback defined with `listen` once the component gets unmounted + // return history.listen(() => { + // dispatch(clearError()); + // }); + // }, [dispatch, navigate]); return ( Object.keys(x.answers).length !== 0); return ( -
history.push(url)}> +
navigate(url)}>

evt.preventDefault()}> {title} diff --git a/newdle/client/src/components/NewdleTitle.js b/newdle/client/src/components/NewdleTitle.js index 6d24448cb..ea7a7d4aa 100644 --- a/newdle/client/src/components/NewdleTitle.js +++ b/newdle/client/src/components/NewdleTitle.js @@ -1,6 +1,6 @@ import React, {useEffect} from 'react'; import {useSelector, useDispatch} from 'react-redux'; -import {useHistory, useRouteMatch} from 'react-router'; +import {useNavigate, useMatch} from 'react-router'; import {Trans, t} from '@lingui/macro'; import PropTypes from 'prop-types'; import {Container, Icon, Button, Popup, Divider, Label} from 'semantic-ui-react'; @@ -26,12 +26,12 @@ export default function NewdleTitle({ const isMobile = useIsMobile(); const gridViewActive = useSelector(getGridViewActive); const hasParticipants = useSelector(getNumberOfParticipants) > 0; - const history = useHistory(); + const navigate = useNavigate(); const dispatch = useDispatch(); // TODO: Find a routing solution that doesn't push the same route to the history - const isSummaryRoute = !!useRouteMatch({path: '/newdle/:code/summary'}); - const isEditing = !!useRouteMatch({path: '/newdle/:code/edit'}); + const isSummaryRoute = !!useMatch({path: '/newdle/:code/summary'}); + const isEditing = !!useMatch({path: '/newdle/:code/edit'}); const summaryURL = `/newdle/${code}/summary`; const answerURL = `/newdle/${code}/${participantCode || ''}`; @@ -85,7 +85,7 @@ export default function NewdleTitle({ icon active={!isEditing && !isSummaryRoute} // Prevent the same route from being pushed to the history again - onClick={() => (isSummaryRoute || isEditing ? history.push(answerURL) : null)} + onClick={() => (isSummaryRoute || isEditing ? navigate(answerURL) : null)} disabled={finished} > @@ -99,7 +99,7 @@ export default function NewdleTitle({ diff --git a/newdle/client/src/components/NewdlesParticipating.js b/newdle/client/src/components/NewdlesParticipating.js index 8955f88de..946e954fd 100644 --- a/newdle/client/src/components/NewdlesParticipating.js +++ b/newdle/client/src/components/NewdlesParticipating.js @@ -1,5 +1,5 @@ import React from 'react'; -import {useHistory} from 'react-router'; +import {useNavigate} from 'react-router'; import {Trans, Plural, t} from '@lingui/macro'; import flask from 'flask-urls.macro'; import PropTypes from 'prop-types'; @@ -65,7 +65,7 @@ function NewdleParticipation({ answers, participant_code, }) { - const history = useHistory(); + const navigate = useNavigate(); const startTime = finalDT && serializeDate(finalDT, 'HH:mm'); const endTime = finalDT && serializeDate(toMoment(finalDT).add(duration, 'm'), 'HH:mm'); const url = flask`newdle`({code, participant_code}); @@ -74,7 +74,7 @@ function NewdleParticipation({ ); return ( -
history.push(url)}> +
navigate(url)}>

evt.preventDefault()}> {title} diff --git a/newdle/client/src/components/TopHeader.js b/newdle/client/src/components/TopHeader.js index a90ab0891..55c11cb95 100644 --- a/newdle/client/src/components/TopHeader.js +++ b/newdle/client/src/components/TopHeader.js @@ -1,5 +1,5 @@ import React from 'react'; -import {Route, Switch, Link} from 'react-router-dom'; +import {Route, Routes, Link} from 'react-router-dom'; import {t} from '@lingui/macro'; import {Grid, Header, Image} from 'semantic-ui-react'; import logo from '../images/logo.svg'; @@ -29,13 +29,16 @@ export default function TopHeader() { - - - - - - - + + } /> + } /> + } /> + } /> + } /> + } /> + {/* avoid warning on pages where we do not have a top header */} + + diff --git a/newdle/client/src/components/UnloadPrompt.js b/newdle/client/src/components/UnloadPrompt.js index a53994ad6..0cb8d24f2 100644 --- a/newdle/client/src/components/UnloadPrompt.js +++ b/newdle/client/src/components/UnloadPrompt.js @@ -1,5 +1,5 @@ import React, {useEffect} from 'react'; -import {Prompt} from 'react-router'; +// import {Prompt} from 'react-router'; import {t} from '@lingui/macro'; import PropTypes from 'prop-types'; @@ -24,7 +24,10 @@ function UnloadPrompt({active, router, message}) { }; }, [active, message]); - return router ? : null; + // TODO: wait for react-router 6 to bring back support for this... + // --> https://github.com/remix-run/react-router/issues/8139 + // return router ? : null; + return null; } UnloadPrompt.propTypes = { diff --git a/newdle/client/src/components/UserMenu.js b/newdle/client/src/components/UserMenu.js index 3660bbe70..38ab54862 100644 --- a/newdle/client/src/components/UserMenu.js +++ b/newdle/client/src/components/UserMenu.js @@ -1,6 +1,6 @@ import React from 'react'; import {useSelector} from 'react-redux'; -import {useHistory} from 'react-router'; +import {useNavigate} from 'react-router'; import {Trans} from '@lingui/macro'; import {Dropdown, Icon} from 'semantic-ui-react'; import {useAuthentication} from '../auth'; @@ -9,7 +9,7 @@ import UserAvatar from './UserAvatar'; import styles from './UserMenu.module.scss'; export default function UserMenu() { - const history = useHistory(); + const navigate = useNavigate(); const user = useSelector(getUserInfo); const {login, logout} = useAuthentication(); const isUserLoggedIn = useSelector(isLoggedIn); @@ -33,7 +33,7 @@ export default function UserMenu() { href="/mine" onClick={evt => { evt.preventDefault(); - history.push('/mine'); + navigate('/mine'); }} > My newdles @@ -42,7 +42,7 @@ export default function UserMenu() { href="/participating" onClick={evt => { evt.preventDefault(); - history.push('/participating'); + navigate('/participating'); }} > Newdles I'm in diff --git a/newdle/client/src/components/answer/AnswerHeader.js b/newdle/client/src/components/answer/AnswerHeader.js index 60f984f17..140e2cdfc 100644 --- a/newdle/client/src/components/answer/AnswerHeader.js +++ b/newdle/client/src/components/answer/AnswerHeader.js @@ -1,13 +1,13 @@ import React, {useEffect} from 'react'; import {useDispatch, useSelector} from 'react-redux'; -import PropTypes from 'prop-types'; +import {useParams} from 'react-router'; import {getUserInfo} from 'src/selectors'; import {abortAnswering, fetchNewdleForAnswer, clearNewdle, fetchNewdle} from '../../actions'; import {getNewdle} from '../../answerSelectors'; import NewdleTitle from '../NewdleTitle'; -export default function AnswerHeader({match}) { - const code = match.params.code; +export default function AnswerHeader() { + const {code} = useParams(); const newdle = useSelector(getNewdle); const user = useSelector(getUserInfo) || {}; const dispatch = useDispatch(); @@ -50,11 +50,3 @@ export default function AnswerHeader({match}) { /> ); } - -AnswerHeader.propTypes = { - match: PropTypes.shape({ - params: PropTypes.shape({ - code: PropTypes.string.isRequired, - }).isRequired, - }).isRequired, -}; diff --git a/newdle/client/src/components/answer/AnswerPage.js b/newdle/client/src/components/answer/AnswerPage.js index 865121d3c..87cb9ebdb 100644 --- a/newdle/client/src/components/answer/AnswerPage.js +++ b/newdle/client/src/components/answer/AnswerPage.js @@ -1,6 +1,6 @@ import React, {useEffect, useState} from 'react'; import {useDispatch, useSelector} from 'react-redux'; -import {useHistory} from 'react-router'; +import {useNavigate} from 'react-router'; import {useParams} from 'react-router-dom'; import {Trans, Plural, t} from '@lingui/macro'; import PropTypes from 'prop-types'; @@ -151,7 +151,7 @@ export default function AnswerPage() { const allAvailableDisabled = useSelector(isAllAvailableSelectedImplicitly); const dates = useSelector(getCalendarDates); const [name, setName] = useState(''); - const history = useHistory(); + const navigate = useNavigate(); const user = useSelector(getUserInfo); const isCreator = user !== null && newdle !== null && user.uid === newdle.creator_uid; const participantAnswers = useSelector(getParticipantAnswers); @@ -185,7 +185,7 @@ export default function AnswerPage() { if (!participantCode) { // replace history entry if we are logged in (as going back would instantly redirect // you back to your participant); otherwise push it - history[user ? 'replace' : 'push'](`/newdle/${newdle.code}/${result.code}`); + navigate(`/newdle/${newdle.code}/${result.code}`, {replace: !!user}); } return result; }, @@ -217,9 +217,9 @@ export default function AnswerPage() { useEffect(() => { if (newdle && user && !participantCode && participant) { - history.replace(`/newdle/${newdle.code}/${participant.code}`); + navigate(`/newdle/${newdle.code}/${participant.code}`, {replace: true}); } - }, [newdle, user, participant, history, participantCode]); + }, [newdle, user, participant, navigate, participantCode]); useEffect(() => { if ((participantCode && !participantUnknown) || (!participantCode && user)) { diff --git a/newdle/client/src/components/creation/ClonePage.js b/newdle/client/src/components/creation/ClonePage.js index d8c3c1c43..1fad3c4dc 100644 --- a/newdle/client/src/components/creation/ClonePage.js +++ b/newdle/client/src/components/creation/ClonePage.js @@ -1,8 +1,8 @@ import 'moment-timezone'; import React, {useState} from 'react'; import {useSelector} from 'react-redux'; -import {useHistory} from 'react-router'; -import {Redirect} from 'react-router-dom'; +import {useNavigate} from 'react-router'; +import {Navigate} from 'react-router-dom'; import {t, Trans} from '@lingui/macro'; import _ from 'lodash'; import moment from 'moment'; @@ -25,7 +25,7 @@ import styles from './creation.module.scss'; export default function ClonePage() { const isUserLoggedIn = useSelector(isLoggedIn); const newdle = useSelector(getCreatedNewdle); - const history = useHistory(); + const navigate = useNavigate(); const [keepSettings, setKeepSettings] = useState(true); const [keepParticipants, setKeepParticipants] = useState(true); const [keepTimeslots, setKeepTimeslots] = useState(true); @@ -34,7 +34,7 @@ export default function ClonePage() { usePageTitle(t`Clone newdle`); if (!isUserLoggedIn) { - return ; + return ; } if (!newdle) { return ; @@ -44,7 +44,7 @@ export default function ClonePage() { function cloneNewdle() { const dayOffset = getDayOffset(newdle.timeslots, newdle.timezone, option, startDate); - history.push({ + navigate({ pathname: `/new`, state: { cloneData: { diff --git a/newdle/client/src/components/creation/CreationPage.js b/newdle/client/src/components/creation/CreationPage.js index b5bcb7343..b5b208cd2 100644 --- a/newdle/client/src/components/creation/CreationPage.js +++ b/newdle/client/src/components/creation/CreationPage.js @@ -1,6 +1,6 @@ import React, {useEffect} from 'react'; import {useDispatch, useSelector} from 'react-redux'; -import {Redirect, useLocation} from 'react-router-dom'; +import {Navigate, useLocation} from 'react-router-dom'; import {t} from '@lingui/macro'; import { abortCreation, @@ -62,7 +62,7 @@ export default function CreationPage() { }, [dispatch, location.state]); if (!isUserLoggedIn) { - return ; + return ; } return ( diff --git a/newdle/client/src/components/creation/CreationSuccessPage.js b/newdle/client/src/components/creation/CreationSuccessPage.js index 5b9a8ff1a..903904ea6 100644 --- a/newdle/client/src/components/creation/CreationSuccessPage.js +++ b/newdle/client/src/components/creation/CreationSuccessPage.js @@ -1,7 +1,7 @@ import React from 'react'; import {useSelector} from 'react-redux'; -import {useHistory} from 'react-router'; -import {Redirect} from 'react-router-dom'; +import {useNavigate} from 'react-router'; +import {Navigate} from 'react-router-dom'; import {Trans, t} from '@lingui/macro'; import {Button, Container, Header, Input, Popup} from 'semantic-ui-react'; import {getCreatedNewdle} from '../../selectors'; @@ -10,15 +10,15 @@ import styles from './CreationSuccessPage.module.scss'; export default function CreationSuccessPage() { const newdle = useSelector(getCreatedNewdle); - const history = useHistory(); + const navigate = useNavigate(); usePageTitle(t`Newdle created`); if (!newdle) { - return ; + return ; } const handleSummaryClick = () => { - history.push(`/newdle/${newdle.code}/summary`); + navigate(`/newdle/${newdle.code}/summary`); }; return ( diff --git a/newdle/client/src/components/creation/EditPage.js b/newdle/client/src/components/creation/EditPage.js index d4c006808..b4de66c9e 100644 --- a/newdle/client/src/components/creation/EditPage.js +++ b/newdle/client/src/components/creation/EditPage.js @@ -1,6 +1,6 @@ import React, {useEffect} from 'react'; import {useDispatch, useSelector} from 'react-redux'; -import {Redirect, Route, Switch, useParams} from 'react-router-dom'; +import {Navigate, Route, Routes, useParams} from 'react-router-dom'; import {t} from '@lingui/macro'; import {Loader} from 'semantic-ui-react'; import {fetchNewdle} from '../../actions'; @@ -24,22 +24,18 @@ export default function EditPage() { }, [dispatch, newdle, newdleCode]); if (!isUserLoggedIn) { - return ; + return ; } if (!newdle) { return ; } return ( - - - } /> - } - /> - } /> - + + } /> + } /> + } /> + } /> + ); } diff --git a/newdle/client/src/components/creation/FinalStep.js b/newdle/client/src/components/creation/FinalStep.js index e8127f3fb..8c23c5e52 100644 --- a/newdle/client/src/components/creation/FinalStep.js +++ b/newdle/client/src/components/creation/FinalStep.js @@ -1,6 +1,6 @@ import React, {useState} from 'react'; import {useDispatch, useSelector} from 'react-redux'; -import {useHistory} from 'react-router'; +import {useNavigate} from 'react-router'; import {t, Trans} from '@lingui/macro'; import PropTypes from 'prop-types'; import {Button, Container, Header, Icon, Input, Checkbox} from 'semantic-ui-react'; @@ -39,7 +39,7 @@ export default function FinalStep({isEditing}) { const timezone = useSelector(getTimezone); const activeNewdle = useSelector(getCreatedNewdle); const dispatch = useDispatch(); - const history = useHistory(); + const navigate = useNavigate(); const [_createNewdle, createSubmitting] = client.useBackendLazy(client.createNewdle); const [_editNewdle, editSubmitting] = client.useBackendLazy(client.updateNewdle); const [showAdvancedOptions, setShowAdvancedOptions] = useState(isEditing); @@ -62,7 +62,7 @@ export default function FinalStep({isEditing}) { if (newdle) { dispatch(newdleCreated(newdle)); - history.push('/new/success'); + navigate('/new/success'); } } @@ -71,7 +71,7 @@ export default function FinalStep({isEditing}) { if (newdle) { dispatch(updateNewdle(newdle)); - history.push(`/newdle/${newdle.code}/summary`); + navigate(`/newdle/${newdle.code}/summary`); } } diff --git a/newdle/client/src/components/creation/ParticipantsStep.js b/newdle/client/src/components/creation/ParticipantsStep.js index 3189041a1..0ea6665e0 100644 --- a/newdle/client/src/components/creation/ParticipantsStep.js +++ b/newdle/client/src/components/creation/ParticipantsStep.js @@ -1,6 +1,6 @@ import React from 'react'; import {useDispatch, useSelector} from 'react-redux'; -import {useHistory} from 'react-router'; +import {useNavigate} from 'react-router'; import {t, Trans} from '@lingui/macro'; import PropTypes from 'prop-types'; import {Button, Container, Icon, Message} from 'semantic-ui-react'; @@ -16,7 +16,7 @@ export default function ParticipantsStep({isEditing, isCloning}) { const participantsDefined = useSelector(areParticipantsDefined); const participants = useSelector(getParticipants); const activeNewdle = useSelector(getCreatedNewdle); - const history = useHistory(); + const navigate = useNavigate(); const [_editNewdle, submitting] = client.useBackendLazy(client.updateNewdle); async function editNewdle() { @@ -25,7 +25,7 @@ export default function ParticipantsStep({isEditing, isCloning}) { if (newdle) { dispatch(clearParticipantCodes(newdle.code)); dispatch(updateNewdle(newdle)); - history.push(`/newdle/${newdle.code}/summary`); + navigate(`/newdle/${newdle.code}/summary`); } } diff --git a/newdle/client/src/components/creation/timeslots/TimeslotsStep.js b/newdle/client/src/components/creation/timeslots/TimeslotsStep.js index de25c7ff9..45fa4c2eb 100644 --- a/newdle/client/src/components/creation/timeslots/TimeslotsStep.js +++ b/newdle/client/src/components/creation/timeslots/TimeslotsStep.js @@ -1,6 +1,6 @@ import React from 'react'; import {useDispatch, useSelector} from 'react-redux'; -import {useHistory} from 'react-router'; +import {useNavigate} from 'react-router'; import {Trans, Plural} from '@lingui/macro'; import _ from 'lodash'; import PropTypes from 'prop-types'; @@ -46,7 +46,7 @@ export default function TimeslotsStep({isEditing}) { const duration = useSelector(getDuration); const timezone = useSelector(getTimezone); const activeNewdle = useSelector(getCreatedNewdle); - const history = useHistory(); + const navigate = useNavigate(); const [_editNewdle, submitting] = client.useBackendLazy(client.updateNewdle); async function editNewdle() { @@ -54,7 +54,7 @@ export default function TimeslotsStep({isEditing}) { if (newdle) { dispatch(updateNewdle(newdle)); - history.push(`/newdle/${newdle.code}/summary`); + navigate(`/newdle/${newdle.code}/summary`); } } diff --git a/newdle/client/src/components/home/HomePage.js b/newdle/client/src/components/home/HomePage.js index e4abe6996..91bfb3283 100644 --- a/newdle/client/src/components/home/HomePage.js +++ b/newdle/client/src/components/home/HomePage.js @@ -1,5 +1,5 @@ import React from 'react'; -import {useHistory} from 'react-router'; +import {useNavigate} from 'react-router'; import {Trans} from '@lingui/macro'; import {Icon} from 'semantic-ui-react'; import {Button} from 'semantic-ui-react'; @@ -10,7 +10,7 @@ import LoginRequired from '../login/LoginRequired'; import styles from './HomePage.module.scss'; export default function HomePage() { - const history = useHistory(); + const navigate = useNavigate(); return (
@@ -48,7 +48,7 @@ export default function HomePage() { labelPosition="right" size="big" onClick={() => { - history.push('/new'); + navigate('/new'); }} > Get started diff --git a/newdle/client/src/components/login/LoginPrompt.js b/newdle/client/src/components/login/LoginPrompt.js index b0be10073..ebdfbefdd 100644 --- a/newdle/client/src/components/login/LoginPrompt.js +++ b/newdle/client/src/components/login/LoginPrompt.js @@ -1,6 +1,6 @@ import React from 'react'; import {useDispatch, useSelector} from 'react-redux'; -import {useHistory} from 'react-router'; +import {useNavigate} from 'react-router'; import {t} from '@lingui/macro'; import {Modal} from 'semantic-ui-react'; import {loginPromptAborted} from '../../actions'; @@ -11,7 +11,7 @@ export default function LoginPrompt() { const acquiringToken = useSelector(isAcquiringToken); const loggedIn = useSelector(isLoggedIn); const {login, logout} = useAuthentication(); - const history = useHistory(); + const navigate = useNavigate(); const dispatch = useDispatch(); if (!acquiringToken) { @@ -44,7 +44,7 @@ export default function LoginPrompt() { key: 'cancel', content: t`Cancel`, onClick: () => { - history.push('/'); + navigate('/'); dispatch(loginPromptAborted()); }, }, diff --git a/newdle/client/src/components/summary/SummaryHeader.js b/newdle/client/src/components/summary/SummaryHeader.js index 29f12cb00..eb5a23467 100644 --- a/newdle/client/src/components/summary/SummaryHeader.js +++ b/newdle/client/src/components/summary/SummaryHeader.js @@ -1,12 +1,12 @@ import React, {useEffect} from 'react'; import {useDispatch, useSelector} from 'react-redux'; -import PropTypes from 'prop-types'; +import {useParams} from 'react-router'; import {clearNewdle, fetchNewdle} from '../../actions'; import {getNewdle} from '../../selectors'; import NewdleTitle from '../NewdleTitle'; -export default function SummaryHeader({match}) { - const code = match.params.code; +export default function SummaryHeader() { + const {code} = useParams(); const newdle = useSelector(getNewdle); const dispatch = useDispatch(); @@ -36,11 +36,3 @@ export default function SummaryHeader({match}) { /> ); } - -SummaryHeader.propTypes = { - match: PropTypes.shape({ - params: PropTypes.shape({ - code: PropTypes.string.isRequired, - }).isRequired, - }).isRequired, -}; diff --git a/newdle/client/src/locales/es/messages.po b/newdle/client/src/locales/es/messages.po index 51ab1d723..79c9016ab 100644 --- a/newdle/client/src/locales/es/messages.po +++ b/newdle/client/src/locales/es/messages.po @@ -197,7 +197,7 @@ msgstr "" msgid "Email address" msgstr "" -#: src/components/ErrorMessage.js:30 +#: src/components/ErrorMessage.js:31 msgid "Error occurred" msgstr ""