diff --git a/app/layout.tsx b/app/layout.tsx
index a092d4fe..bddadc19 100644
--- a/app/layout.tsx
+++ b/app/layout.tsx
@@ -12,7 +12,10 @@ import { SpeedInsights } from "@vercel/speed-insights/next"
import { Toaster } from '@/components/ui/sonner'
import { MapToggleProvider } from '@/components/map-toggle-context'
import { ProfileToggleProvider } from '@/components/profile-toggle-context'
+import { UsageToggleProvider } from '@/components/usage-toggle-context'
import { CalendarToggleProvider } from '@/components/calendar-toggle-context'
+import { HistoryToggleProvider } from '@/components/history-toggle-context'
+import { HistorySidebar } from '@/components/history-sidebar'
import { MapLoadingProvider } from '@/components/map-loading-context';
import ConditionalLottie from '@/components/conditional-lottie';
import { MapProvider as MapContextProvider } from '@/components/map/map-context'
@@ -70,28 +73,33 @@ export default function RootLayout({
)}
>
-
-
-
-
-
-
-
- {children}
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+ {children}
+
+
+
+
+
+
+
+
+
+
+
diff --git a/components/chat.tsx b/components/chat.tsx
index 04e27ac6..2e0fd1e9 100644
--- a/components/chat.tsx
+++ b/components/chat.tsx
@@ -14,7 +14,9 @@ import { MapProvider } from './map/map-provider'
import { useUIState, useAIState } from 'ai/rsc'
import MobileIconsBar from './mobile-icons-bar'
import { useProfileToggle, ProfileToggleEnum } from "@/components/profile-toggle-context";
+import { useUsageToggle } from "@/components/usage-toggle-context";
import SettingsView from "@/components/settings/settings-view";
+import { UsageView } from "@/components/usage-view";
import { MapDataProvider, useMapData } from './map/map-data-context'; // Add this and useMapData
import { updateDrawingContext } from '@/lib/actions/chat'; // Import the server action
import dynamic from 'next/dynamic'
@@ -31,6 +33,7 @@ export function Chat({ id }: ChatProps) {
const [aiState] = useAIState()
const [isMobile, setIsMobile] = useState(false)
const { activeView } = useProfileToggle();
+ const { isUsageOpen } = useUsageToggle();
const { isCalendarOpen } = useCalendarToggle()
const [input, setInput] = useState('')
const [showEmptyScreen, setShowEmptyScreen] = useState(false)
@@ -107,7 +110,7 @@ export function Chat({ id }: ChatProps) {
- {activeView ? : }
+ {isUsageOpen ? : activeView ? : }
@@ -218,7 +221,7 @@ export function Chat({ id }: ChatProps) {
className="w-1/2 p-4 fixed h-[calc(100vh-0.5in)] top-0 right-0 mt-[0.5in]"
style={{ zIndex: 10 }} // Added z-index
>
- {activeView ? : }
+ {isUsageOpen ? : activeView ? : }
diff --git a/components/conditional-lottie.tsx b/components/conditional-lottie.tsx
index 55ca35d5..e29eda31 100644
--- a/components/conditional-lottie.tsx
+++ b/components/conditional-lottie.tsx
@@ -3,13 +3,15 @@
import LottiePlayer from '@/components/ui/lottie-player';
import { useMapLoading } from '@/components/map-loading-context';
import { useProfileToggle } from '@/components/profile-toggle-context'; // Added import
+import { useUsageToggle } from '@/components/usage-toggle-context';
const ConditionalLottie = () => {
const { isMapLoaded } = useMapLoading();
const { activeView } = useProfileToggle(); // Added this line
+ const { isUsageOpen } = useUsageToggle();
- // Updated isVisible logic
- return ;
+ // Updated isVisible logic to hide lottie when settings or usage is open
+ return ;
};
export default ConditionalLottie;
diff --git a/components/header.tsx b/components/header.tsx
index 71c7556c..b675055c 100644
--- a/components/header.tsx
+++ b/components/header.tsx
@@ -16,13 +16,25 @@ import {
import { MapToggle } from './map-toggle'
import { ProfileToggle } from './profile-toggle'
import { PurchaseCreditsPopup } from './purchase-credits-popup'
-import { UsageSidebar } from './usage-sidebar'
+import { useUsageToggle } from './usage-toggle-context'
+import { useProfileToggle } from './profile-toggle-context'
+import { useHistoryToggle } from './history-toggle-context'
import { useState, useEffect } from 'react'
export const Header = () => {
const { toggleCalendar } = useCalendarToggle()
const [isPurchaseOpen, setIsPurchaseOpen] = useState(false)
- const [isUsageOpen, setIsUsageOpen] = useState(false)
+ const { toggleUsage, isUsageOpen } = useUsageToggle()
+ const { activeView, closeProfileView } = useProfileToggle()
+ const { toggleHistory } = useHistoryToggle()
+
+ const handleUsageToggle = () => {
+ // If we're about to open usage and profile is open, close profile first
+ if (!isUsageOpen && activeView) {
+ closeProfileView()
+ }
+ toggleUsage()
+ }
useEffect(() => {
// Open payment popup as soon as application opens
@@ -32,8 +44,7 @@ export const Header = () => {
return (
<>
setIsPurchaseOpen(false)} />
- setIsUsageOpen(false)} />
-
+
-