Files
krow_workforce_owliver/src/hooks/useOwliverContext.ts
2026-09-16 20:11:27 +05:30

27 lines
724 B
TypeScript

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"
}