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