fix tut flow
This commit is contained in:
parent
329a71931b
commit
75f4257a69
@ -40,6 +40,7 @@ export default function QuickActionDashboardPage() {
|
||||
const [isTutorialOpen, setIsTutorialOpen] = useState(false)
|
||||
const [currentTutorialStep, setCurrentTutorialStep] = useState(1)
|
||||
const [hasSeenTutorial, setHasSeenTutorial] = useState(false)
|
||||
const forceOpenRef = useRef(false)
|
||||
|
||||
useEffect(() => {
|
||||
setIsClient(true)
|
||||
@ -69,7 +70,11 @@ export default function QuickActionDashboardPage() {
|
||||
useEffect(() => {
|
||||
if (!isClient) return
|
||||
if (loading || !userStatus) return
|
||||
if (allDone) smoothReplace('/dashboard') // CHANGED
|
||||
|
||||
const urlParams = new URLSearchParams(window.location.search)
|
||||
const forceOpen = urlParams.get('tutorial') === 'true'
|
||||
|
||||
if (allDone && !forceOpen) smoothReplace('/dashboard')
|
||||
}, [isClient, loading, userStatus, allDone, smoothReplace])
|
||||
|
||||
// NEW: decide which tutorial step to start on
|
||||
@ -86,8 +91,23 @@ export default function QuickActionDashboardPage() {
|
||||
// CHANGED: single auto-open mechanism (works even if tutorial_seen exists)
|
||||
useEffect(() => {
|
||||
if (!isClient) return
|
||||
const urlParams = new URLSearchParams(window.location.search)
|
||||
const forceOpen = urlParams.get('tutorial') === 'true'
|
||||
|
||||
if (forceOpen && !forceOpenRef.current && !isTutorialOpen) {
|
||||
// Open immediately to avoid dashboard flash; step will be corrected once status loads
|
||||
setCurrentTutorialStep(1)
|
||||
setIsTutorialOpen(true)
|
||||
forceOpenRef.current = true
|
||||
return
|
||||
}
|
||||
|
||||
if (loading || !userStatus) return
|
||||
if (allDone) return // NEW: avoid tutorial flash during redirect
|
||||
|
||||
if (isTutorialOpen && forceOpenRef.current) {
|
||||
setCurrentTutorialStep(getNextTutorialStep())
|
||||
}
|
||||
|
||||
if (isTutorialOpen) return
|
||||
|
||||
const uid =
|
||||
@ -100,9 +120,6 @@ export default function QuickActionDashboardPage() {
|
||||
|
||||
const tokenSuffix = (accessToken || '').slice(-12) || 'no-token'
|
||||
const sessionKey = `pp:tutorialShown:${uid}:${tokenSuffix}`
|
||||
|
||||
const urlParams = new URLSearchParams(window.location.search)
|
||||
const forceOpen = urlParams.get('tutorial') === 'true'
|
||||
if (forceOpen) {
|
||||
window.history.replaceState({}, '', window.location.pathname)
|
||||
}
|
||||
@ -180,7 +197,8 @@ export default function QuickActionDashboardPage() {
|
||||
setIsTutorialOpen(false)
|
||||
localStorage.setItem('tutorial_seen', 'true')
|
||||
setHasSeenTutorial(true)
|
||||
}, [])
|
||||
if (allDone) smoothReplace('/dashboard')
|
||||
}, [allDone, smoothReplace])
|
||||
|
||||
const nextTutorialStep = useCallback(() => {
|
||||
setCurrentTutorialStep(prev => prev + 1)
|
||||
|
||||
@ -306,17 +306,9 @@ export default function CompanyAdditionalInformationPage() {
|
||||
// Refresh user status to update profile completion state
|
||||
await refreshStatus()
|
||||
|
||||
// Redirect to next step after short delay
|
||||
// Redirect back to tutorial modal after short delay
|
||||
setTimeout(() => {
|
||||
// Check if we came from tutorial
|
||||
const urlParams = new URLSearchParams(window.location.search)
|
||||
const fromTutorial = urlParams.get('tutorial') === 'true'
|
||||
|
||||
if (fromTutorial) {
|
||||
router.push('/quickaction-dashboard?tutorial=true')
|
||||
} else {
|
||||
router.push('/quickaction-dashboard/register-sign-contract/company')
|
||||
}
|
||||
router.push('/quickaction-dashboard?tutorial=true')
|
||||
}, 1500)
|
||||
|
||||
} catch (error: any) {
|
||||
|
||||
@ -387,17 +387,9 @@ export default function PersonalAdditionalInformationPage() {
|
||||
// Refresh user status to update profile completion state
|
||||
await refreshStatus()
|
||||
|
||||
// Redirect to next step after short delay
|
||||
// Redirect back to tutorial modal after short delay
|
||||
setTimeout(() => {
|
||||
// Check if we came from tutorial
|
||||
const urlParams = new URLSearchParams(window.location.search)
|
||||
const fromTutorial = urlParams.get('tutorial') === 'true'
|
||||
|
||||
if (fromTutorial) {
|
||||
router.push('/quickaction-dashboard?tutorial=true')
|
||||
} else {
|
||||
router.push('/quickaction-dashboard/register-sign-contract/personal')
|
||||
}
|
||||
router.push('/quickaction-dashboard?tutorial=true')
|
||||
}, 1500)
|
||||
|
||||
} catch (error: any) {
|
||||
|
||||
@ -236,15 +236,7 @@ export default function EmailVerifyPage() {
|
||||
message: 'Your email has been verified successfully.'
|
||||
})
|
||||
await refreshStatus()
|
||||
setTimeout(() => {
|
||||
const urlParams = new URLSearchParams(window.location.search)
|
||||
const fromTutorial = urlParams.get('tutorial') === 'true'
|
||||
if (fromTutorial) {
|
||||
window.location.href = '/quickaction-dashboard?tutorial=true'
|
||||
} else {
|
||||
window.location.href = '/quickaction-dashboard'
|
||||
}
|
||||
}, 2000)
|
||||
window.location.href = '/quickaction-dashboard?tutorial=true'
|
||||
} else {
|
||||
const msg = data.error || 'Verification failed. Please try again.'
|
||||
setError(msg)
|
||||
|
||||
@ -277,9 +277,9 @@ export default function CompanySignContractPage() {
|
||||
// Refresh user status to update contract signed state
|
||||
await refreshStatus()
|
||||
|
||||
// Redirect to main dashboard after short delay
|
||||
// Redirect back to tutorial modal after short delay
|
||||
setTimeout(() => {
|
||||
router.push('/dashboard')
|
||||
router.push('/quickaction-dashboard?tutorial=true')
|
||||
}, 2000)
|
||||
|
||||
} catch (error: unknown) {
|
||||
|
||||
@ -314,9 +314,9 @@ export default function PersonalSignContractPage() {
|
||||
// Refresh user status to update contract signed state
|
||||
await refreshStatus()
|
||||
|
||||
// Redirect to main dashboard after short delay
|
||||
// Redirect back to tutorial modal after short delay
|
||||
setTimeout(() => {
|
||||
router.push('/dashboard')
|
||||
router.push('/quickaction-dashboard?tutorial=true')
|
||||
}, 2000)
|
||||
|
||||
} catch (error: unknown) {
|
||||
|
||||
@ -149,16 +149,7 @@ export function useCompanyUploadId() {
|
||||
await refreshStatus()
|
||||
|
||||
setTimeout(() => {
|
||||
// Check if we came from tutorial
|
||||
const urlParams = new URLSearchParams(window.location.search)
|
||||
const fromTutorial = urlParams.get('tutorial') === 'true'
|
||||
|
||||
if (fromTutorial) {
|
||||
window.location.href = '/quickaction-dashboard?tutorial=true'
|
||||
} else {
|
||||
// keep same redirect as page used before
|
||||
window.location.href = '/quickaction-dashboard/register-additional-information'
|
||||
}
|
||||
window.location.href = '/quickaction-dashboard?tutorial=true'
|
||||
}, 1500)
|
||||
} catch (err: any) {
|
||||
console.error('Company ID upload error:', err)
|
||||
|
||||
@ -165,15 +165,7 @@ export function usePersonalUploadId() {
|
||||
})
|
||||
await refreshStatus()
|
||||
setTimeout(() => {
|
||||
// Check if we came from tutorial
|
||||
const urlParams = new URLSearchParams(window.location.search)
|
||||
const fromTutorial = urlParams.get('tutorial') === 'true'
|
||||
|
||||
if (fromTutorial) {
|
||||
window.location.href = '/quickaction-dashboard?tutorial=true'
|
||||
} else {
|
||||
window.location.href = '/quickaction-dashboard'
|
||||
}
|
||||
window.location.href = '/quickaction-dashboard?tutorial=true'
|
||||
}, 2000)
|
||||
} else {
|
||||
const msg = data.message || 'Upload failed. Please try again.'
|
||||
|
||||
Loading…
Reference in New Issue
Block a user