This commit is contained in:
2026-03-31 10:23:49 +05:30
parent f488400c6d
commit cfecfa5116
8 changed files with 21 additions and 23 deletions

View File

@@ -1,12 +1,12 @@
import { useAuth } from '../contexts/AuthContext'
import { Link, useNavigate } from 'react-router-dom'
import { useState, useRef, useEffect } from 'react'
import { createEntry } from '../lib/api'
import { createEntry, updateUserProfile } from '../lib/api'
import { encryptEntry } from '../lib/crypto'
import BottomNav from '../components/BottomNav'
import WelcomeModal from '../components/WelcomeModal'
import { SaveBookAnimation } from '../components/SaveBookAnimation'
import { useOnboardingTour, hasSeenOnboarding, markOnboardingDone } from '../hooks/useOnboardingTour'
import { useOnboardingTour } from '../hooks/useOnboardingTour'
import { PageLoader } from '../components/PageLoader'
const AFFIRMATIONS = [
@@ -31,7 +31,7 @@ const SAVE_LEAVES = [
]
export default function HomePage() {
const { user, userId, secretKey, loading } = useAuth()
const { user, userId, mongoUser, secretKey, loading } = useAuth()
const navigate = useNavigate()
const [entry, setEntry] = useState('')
const [title, setTitle] = useState('')
@@ -47,19 +47,26 @@ export default function HomePage() {
// Check if onboarding should be shown after login
useEffect(() => {
if (!loading && user && userId && !hasSeenOnboarding()) {
if (!loading && user && userId && mongoUser && !mongoUser.tutorial) {
setShowWelcome(true)
}
}, [loading, user, userId])
}, [loading, user, userId, mongoUser])
async function markTutorialDone() {
if (!user || !userId) return
const token = await user.getIdToken()
updateUserProfile(userId, { tutorial: true }, token).catch(console.error)
}
const handleStartTour = () => {
setShowWelcome(false)
markTutorialDone()
startTour()
}
const handleSkipTour = () => {
setShowWelcome(false)
markOnboardingDone()
markTutorialDone()
}
if (loading) {