Create base account route
This commit is contained in:
parent
394fbd50f0
commit
2a1b1ea45a
@ -15,6 +15,7 @@ import { BaseAuthenticatedPage } from "./widgets/BaseAuthenticatedPage";
|
|||||||
import { BaseLoginPage } from "./widgets/BaseLoginPage";
|
import { BaseLoginPage } from "./widgets/BaseLoginPage";
|
||||||
import { TokensRoute } from "./routes/TokensRoute";
|
import { TokensRoute } from "./routes/TokensRoute";
|
||||||
import { AccountsRoute } from "./routes/AccountsRoute";
|
import { AccountsRoute } from "./routes/AccountsRoute";
|
||||||
|
import { AccountRoute } from "./routes/AccountRoute";
|
||||||
|
|
||||||
interface AuthContext {
|
interface AuthContext {
|
||||||
signedIn: boolean;
|
signedIn: boolean;
|
||||||
@ -41,6 +42,7 @@ export function App() {
|
|||||||
<Route path="" element={<HomeRoute />} />
|
<Route path="" element={<HomeRoute />} />
|
||||||
<Route path="tokens" element={<TokensRoute />} />
|
<Route path="tokens" element={<TokensRoute />} />
|
||||||
<Route path="accounts" element={<AccountsRoute />} />
|
<Route path="accounts" element={<AccountsRoute />} />
|
||||||
|
<Route path="account/:accountId" element={<AccountRoute />} />
|
||||||
|
|
||||||
<Route path="*" element={<NotFoundRoute />} />
|
<Route path="*" element={<NotFoundRoute />} />
|
||||||
</Route>
|
</Route>
|
||||||
|
27
moneymgr_web/src/routes/AccountRoute.tsx
Normal file
27
moneymgr_web/src/routes/AccountRoute.tsx
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import { useParams } from "react-router-dom";
|
||||||
|
import { MoneyMgrWebRouteContainer } from "../widgets/MoneyMgrWebRouteContainer";
|
||||||
|
import { useAccounts } from "../hooks/AccountsListProvider";
|
||||||
|
import { NotFoundRoute } from "./NotFound";
|
||||||
|
import { AccountWidget } from "../widgets/AccountWidget";
|
||||||
|
|
||||||
|
export function AccountRoute(): React.ReactElement {
|
||||||
|
const { accountId } = useParams();
|
||||||
|
|
||||||
|
const accounts = useAccounts();
|
||||||
|
const account = accounts.get(Number(accountId));
|
||||||
|
|
||||||
|
if (account === null) return <NotFoundRoute />;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<MoneyMgrWebRouteContainer
|
||||||
|
label={
|
||||||
|
<span style={{ display: "inline-flex", alignItems: "center" }}>
|
||||||
|
<AccountWidget account={account} />
|
||||||
|
{account.name}
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
TODO : table
|
||||||
|
</MoneyMgrWebRouteContainer>
|
||||||
|
);
|
||||||
|
}
|
@ -3,7 +3,7 @@ import React, { PropsWithChildren } from "react";
|
|||||||
|
|
||||||
export function MoneyMgrWebRouteContainer(
|
export function MoneyMgrWebRouteContainer(
|
||||||
p: {
|
p: {
|
||||||
label: string;
|
label: string | React.ReactElement;
|
||||||
actions?: React.ReactElement;
|
actions?: React.ReactElement;
|
||||||
} & PropsWithChildren
|
} & PropsWithChildren
|
||||||
): React.ReactElement {
|
): React.ReactElement {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user