24 lines
602 B
TypeScript
24 lines
602 B
TypeScript
import { useMatch } from "react-router";
|
|
|
|
function useCurrentRoute() {
|
|
const account = useMatch("/accounts/:accountId/:section?");
|
|
|
|
const section = (["events", "income", "operations"] as const)
|
|
.find(value => value === account?.params.section?.toLowerCase());
|
|
|
|
return {
|
|
account,
|
|
accounts: useMatch("/accounts"),
|
|
bond: useMatch("/bonds/:bondId"),
|
|
bonds: useMatch("/bonds"),
|
|
card: useMatch("/cards/:cardId"),
|
|
cards: useMatch("/cards"),
|
|
section,
|
|
settings: useMatch("/settings"),
|
|
stock: useMatch("/stocks/:stockId"),
|
|
stocks: useMatch("/stocks"),
|
|
};
|
|
}
|
|
|
|
export { useCurrentRoute };
|