refactor: clarify frontend module ownership
This commit is contained in:
@@ -0,0 +1 @@
|
||||
export { useCurrentRoute } from "./useCurrentRoute";
|
||||
@@ -0,0 +1,23 @@
|
||||
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 };
|
||||
Reference in New Issue
Block a user