mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-07 09:52:41 +00:00
Clean up WithRoute
This commit is contained in:
@@ -13,21 +13,12 @@ import ErrorPage from './pages/errorPage/errorPage.jsx';
|
|||||||
import VaultPage from './pages/vaultPage/vaultPage.jsx';
|
import VaultPage from './pages/vaultPage/vaultPage.jsx';
|
||||||
import AccountPage from './pages/accountPage/accountPage.jsx';
|
import AccountPage from './pages/accountPage/accountPage.jsx';
|
||||||
|
|
||||||
const WithRoute = (props)=>{
|
const WithRoute = ({ el: Element, ...rest })=>{
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
const queryParams = {};
|
const queryParams = Object.fromEntries(searchParams?.entries() || []);
|
||||||
for (const [key, value] of searchParams?.entries() || []) {
|
|
||||||
queryParams[key] = value;
|
return <Element {...rest} {...params} query={queryParams} />;
|
||||||
}
|
|
||||||
const Element = props.el;
|
|
||||||
const allProps = {
|
|
||||||
...props,
|
|
||||||
...params,
|
|
||||||
query : queryParams,
|
|
||||||
el : undefined
|
|
||||||
};
|
|
||||||
return <Element {...allProps} />;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const Homebrew = (props)=>{
|
const Homebrew = (props)=>{
|
||||||
@@ -51,11 +42,11 @@ const Homebrew = (props)=>{
|
|||||||
brews
|
brews
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
global.account = account;
|
global.account = account;
|
||||||
global.version = version;
|
global.version = version;
|
||||||
global.enable_v3 = enable_v3;
|
global.enable_v3 = enable_v3;
|
||||||
global.enable_themes = enable_themes;
|
global.enable_themes = enable_themes;
|
||||||
global.config = config;
|
global.config = config;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Router location={url}>
|
<Router location={url}>
|
||||||
|
|||||||
Reference in New Issue
Block a user