larxius commited on
Commit
73048ec
·
verified ·
1 Parent(s): bef6eb9

Update frontend/src/pages/SuperAdminPanel.jsx

Browse files
frontend/src/pages/SuperAdminPanel.jsx CHANGED
@@ -126,18 +126,27 @@ const SuperAdminPanel = () => {
126
  const [demoBookings, setDemoBookings] = useState([]);
127
  const [emailLogs, setEmailLogs] = useState([]);
128
  const [activeTab, setActiveTab] = useState(() => {
129
- const params = new URLSearchParams(window.location.search);
130
- const tabFromUrl = params.get('tab');
131
- const storedTab = localStorage.getItem('superAdminActiveTab');
132
- return tabFromUrl || storedTab || 'overview';
 
 
 
 
133
  });
134
 
135
  useEffect(() => {
136
- localStorage.setItem('superAdminActiveTab', activeTab);
137
- const url = new URL(window.location.href);
138
- if (url.searchParams.get('tab') !== activeTab) {
139
- url.searchParams.set('tab', activeTab);
140
- window.history.replaceState({}, '', url.toString());
 
 
 
 
 
141
  }
142
  }, [activeTab]);
143
 
 
126
  const [demoBookings, setDemoBookings] = useState([]);
127
  const [emailLogs, setEmailLogs] = useState([]);
128
  const [activeTab, setActiveTab] = useState(() => {
129
+ try {
130
+ const params = new URLSearchParams(window.location.search);
131
+ const tabFromUrl = params.get('tab');
132
+ const storedTab = localStorage.getItem('superAdminActiveTab');
133
+ return tabFromUrl || storedTab || 'overview';
134
+ } catch (e) {
135
+ return 'overview';
136
+ }
137
  });
138
 
139
  useEffect(() => {
140
+ try {
141
+ localStorage.setItem('superAdminActiveTab', activeTab);
142
+ const searchParams = new URLSearchParams(window.location.search);
143
+ if (searchParams.get('tab') !== activeTab) {
144
+ searchParams.set('tab', activeTab);
145
+ const newUrl = `${window.location.pathname}?${searchParams.toString()}`;
146
+ window.history.replaceState(null, '', newUrl);
147
+ }
148
+ } catch (e) {
149
+ // Ignore cross-origin history state errors in HF Spaces/iframes
150
  }
151
  }, [activeTab]);
152