Fix Sasquatch "Learn More" landing on home instead of /onboarding

The guide's action buttons used window.location.href = '/onboarding', a hard
full-page navigation. In the SPA/native (Capacitor) context this reboots the
app at its entry point (home) rather than resolving the client-side route, so
tapping "Learn More" dumped users back on the home page.

Switched all Sasquatch guide navigation (Learn More, Login to begin, Login to
Offer Services / Create a Crew, Start exploring) to React Router's navigate(),
which performs proper in-app client-side routing and reliably renders the
target page.

Co-authored-by: shakespeare.diy <assistant@shakespeare.diy>
This commit is contained in:
shakespeare.diy 2026-08-27 11:20:53 +07:00
parent 37f07931d9
commit ea732fc386

View file

@ -1,5 +1,5 @@
import { useState, useEffect } from 'react';
import { useLocation } from 'react-router-dom';
import { useLocation, useNavigate } from 'react-router-dom';
import { useCurrentUser } from '@/hooks/useCurrentUser';
import type { GuideMessage } from '@/components/SasquatchGuide';
@ -9,6 +9,7 @@ import type { GuideMessage } from '@/components/SasquatchGuide';
*/
export function useSasquatchGuide() {
const location = useLocation();
const navigate = useNavigate();
const { user } = useCurrentUser();
const [currentMessage, setCurrentMessage] = useState<GuideMessage | undefined>();
@ -35,7 +36,7 @@ export function useSasquatchGuide() {
action: {
label: 'Learn More',
onClick: () => {
window.location.href = '/onboarding';
navigate('/onboarding');
},
},
enableChat: true,
@ -66,7 +67,7 @@ export function useSasquatchGuide() {
label: user ? 'Start exploring' : 'Login to begin',
onClick: () => {
if (user) {
window.location.href = '/map';
navigate('/map');
} else {
// Scroll to login section
const loginSection = document.getElementById('login-section');
@ -109,7 +110,7 @@ export function useSasquatchGuide() {
action: user ? undefined : {
label: 'Login to Offer Services',
onClick: () => {
window.location.href = '/onboarding';
navigate('/onboarding');
},
},
enableChat: true,
@ -136,7 +137,7 @@ export function useSasquatchGuide() {
action: user ? undefined : {
label: 'Login to Create a Crew',
onClick: () => {
window.location.href = '/onboarding';
navigate('/onboarding');
},
},
enableChat: true,
@ -151,7 +152,7 @@ export function useSasquatchGuide() {
}
setCurrentMessage(message);
}, [location.pathname, user]);
}, [location.pathname, user, navigate]);
const dismissCurrentMessage = () => {
setCurrentMessage(undefined);