Display the list of accounts
This commit is contained in:
parent
91d8b1a579
commit
342af2c443
@ -17,6 +17,13 @@ export class AccountsList {
|
|||||||
this.list.sort((a, b) => a.id - b.id);
|
this.list.sort((a, b) => a.id - b.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if accounts list is empty
|
||||||
|
*/
|
||||||
|
get isEmpty(): boolean {
|
||||||
|
return this.list.length === 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a single account by its id
|
* Get a single account by its id
|
||||||
*/
|
*/
|
||||||
|
@ -1,15 +1,19 @@
|
|||||||
import { mdiApi, mdiCashMultiple, mdiHome } from "@mdi/js";
|
import { mdiAccount, mdiApi, mdiCashMultiple, mdiHome } from "@mdi/js";
|
||||||
import Icon from "@mdi/react";
|
import Icon from "@mdi/react";
|
||||||
import {
|
import {
|
||||||
|
Divider,
|
||||||
List,
|
List,
|
||||||
ListItemButton,
|
ListItemButton,
|
||||||
ListItemIcon,
|
ListItemIcon,
|
||||||
ListItemText,
|
ListItemText,
|
||||||
|
Typography,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { useLocation } from "react-router-dom";
|
import { useLocation } from "react-router-dom";
|
||||||
|
import { useAccounts } from "../hooks/AccountsListProvider";
|
||||||
import { RouterLink } from "./RouterLink";
|
import { RouterLink } from "./RouterLink";
|
||||||
|
|
||||||
export function MoneyNavList(): React.ReactElement {
|
export function MoneyNavList(): React.ReactElement {
|
||||||
|
const accounts = useAccounts();
|
||||||
return (
|
return (
|
||||||
<List
|
<List
|
||||||
dense
|
dense
|
||||||
@ -36,6 +40,28 @@ export function MoneyNavList(): React.ReactElement {
|
|||||||
uri="/accounts"
|
uri="/accounts"
|
||||||
icon={<Icon path={mdiCashMultiple} size={1} />}
|
icon={<Icon path={mdiCashMultiple} size={1} />}
|
||||||
/>
|
/>
|
||||||
|
<Divider />
|
||||||
|
{accounts.list.isEmpty && (
|
||||||
|
<Typography
|
||||||
|
variant="caption"
|
||||||
|
style={{
|
||||||
|
paddingTop: "20px",
|
||||||
|
display: "inline-block",
|
||||||
|
textAlign: "center",
|
||||||
|
width: "100%",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
No account yet.
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{accounts.list.list.map((a) => (
|
||||||
|
<NavLink
|
||||||
|
label={a.name}
|
||||||
|
uri={`/account/${a.id}`}
|
||||||
|
icon={<Icon path={mdiAccount} size={1} />}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
</List>
|
</List>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user