Frontend security / security (push) Successful in 9s
Frontend verify / verify (push) Successful in 5m10s
Conventional commits / commits (pull_request) Successful in 25s
Frontend security / security (pull_request) Successful in 9s
Frontend verify / verify (pull_request) Successful in 5m10s
31 lines
1021 B
TypeScript
31 lines
1021 B
TypeScript
import type { FC } from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
import { useBrokerageAccounts } from "@/entities/brokerage-account";
|
|
import { BreadcrumbTrail } from "./BreadcrumbTrail";
|
|
|
|
type AccountBreadcrumbsProps = {
|
|
accountId: string;
|
|
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 },
|
|
...(section ? [{ label: t(`breadcrumbs.${section}`) }] : []),
|
|
];
|
|
|
|
return <BreadcrumbTrail items={items} />;
|
|
};
|
|
|
|
export { AccountBreadcrumbs };
|