⚡ Code split routes

This commit is contained in:
nikolark committed 2022-04-17 16:59:00 +02:00
1 parent b56d103ae7
commit ce2cdfd409
13 files changed
+33 -22

No files matched your search

+1 -1
View File
@@ -11,6 +11,6 @@ CACHE/
media/ media/
tmp/ tmp/
frontend/dist frontend/dist
static/modern static/
.python-version .python-version
.env .env
-1
View File
@@ -7,7 +7,6 @@ import { Routes } from "./Routes";
import client from "./client"; import client from "./client";
import { Footer } from "./components/Footer"; import { Footer } from "./components/Footer";
import { Header } from "./components/Header"; import { Header } from "./components/Header";
import { Splash as Splash } from "./components/Splash";
import { Toast } from "./components/Toast"; import { Toast } from "./components/Toast";
import { ToastProvider } from "./components/ToastProvider"; import { ToastProvider } from "./components/ToastProvider";
import { Wireframe } from "./components/Wireframe"; import { Wireframe } from "./components/Wireframe";
+12 -10
View File
@@ -1,18 +1,19 @@
import React from "react"; import React from "react";
import { Route, Routes as ReactRouterRoutes } from "react-router-dom"; import { Route, Routes as ReactRouterRoutes } from "react-router-dom";
import { Splash } from "./components/Splash"; const Splash = React.lazy(() => import("./components/Splash"));
import { UserCreate } from "./features/auth/UserCreate"; const UserCreate = React.lazy(() => import("./features/auth/UserCreate"));
import { Deposit } from "./features/deposit/Deposit"; const Deposit = React.lazy(() => import("./features/deposit/Deposit"));
import { Log } from "./features/log/Log"; const Log = React.lazy(() => import("./features/log/Log"));
import { Register } from "./features/register/Register"; const Register = React.lazy(() => import("./features/register/Register"));
import { OrderStats } from "./features/stats/OrderStats"; const OrderStats = React.lazy(() => import("./features/stats/OrderStats"));
import { ProductStats } from "./features/stats/ProductStats"; const ProductStats = React.lazy(() => import("./features/stats/ProductStats"));
import { Stats } from "./features/stats/Stats"; const Stats = React.lazy(() => import("./features/stats/Stats"));
import { UserDetail } from "./features/users/UserDetail"; const UserDetail = React.lazy(() => import("./features/users/UserDetail"));
import { UserList } from "./features/users/UserList"; const UserList = React.lazy(() => import("./features/users/UserList"));
export const Routes = (): JSX.Element => ( export const Routes = (): JSX.Element => (
<React.Suspense fallback={<div>Loading...</div>}>
<ReactRouterRoutes> <ReactRouterRoutes>
<Route path="/deposit" element={<Deposit />} /> <Route path="/deposit" element={<Deposit />} />
<Route path="/log" element={<Log />} /> <Route path="/log" element={<Log />} />
@@ -25,4 +26,5 @@ export const Routes = (): JSX.Element => (
<Route path="/" element={<Register />} /> <Route path="/" element={<Register />} />
<Route path="*" element={<Splash brandText="404" noOverlay />} /> <Route path="*" element={<Splash brandText="404" noOverlay />} />
</ReactRouterRoutes> </ReactRouterRoutes>
</React.Suspense>
); );
+2 -1
View File
@@ -8,7 +8,7 @@ interface SplashProps {
noOverlay?: boolean; noOverlay?: boolean;
} }
export const Splash = ({ brandText = "BBS", noOverlay = false }: SplashProps): JSX.Element => ( const Splash = ({ brandText = "BBS", noOverlay = false }: SplashProps): JSX.Element => (
<div className={clsx(styles.splash, { [styles.overlay]: !noOverlay })}> <div className={clsx(styles.splash, { [styles.overlay]: !noOverlay })}>
<div className={styles.wrap}> <div className={styles.wrap}>
<div className={styles.sun}></div> <div className={styles.sun}></div>
@@ -17,3 +17,4 @@ export const Splash = ({ brandText = "BBS", noOverlay = false }: SplashProps): J
</div> </div>
</div> </div>
); );
export default Splash;
+2 -1
View File
@@ -11,7 +11,7 @@ type FormValues = {
email: string; email: string;
}; };
export const UserCreate = () => { const UserCreate = () => {
const { const {
register, register,
handleSubmit, handleSubmit,
@@ -48,3 +48,4 @@ export const UserCreate = () => {
</div> </div>
); );
}; };
export default UserCreate;
+2 -1
View File
@@ -4,7 +4,7 @@ import { UserCard } from "../users/UserCard";
import styles from "./Deposit.module.css"; import styles from "./Deposit.module.css";
import { useDeposit } from "./useDeposit"; import { useDeposit } from "./useDeposit";
export const Deposit = (): JSX.Element => { const Deposit = (): JSX.Element => {
const { const {
loading, loading,
selectedUser, selectedUser,
@@ -65,3 +65,4 @@ export const Deposit = (): JSX.Element => {
</div> </div>
); );
}; };
export default Deposit;
+2 -1
View File
@@ -9,7 +9,7 @@ import styles from "./Log.module.css";
const PAGE_SIZE = 10; const PAGE_SIZE = 10;
export const Log = () => { const Log = () => {
const types = { const types = {
orderOffset: Number, orderOffset: Number,
transactionOffset: Number, transactionOffset: Number,
@@ -139,3 +139,4 @@ export const Log = () => {
</div> </div>
); );
}; };
export default Log;
+2 -1
View File
@@ -8,7 +8,7 @@ import { useRegister } from "./useRegister";
const USER_EXTERNAL = "external"; const USER_EXTERNAL = "external";
export const Register = (): JSX.Element => { const Register = (): JSX.Element => {
const { const {
users, users,
products, products,
@@ -80,3 +80,4 @@ export const Register = (): JSX.Element => {
</div> </div>
); );
}; };
export default Register;
+2 -1
View File
@@ -35,7 +35,7 @@ const OrderBar = ({ data }: { data: BarDatum[] }) => (
/> />
); );
export const OrderStats = () => { const OrderStats = () => {
const { data, loading } = useQuery(OrderStatsDocument); const { data, loading } = useQuery(OrderStatsDocument);
return ( return (
@@ -77,3 +77,4 @@ export const OrderStats = () => {
</StatsView> </StatsView>
); );
}; };
export default OrderStats;
+2 -1
View File
@@ -11,7 +11,7 @@ type UserCount = {
count: number; count: number;
}; };
export const ProductStats = () => { const ProductStats = () => {
const { data, loading } = useQuery(AllProductStatsDocument, { const { data, loading } = useQuery(AllProductStatsDocument, {
variables: { active: true }, variables: { active: true },
}); });
@@ -38,3 +38,4 @@ export const ProductStats = () => {
</StatsView> </StatsView>
); );
}; };
export default ProductStats;
+2 -1
View File
@@ -5,7 +5,7 @@ import React from "react";
import { ProductStatsDocument } from "../../types"; import { ProductStatsDocument } from "../../types";
import { StatsView } from "./StatsView"; import { StatsView } from "./StatsView";
export const Stats = () => { const Stats = () => {
const { data, loading } = useQuery(ProductStatsDocument); const { data, loading } = useQuery(ProductStatsDocument);
const series: any[] = []; const series: any[] = [];
@@ -68,3 +68,4 @@ export const Stats = () => {
</StatsView> </StatsView>
); );
}; };
export default Stats;
+2 -1
View File
@@ -7,7 +7,7 @@ import { User, UserDetailDocument, UserProfile } from "../../types";
import { formatMonth, formatTime } from "../../utils/time"; import { formatMonth, formatTime } from "../../utils/time";
import styles from "./UserDetail.module.css"; import styles from "./UserDetail.module.css";
export const UserDetail = () => { const UserDetail = () => {
const { userId } = useParams(); const { userId } = useParams();
const { data, loading } = useQuery(UserDetailDocument, { variables: { userId: userId || "" }, skip: !userId }); const { data, loading } = useQuery(UserDetailDocument, { variables: { userId: userId || "" }, skip: !userId });
@@ -108,3 +108,4 @@ export const UserDetail = () => {
</div> </div>
); );
}; };
export default UserDetail;
+2 -1
View File
@@ -5,7 +5,7 @@ import { Link } from "react-router-dom";
import { AllUsersDocument } from "../../types"; import { AllUsersDocument } from "../../types";
import { activeUserFilter } from "../../utils/users"; import { activeUserFilter } from "../../utils/users";
export const UserList = () => { const UserList = () => {
const { data, loading } = useQuery(AllUsersDocument); const { data, loading } = useQuery(AllUsersDocument);
const [showAll, setShowAll] = useState(false); const [showAll, setShowAll] = useState(false);
@@ -35,3 +35,4 @@ export const UserList = () => {
</div> </div>
); );
}; };
export default UserList;