first commit
This commit is contained in:
26
src/hooks/useOwliverContext.ts
Normal file
26
src/hooks/useOwliverContext.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { useLocation } from "react-router-dom"
|
||||
|
||||
import type { OwliverContext } from "@/owliver/types"
|
||||
|
||||
const BY_PATH: Record<string, OwliverContext> = {
|
||||
"/": "home",
|
||||
"/performance": "performance",
|
||||
"/orders": "orders",
|
||||
"/availability": "availability",
|
||||
"/tasks": "tasks",
|
||||
"/staff": "staff",
|
||||
"/compliance": "compliance",
|
||||
"/benefits": "benefits",
|
||||
"/clients": "clients",
|
||||
"/invoices": "invoices",
|
||||
"/payroll": "payroll",
|
||||
"/reports": "reports",
|
||||
"/messages": "messages",
|
||||
"/settings": "settings",
|
||||
}
|
||||
|
||||
/** Maps the active route to the context Owliver should brief itself on. */
|
||||
export function useOwliverContext(): OwliverContext {
|
||||
const { pathname } = useLocation()
|
||||
return BY_PATH[pathname] ?? "home"
|
||||
}
|
||||
Reference in New Issue
Block a user