fix: DevTools account switcher navigates to dashboard after login
This commit is contained in:
parent
4bf0471f7b
commit
57dee7870a
1 changed files with 4 additions and 0 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { useAuth } from '../../context/AuthContext';
|
import { useAuth } from '../../context/AuthContext';
|
||||||
import { Bug, ChevronUp, ChevronDown, User, X } from 'lucide-react';
|
import { Bug, ChevronUp, ChevronDown, User, X } from 'lucide-react';
|
||||||
import api from '../../lib/api';
|
import api from '../../lib/api';
|
||||||
|
|
@ -24,6 +25,7 @@ const DEV_USERS: DevUser[] = [
|
||||||
*/
|
*/
|
||||||
export function DevTools() {
|
export function DevTools() {
|
||||||
const { user, login, logout } = useAuth();
|
const { user, login, logout } = useAuth();
|
||||||
|
const navigate = useNavigate();
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
const [isLoading, setIsLoading] = useState<string | null>(null);
|
const [isLoading, setIsLoading] = useState<string | null>(null);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
@ -53,6 +55,8 @@ export function DevTools() {
|
||||||
const { accessToken, refreshToken, user: userData } = response.data;
|
const { accessToken, refreshToken, user: userData } = response.data;
|
||||||
login(accessToken, refreshToken, userData);
|
login(accessToken, refreshToken, userData);
|
||||||
setIsOpen(false);
|
setIsOpen(false);
|
||||||
|
// Navigate to dashboard after successful account switch
|
||||||
|
navigate('/');
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
setError(err.response?.data?.message || 'Login failed - run seed first?');
|
setError(err.response?.data?.message || 'Login failed - run seed first?');
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue