implement hashrouter instead of browserrouter, add nextgraphauth logout to logout button

main
Christopher Maujean 2 months ago
parent 68a028cd22
commit c686261d43
  1. 2
      src/App.tsx
  2. 1
      src/components/layout/DashboardLayout.tsx
  3. 19
      src/pages/AccountPage.tsx

@ -1,4 +1,4 @@
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
import { HashRouter as Router, Routes, Route } from 'react-router-dom';
import { ThemeProvider } from '@mui/material/styles';
import CssBaseline from '@mui/material/CssBaseline';
import { OnboardingProvider } from '@/contexts/OnboardingContext';

@ -1,6 +1,7 @@
import { useState, useEffect } from 'react';
import type { ReactNode } from 'react';
import { useLocation, useNavigate } from 'react-router-dom';
import { useNextGraphAuth } from '@/lib/nextgraph';
import {
Box,
Drawer,

@ -1,5 +1,6 @@
import { useState, useEffect } from 'react';
import { useSearchParams } from 'react-router-dom';
import { useNextGraphAuth } from '@/lib/nextgraph';
import {
Typography,
Box,
@ -59,6 +60,7 @@ const TabPanel = ({ children, value, index }: TabPanelProps) => {
const AccountPage = () => {
const theme = useTheme();
const [searchParams] = useSearchParams();
const nextGraphAuth = useNextGraphAuth();
// Initialize tab from URL parameter
const initialTab = parseInt(searchParams.get('tab') || '0', 10);
@ -599,9 +601,20 @@ const AccountPage = () => {
<Button
variant="outlined"
startIcon={<Logout />}
onClick={() => {
// Handle logout
console.log('Logout clicked');
onClick={async () => {
try {
console.log('NextGraph Auth object:', nextGraphAuth);
console.log('Available methods:', nextGraphAuth ? Object.keys(nextGraphAuth) : 'none');
if (nextGraphAuth?.logout && typeof nextGraphAuth.logout === 'function') {
console.log('Calling logout...');
await nextGraphAuth.logout();
} else {
console.log('Logout function not available or not a function');
}
} catch (error) {
console.error('Logout failed:', error);
}
}}
sx={{
color: 'error.main',

Loading…
Cancel
Save