From 7e3afeef5cbaad32a4d9792846e36268c54fc926 Mon Sep 17 00:00:00 2001 From: Ashad Qureshi Date: Fri, 13 Jun 2025 23:27:28 +0500 Subject: [PATCH 1/2] Window Hook Error Fixed --- auto-analyst-frontend/components/chat/Sidebar.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto-analyst-frontend/components/chat/Sidebar.tsx b/auto-analyst-frontend/components/chat/Sidebar.tsx index 398a4617..8c6ee85c 100644 --- a/auto-analyst-frontend/components/chat/Sidebar.tsx +++ b/auto-analyst-frontend/components/chat/Sidebar.tsx @@ -88,7 +88,7 @@ const Sidebar: React.FC = ({ isOpen, onClose, onNewChat, chatHisto // Also check admin status on client side only useEffect(() => { if (typeof window !== 'undefined') { - setIsAdmin(localStorage.getItem('isAdmin') === 'true') + setIsAdmin(localStorage.getItem('isAdmin') === 'true') } }, []) From a15f9615e823b536af8ba537dffbfc1132de5240 Mon Sep 17 00:00:00 2001 From: Ashad Qureshi Date: Fri, 13 Jun 2025 23:29:01 +0500 Subject: [PATCH 2/2] Window Hook Error Fixed --- .../components/custom-templates/useTemplates.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/auto-analyst-frontend/components/custom-templates/useTemplates.ts b/auto-analyst-frontend/components/custom-templates/useTemplates.ts index 5d29cd41..c0ee739a 100644 --- a/auto-analyst-frontend/components/custom-templates/useTemplates.ts +++ b/auto-analyst-frontend/components/custom-templates/useTemplates.ts @@ -86,7 +86,9 @@ export function useTemplates({ userId, enabled = true }: UseTemplatesProps): Use )) // Dispatch event for other components - window.dispatchEvent(new CustomEvent('template-preferences-updated')) + if (typeof window !== 'undefined') { + window.dispatchEvent(new CustomEvent('template-preferences-updated')) + } return true } else { @@ -123,7 +125,9 @@ export function useTemplates({ userId, enabled = true }: UseTemplatesProps): Use })) // Dispatch event for other components - window.dispatchEvent(new CustomEvent('template-preferences-updated')) + if (typeof window !== 'undefined') { + window.dispatchEvent(new CustomEvent('template-preferences-updated')) + } const successful = result.results?.filter((r: any) => r.success).length || updates.length const failed = result.results?.filter((r: any) => !r.success).length || 0 @@ -159,6 +163,8 @@ export function useTemplates({ userId, enabled = true }: UseTemplatesProps): Use // Listen for external updates useEffect(() => { + if (typeof window === 'undefined') return + const handleUpdate = () => { loadData() }