redirect after saving
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { useAuth } from '../contexts/AuthContext'
|
import { useAuth } from '../contexts/AuthContext'
|
||||||
import { Link } from 'react-router-dom'
|
import { Link, useNavigate } from 'react-router-dom'
|
||||||
import { useState, useRef, useEffect } from 'react'
|
import { useState, useRef, useEffect } from 'react'
|
||||||
import { createEntry } from '../lib/api'
|
import { createEntry } from '../lib/api'
|
||||||
import { encryptEntry } from '../lib/crypto'
|
import { encryptEntry } from '../lib/crypto'
|
||||||
@@ -32,6 +32,7 @@ const SAVE_LEAVES = [
|
|||||||
|
|
||||||
export default function HomePage() {
|
export default function HomePage() {
|
||||||
const { user, userId, secretKey, loading } = useAuth()
|
const { user, userId, secretKey, loading } = useAuth()
|
||||||
|
const navigate = useNavigate()
|
||||||
const [entry, setEntry] = useState('')
|
const [entry, setEntry] = useState('')
|
||||||
const [title, setTitle] = useState('')
|
const [title, setTitle] = useState('')
|
||||||
const [phase, setPhase] = useState<'idle' | 'saving' | 'book' | 'celebrate'>('idle')
|
const [phase, setPhase] = useState<'idle' | 'saving' | 'book' | 'celebrate'>('idle')
|
||||||
@@ -83,7 +84,7 @@ export default function HomePage() {
|
|||||||
|
|
||||||
const handleBookDone = () => {
|
const handleBookDone = () => {
|
||||||
setPhase('celebrate')
|
setPhase('celebrate')
|
||||||
setTimeout(() => setPhase('idle'), 2500)
|
setTimeout(() => navigate('/history'), 2500)
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleTitleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
const handleTitleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user