fix: enable Tasks and Workers tabs from URL params
Sidebar Tasks link points to /admin/time-tracking?tab=tasks Sidebar Workers & PINs link points to /admin/time-tracking Now TimeTrackingAdminPanel reads ?tab= URL param to set initial tab
This commit is contained in:
@@ -145,7 +145,14 @@ const TABS = [
|
||||
];
|
||||
|
||||
export default function TimeTrackingAdminPanel({ brandId }: { brandId?: string }) {
|
||||
const [tab, setTab] = useState<Tab>("summary");
|
||||
const [tab, setTab] = useState<Tab>(() => {
|
||||
if (typeof window !== "undefined") {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const t = params.get("tab");
|
||||
if (t === "tasks" || t === "workers") return t as Tab;
|
||||
}
|
||||
return "summary" as Tab;
|
||||
});
|
||||
const [workers, setWorkers] = useState<TimeWorker[]>([]);
|
||||
const [tasks, setTasks] = useState<TimeTask[]>([]);
|
||||
const [logs, setLogs] = useState<TimeLog[]>([]);
|
||||
|
||||
Reference in New Issue
Block a user