refactor: enforce frontend view model boundaries
This commit is contained in:
@@ -8,19 +8,24 @@ import { BreadcrumbTrail } from "./BreadcrumbTrail";
|
||||
|
||||
type AccountBreadcrumbsProps = {
|
||||
accountId: string;
|
||||
section?: "events" | "income" | "operations";
|
||||
section?: "events"
|
||||
| "income"
|
||||
| "operations";
|
||||
};
|
||||
|
||||
const AccountBreadcrumbs: FC<AccountBreadcrumbsProps> = (props) => {
|
||||
const { accountId, section } = props;
|
||||
const { data: accounts } = useBrokerageAccounts();
|
||||
const { t } = useTranslation();
|
||||
|
||||
const accountName
|
||||
= accountId === "all"
|
||||
? t("accounts.all")
|
||||
: (accounts?.find(account => account.id === accountId)?.name
|
||||
?? t("breadcrumbs.accountFallback"));
|
||||
|
||||
const accountPath = `/accounts/${accountId}`;
|
||||
|
||||
const items = [
|
||||
{ label: t("breadcrumbs.accounts"), to: "/accounts" },
|
||||
section ? { label: accountName, to: accountPath } : { label: accountName },
|
||||
|
||||
Reference in New Issue
Block a user