mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-07 18:32:40 +00:00
Merge pull request #4340 from naturalcrit/MoreHomebrew.jsxCleanup
More homebrew.jsx cleanup
This commit is contained in:
@@ -4,30 +4,21 @@ import './homebrew.less';
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { StaticRouter as Router, Route, Routes, useParams, useSearchParams } from 'react-router';
|
import { StaticRouter as Router, Route, Routes, useParams, useSearchParams } from 'react-router';
|
||||||
|
|
||||||
const HomePage = require('./pages/homePage/homePage.jsx');
|
import HomePage from './pages/homePage/homePage.jsx';
|
||||||
const EditPage = require('./pages/editPage/editPage.jsx');
|
import EditPage from './pages/editPage/editPage.jsx';
|
||||||
const UserPage = require('./pages/userPage/userPage.jsx');
|
import UserPage from './pages/userPage/userPage.jsx';
|
||||||
const SharePage = require('./pages/sharePage/sharePage.jsx');
|
import SharePage from './pages/sharePage/sharePage.jsx';
|
||||||
const NewPage = require('./pages/newPage/newPage.jsx');
|
import NewPage from './pages/newPage/newPage.jsx';
|
||||||
const ErrorPage = require('./pages/errorPage/errorPage.jsx');
|
import ErrorPage from './pages/errorPage/errorPage.jsx';
|
||||||
const VaultPage = require('./pages/vaultPage/vaultPage.jsx');
|
import VaultPage from './pages/vaultPage/vaultPage.jsx';
|
||||||
const AccountPage = require('./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