diff --git a/packages/desktop-client/src/components/FinancesApp.js b/packages/desktop-client/src/components/FinancesApp.js index 6ec499df247..74e592dd760 100644 --- a/packages/desktop-client/src/components/FinancesApp.js +++ b/packages/desktop-client/src/components/FinancesApp.js @@ -57,118 +57,82 @@ import PostsOfflineNotification from './schedules/PostsOfflineNotification'; import Settings from './settings'; import Titlebar, { TitlebarProvider } from './Titlebar'; -function PageRoute({ - path, - component: Component, - redirectTo = '/budget', - worksInNarrow = true, -}) { +function NarrowNotSupported({ children, redirectTo = '/budget' }) { const { isNarrowWidth } = useResponsive(); - return worksInNarrow || !isNarrowWidth ? ( - { - return ( - - - - ); - }} - /> - ) : ( - - ); -} - -function NonPageRoute({ - redirectTo = '/budget', - worksInNarrow = true, - ...routeProps -}) { - const { isNarrowWidth } = useResponsive(); - - return worksInNarrow || !isNarrowWidth ? ( - - ) : ( - - ); + return isNarrowWidth ? : children; } function Routes({ location }) { const { isNarrowWidth } = useResponsive(); return ( - - - - - - - - - - - - - - - - - - - { + } /> + + + + + + + + + {isNarrowWidth ? : } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {props => { const AcctCmp = isNarrowWidth ? MobileAccount : Account; return ( props.match && ); }} - /> - + + + {isNarrowWidth ? : } + ); } @@ -327,13 +291,10 @@ function FinancesApp(props) { -
@@ -362,11 +323,17 @@ function FinancesApp(props) {
- - - + + + + + + + + + - +
diff --git a/packages/desktop-client/src/components/Modals.js b/packages/desktop-client/src/components/Modals.js index 46df9f5b288..c18eeb85957 100644 --- a/packages/desktop-client/src/components/Modals.js +++ b/packages/desktop-client/src/components/Modals.js @@ -112,164 +112,110 @@ function Modals({ />
- { - const { category, group, onDelete } = options; - return ( - c.id === category)} - group={categoryGroups.find(g => g.id === group)} - categoryGroups={categoryGroups} - onDelete={onDelete} - /> - ); - }} - /> + + c.id === options.category)} + group={categoryGroups.find(g => g.id === options.group)} + categoryGroups={categoryGroups} + onDelete={options.onDelete} + /> + - ( - - )} - /> + + + - { - return ( - - ); - }} - /> + + + - { - return ( - - ); - }} - /> + + + - { - return ( - - ); - }} - /> + + + - { - return ( - { - options.onClose && options.onClose(); - send('poll-web-token-stop'); - }} - onSuccess={options.onSuccess} - /> - ); - }} - /> - { - return ( - - ); - }} - /> - { - return ( - { - options.onClose && options.onClose(); - send('nordigen-poll-web-token-stop'); - }} - onSuccess={options.onSuccess} - /> - ); - }} - /> + + { + options.onClose && options.onClose(); + send('poll-web-token-stop'); + }} + onSuccess={options.onSuccess} + /> + + + + + + { + options.onClose && options.onClose(); + send('nordigen-poll-web-token-stop'); + }} + onSuccess={options.onSuccess} + /> + - { - return ( - - ); - }} - /> + + + - { - return ( - - ); - }} - /> + + + - { - return ( - - ); - }} - /> + + + - { - let state = props.location.state || {}; - return state.goBack ? ( - - ) : null; - }} - /> + + {location.state?.goBack ? ( + + ) : null} + - { - return ( - props.match && - ); - }} - /> + + + - ( - - )} - /> + + + @@ -374,14 +360,12 @@ function Titlebar({ ); } -export default withRouter( - connect( - state => ({ - globalPrefs: state.prefs.global, - localPrefs: state.prefs.local, - userData: state.user.data, - floatingSidebar: state.prefs.global.floatingSidebar, - }), - actions, - )(Titlebar), -); +export default connect( + state => ({ + globalPrefs: state.prefs.global, + localPrefs: state.prefs.local, + userData: state.user.data, + floatingSidebar: state.prefs.global.floatingSidebar, + }), + actions, +)(Titlebar); diff --git a/packages/desktop-client/src/components/accounts/Account.js b/packages/desktop-client/src/components/accounts/Account.js index 7d7ae712c1d..92179999653 100644 --- a/packages/desktop-client/src/components/accounts/Account.js +++ b/packages/desktop-client/src/components/accounts/Account.js @@ -2001,6 +2001,7 @@ class AccountInternal extends PureComponent { function AccountHack(props) { let { dispatch: splitsExpandedDispatch } = useSplitsExpanded(); + return ( ({ newTransactions: state.queries.newTransactions, matchedTransactions: state.queries.matchedTransactions, @@ -2019,16 +2024,11 @@ export default function Account(props) { categoryGroups: state.queries.categories.grouped, dateFormat: state.prefs.local.dateFormat || 'MM/dd/yyyy', hideFraction: state.prefs.local.hideFraction || false, - expandSplits: props.match && state.prefs.local['expand-splits'], - showBalances: - props.match && - state.prefs.local['show-balances-' + props.match.params.id], - showCleared: - props.match && - !state.prefs.local['hide-cleared-' + props.match.params.id], + expandSplits: state.prefs.local['expand-splits'], + showBalances: params.id && state.prefs.local['show-balances-' + params.id], + showCleared: params.id && !state.prefs.local['hide-cleared-' + params.id], showExtraBalances: - props.match && - state.prefs.local['show-extra-balances-' + props.match.params.id], + params.id && state.prefs.local['show-extra-balances-' + params.id], payees: state.queries.payees, modalShowing: state.modals.modalStack.length > 0, accountsSyncing: state.account.accountsSyncing, @@ -2042,10 +2042,6 @@ export default function Account(props) { [dispatch], ); - let params = useParams(); - let location = useLocation(); - let activeLocation = useActiveLocation(); - let transform = useMemo(() => { let filterByAccount = queries.getAccountFilter(params.id, '_account'); let filterByPayee = queries.getAccountFilter( @@ -2085,7 +2081,7 @@ export default function Account(props) { !!(activeLocation.state && activeLocation.state.locationPtr) } accountId={params.id} - location={props.location} + location={location} /> diff --git a/packages/desktop-client/src/components/accounts/MobileAccount.js b/packages/desktop-client/src/components/accounts/MobileAccount.js index cefcc54d5a9..2db1f2ca346 100644 --- a/packages/desktop-client/src/components/accounts/MobileAccount.js +++ b/packages/desktop-client/src/components/accounts/MobileAccount.js @@ -1,5 +1,6 @@ import React, { useEffect, useMemo, useState } from 'react'; import { connect, useDispatch, useSelector } from 'react-redux'; +import { useParams } from 'react-router-dom'; import { useNavigate } from 'react-router-dom-v5-compat'; import debounce from 'debounce'; @@ -88,12 +89,9 @@ function Account(props) { [dispatch], ); - const { id: accountId } = props.match.params; + const { id: accountId } = useParams(); - const makeRootQuery = () => { - const { id } = props.match.params || {}; - return queries.makeTransactionsQuery(id); - }; + const makeRootQuery = () => queries.makeTransactionsQuery(accountId); const updateQuery = query => { if (paged) { diff --git a/packages/desktop-client/src/components/manager/ManagementApp.js b/packages/desktop-client/src/components/manager/ManagementApp.js index d5724e0da42..7c90c251424 100644 --- a/packages/desktop-client/src/components/manager/ManagementApp.js +++ b/packages/desktop-client/src/components/manager/ManagementApp.js @@ -151,16 +151,20 @@ function ManagementApp({ {userData && files ? ( <> - - + + + + + + {files && files.length > 0 ? ( - + + + ) : ( - + + + )} {/* Redirect all other pages to this route */} } /> @@ -176,23 +180,27 @@ function ManagementApp({ }} > - - ( - - )} - /> + + + + ) : ( - - - - + + + + + + + + + + + + {/* Redirect all other pages to this route */} } /> @@ -201,8 +209,10 @@ function ManagementApp({ )} - - + + + + diff --git a/packages/desktop-client/src/components/modals/ManageRulesModal.js b/packages/desktop-client/src/components/modals/ManageRulesModal.js index 7595854547d..1eb05415a80 100644 --- a/packages/desktop-client/src/components/modals/ManageRulesModal.js +++ b/packages/desktop-client/src/components/modals/ManageRulesModal.js @@ -1,5 +1,5 @@ import React, { useState } from 'react'; -import { useLocation } from 'react-router-dom-v5-compat'; +import { useLocation } from 'react-router-dom'; import { isNonProductionEnvironment } from 'loot-core/src/shared/environment'; diff --git a/packages/desktop-client/src/components/reports/index.js b/packages/desktop-client/src/components/reports/index.js index 08ef98347d3..75af78499bc 100644 --- a/packages/desktop-client/src/components/reports/index.js +++ b/packages/desktop-client/src/components/reports/index.js @@ -10,9 +10,15 @@ import Overview from './Overview'; export default function Reports() { return ( - - - + + + + + + + + + ); } diff --git a/upcoming-release-notes/1045.md b/upcoming-release-notes/1045.md new file mode 100644 index 00000000000..f31fafc1bfd --- /dev/null +++ b/upcoming-release-notes/1045.md @@ -0,0 +1,6 @@ +--- +category: Maintenance +authors: [trevdor] +--- + +Update to React Router v5.1 conventions to facilitate the v6 upgrade.