feat: global time range context with custom date picker
Lift time range state into a shared React context so the selected
range persists across page navigation and browser refreshes
(localStorage). Add a "Custom" option with a popover date picker
that lets users specify arbitrary start/end dates. All preset end
times now use endOf("day") (23:59:59) instead of the current moment.
This commit is contained in:
@@ -4,6 +4,7 @@ import { type ReactNode } from "react";
|
||||
import { usePathname } from "next/navigation";
|
||||
import { I18nProvider } from "@/lib/i18n";
|
||||
import { ThemeProvider } from "@/lib/theme";
|
||||
import { TimeRangeProvider } from "@/lib/time-range-context";
|
||||
import { Sidebar } from "@/components/Sidebar";
|
||||
|
||||
export function ClientProviders({ children }: { children: ReactNode }) {
|
||||
@@ -13,14 +14,16 @@ export function ClientProviders({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
<ThemeProvider>
|
||||
<I18nProvider>
|
||||
{isPortal ? (
|
||||
<>{children}</>
|
||||
) : (
|
||||
<>
|
||||
<Sidebar />
|
||||
<main className="ml-[220px] min-h-screen p-6 lg:p-8">{children}</main>
|
||||
</>
|
||||
)}
|
||||
<TimeRangeProvider>
|
||||
{isPortal ? (
|
||||
<>{children}</>
|
||||
) : (
|
||||
<>
|
||||
<Sidebar />
|
||||
<main className="ml-[220px] min-h-screen p-6 lg:p-8">{children}</main>
|
||||
</>
|
||||
)}
|
||||
</TimeRangeProvider>
|
||||
</I18nProvider>
|
||||
</ThemeProvider>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user